fix: 总榜按无效人数排行;总会员ID匹配与子类型展开修复

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-11 01:56:39 +08:00
parent fda4ffb628
commit 5556bbdb61
4 changed files with 172 additions and 31 deletions

View File

@@ -181,6 +181,48 @@ class XzjPhbHqsjView(APIView):
})
try:
if riqi == '总榜' and shenfen in ('guanshi', 'zuzhang'):
from rank.reward_services import (
WUXIAO_TOTAL_RANK_SORT_FIELDS,
enrich_rank_stats,
query_wuxiao_total_rank_rows,
)
wuxiao_rows = query_wuxiao_total_rank_rows(shenfen, club_id=None, limit=MAX_RANK)
cfg = XZJ_ROLE_CONFIG[shenfen]
id_field = cfg['id_field']
wuxiao_key = WUXIAO_TOTAL_RANK_SORT_FIELDS[shenfen]
pseudo_rows = [{id_field: r['yonghuid']} for r in wuxiao_rows]
nick_map, avatar_map = self._load_user_display(pseudo_rows, shenfen)
yonghuids = [r['yonghuid'] for r in wuxiao_rows]
stats_map = enrich_rank_stats(shenfen, yonghuids, riqi, '')
result_list = []
for idx, row in enumerate(wuxiao_rows):
yonghuid = row['yonghuid']
metric = int(row.get('metric') or 0)
item = {
'mingci': idx + 1,
'yonghuid': yonghuid,
'nicheng': nick_map.get(yonghuid, '用户'),
'touxiang': avatar_map.get(yonghuid, '') or '',
wuxiao_key: metric,
'sort_field': wuxiao_key,
'metric_value': metric,
'metric_label': '无效人数',
}
extra = stats_map.get(yonghuid) or {}
for k, v in extra.items():
item[k] = v
result_list.append(item)
return Response({
'code': 200,
'msg': '获取成功',
'data': {
'list': result_list,
'sort_field': wuxiao_key,
'sort_label': '无效人数',
},
})
if riqi == '总榜':
rows = self._query_rows(shenfen, all_time=True)
start_date, end_date = None, None