fix: 总榜按邀请总人数排行,组长去重统计;总会员子类型解析增强

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-11 02:00:31 +08:00
parent 5556bbdb61
commit 80cca803f8
4 changed files with 98 additions and 68 deletions

View File

@@ -183,20 +183,21 @@ class XzjPhbHqsjView(APIView):
try:
if riqi == '总榜' and shenfen in ('guanshi', 'zuzhang'):
from rank.reward_services import (
WUXIAO_TOTAL_RANK_SORT_FIELDS,
TOTAL_RANK_INVITE_SORT_FIELDS,
TOTAL_RANK_INVITE_SORT_LABEL,
enrich_rank_stats,
query_wuxiao_total_rank_rows,
query_total_rank_invite_rows,
)
wuxiao_rows = query_wuxiao_total_rank_rows(shenfen, club_id=None, limit=MAX_RANK)
rank_rows = query_total_rank_invite_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]
sort_key = TOTAL_RANK_INVITE_SORT_FIELDS[shenfen]
pseudo_rows = [{id_field: r['yonghuid']} for r in rank_rows]
nick_map, avatar_map = self._load_user_display(pseudo_rows, shenfen)
yonghuids = [r['yonghuid'] for r in wuxiao_rows]
yonghuids = [r['yonghuid'] for r in rank_rows]
stats_map = enrich_rank_stats(shenfen, yonghuids, riqi, '')
result_list = []
for idx, row in enumerate(wuxiao_rows):
for idx, row in enumerate(rank_rows):
yonghuid = row['yonghuid']
metric = int(row.get('metric') or 0)
item = {
@@ -204,10 +205,10 @@ class XzjPhbHqsjView(APIView):
'yonghuid': yonghuid,
'nicheng': nick_map.get(yonghuid, '用户'),
'touxiang': avatar_map.get(yonghuid, '') or '',
wuxiao_key: metric,
'sort_field': wuxiao_key,
sort_key: metric,
'sort_field': sort_key,
'metric_value': metric,
'metric_label': '无效人数',
'metric_label': TOTAL_RANK_INVITE_SORT_LABEL,
}
extra = stats_map.get(yonghuid) or {}
for k, v in extra.items():
@@ -218,8 +219,8 @@ class XzjPhbHqsjView(APIView):
'msg': '获取成功',
'data': {
'list': result_list,
'sort_field': wuxiao_key,
'sort_label': '无效人数',
'sort_field': sort_key,
'sort_label': TOTAL_RANK_INVITE_SORT_LABEL,
},
})