fix: 资源中文说明、补全打手日统计写入、今日榜仅读日统计表
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -17,7 +17,7 @@ from houtai.models import (
|
||||
ZuzhangRiTongji,
|
||||
ShangjiaRiTongji,
|
||||
)
|
||||
from yonghu.models import UserMain, UserDashou, UserShangjia, UserBoss, UserGuanshi, UserZuzhang
|
||||
from yonghu.models import UserMain, UserDashou, UserShangjia, UserBoss
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -57,44 +57,6 @@ ROLE_CONFIG = {
|
||||
},
|
||||
}
|
||||
|
||||
TODAY_PROFILE_CONFIG = {
|
||||
'dashou': {
|
||||
'profile_model': UserDashou,
|
||||
'profile_sort_field': 'jinrishouyi',
|
||||
'field_map': {
|
||||
'jiedan_zongliang': 'jinrijiedan',
|
||||
'chengjiao_zongliang': 'jinrijiedan',
|
||||
'jiedan_zonge': 'jinrishouyi',
|
||||
'chengjiao_zonge': 'jinrishouyi',
|
||||
},
|
||||
},
|
||||
'guanshi': {
|
||||
'profile_model': UserGuanshi,
|
||||
'profile_sort_field': None,
|
||||
'field_map': {},
|
||||
'skip_profile_fallback': True,
|
||||
},
|
||||
'zuzhang': {
|
||||
'profile_model': UserZuzhang,
|
||||
'profile_sort_field': 'jinri_fenyong',
|
||||
'field_map': {
|
||||
'yaoqing_guanshi_shu': None,
|
||||
'fenyong_jine': 'jinri_fenyong',
|
||||
'shouru_zonge': 'jinri_fenyong',
|
||||
},
|
||||
},
|
||||
'shangjia': {
|
||||
'profile_model': UserShangjia,
|
||||
'profile_sort_field': 'jinriliushui',
|
||||
'field_map': {
|
||||
'paifa_dingdan_shu': 'jinridingdan',
|
||||
'paifa_jine': 'jinriliushui',
|
||||
'jiesuan_dingdan_shu': None,
|
||||
'jiesuan_jine': None,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
def _resolve_date_range(riqi: str):
|
||||
today = date.today()
|
||||
if riqi == '今日':
|
||||
@@ -218,14 +180,6 @@ class PhbHqsjView(APIView):
|
||||
{id_field: getattr(r, id_field), **{f: getattr(r, f) for f in fields}}
|
||||
for r in qs
|
||||
]
|
||||
if rows:
|
||||
return rows
|
||||
today = date.today()
|
||||
if start_date == today:
|
||||
today_cfg = TODAY_PROFILE_CONFIG.get(shenfen, {})
|
||||
if today_cfg.get('skip_profile_fallback'):
|
||||
return rows
|
||||
return self._query_today_from_profiles(shenfen)
|
||||
return rows
|
||||
|
||||
rows = (
|
||||
@@ -237,36 +191,6 @@ class PhbHqsjView(APIView):
|
||||
)
|
||||
return list(rows)
|
||||
|
||||
def _query_today_from_profiles(self, shenfen):
|
||||
cfg = ROLE_CONFIG[shenfen]
|
||||
today_cfg = TODAY_PROFILE_CONFIG[shenfen]
|
||||
if today_cfg.get('skip_profile_fallback'):
|
||||
return []
|
||||
profile_model = today_cfg['profile_model']
|
||||
profile_sort = today_cfg['profile_sort_field']
|
||||
if not profile_sort:
|
||||
return []
|
||||
field_map = today_cfg['field_map']
|
||||
id_field = cfg['id_field']
|
||||
fields = cfg['fields']
|
||||
|
||||
qs = profile_model.objects.filter(
|
||||
**{f'{profile_sort}__gt': 0}
|
||||
).select_related('user').order_by(f'-{profile_sort}')[:MAX_RANK]
|
||||
|
||||
rows = []
|
||||
for p in qs:
|
||||
uid = p.user.yonghuid
|
||||
row = {id_field: uid}
|
||||
for f in fields:
|
||||
profile_field = field_map.get(f)
|
||||
if profile_field:
|
||||
row[f] = getattr(p, profile_field)
|
||||
else:
|
||||
row[f] = 0
|
||||
rows.append(row)
|
||||
return rows
|
||||
|
||||
def _load_user_display(self, rows, shenfen):
|
||||
id_field = ROLE_CONFIG[shenfen]['id_field']
|
||||
yonghuids = [r[id_field] for r in rows if r.get(id_field)]
|
||||
|
||||
@@ -9274,6 +9274,7 @@ class KefuPlatformRefundView(APIView):
|
||||
|
||||
# 14. 打手每日统计(退款)
|
||||
try:
|
||||
from houtai.utils import update_dashou_daily_by_action
|
||||
update_dashou_daily_by_action(
|
||||
yonghuid=order.jiedan_dashou_id,
|
||||
amount=order.dashou_fencheng,
|
||||
@@ -10371,6 +10372,7 @@ class KefuForceCompleteView(APIView):
|
||||
|
||||
# 🔥 新增:调用打手每日统计(成交)
|
||||
try:
|
||||
from houtai.utils import update_dashou_daily_by_action
|
||||
update_dashou_daily_by_action(
|
||||
yonghuid=order.jiedan_dashou_id,
|
||||
amount=dashou_fencheng,
|
||||
|
||||
Reference in New Issue
Block a user