fix: 资源中文说明、补全打手日统计写入、今日榜仅读日统计表
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2502,7 +2502,7 @@ from rest_framework import status
|
||||
|
||||
from yonghu.models import UserMain, UserShangjia, UserDashou
|
||||
|
||||
from houtai.utils import update_shangjia_daily
|
||||
from houtai.utils import update_shangjia_daily, update_dashou_daily_by_action
|
||||
|
||||
|
||||
# 导入 Celery 广播任务
|
||||
@@ -3071,7 +3071,7 @@ from dingdan.models import Dingdan, DingdanShangjia, PreSettlement
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from houtai.utils import update_shangjia_daily
|
||||
from houtai.utils import update_shangjia_daily, update_dashou_daily_by_action
|
||||
class ShangjiaJiesuanView(APIView):
|
||||
"""商家结单接口(支持跨平台订单)"""
|
||||
permission_classes = [permissions.IsAuthenticated]
|
||||
|
||||
@@ -154,6 +154,22 @@ def update_dashou_daily(yonghuid, jiedan_jine=Decimal('0.00'), chengjiao_jine=De
|
||||
DashouRiTongji.objects.filter(id=stat.id).update(**update_fields)
|
||||
|
||||
|
||||
def update_dashou_daily_by_action(yonghuid, amount, action):
|
||||
"""
|
||||
根据行为类型更新打手每日统计(写入 dashou_ri_tongji 日统计表)
|
||||
action: 1=接单, 2=成交/结算, 3=退款
|
||||
"""
|
||||
amount = Decimal(str(amount)) if amount else Decimal('0.00')
|
||||
if amount <= 0:
|
||||
return
|
||||
if action == 1:
|
||||
update_dashou_daily(yonghuid, jiedan_jine=amount)
|
||||
elif action == 2:
|
||||
update_dashou_daily(yonghuid, chengjiao_jine=amount)
|
||||
elif action == 3:
|
||||
update_dashou_daily(yonghuid, tuikuan_jine=amount)
|
||||
|
||||
|
||||
|
||||
def update_shangjia_daily(yonghuid, amount, action):
|
||||
"""
|
||||
|
||||
@@ -10,7 +10,7 @@ from rest_framework.views import APIView
|
||||
from houtai.utils import verify_kefu_permission
|
||||
from peizhi.models import XcxSysPeizhi, XcxPageZiyuan
|
||||
from utils.oss_utils import upload_to_oss, validate_image
|
||||
from utils.page_ziyuan_service import DEFAULT_ZIYUAN, build_page_assets_for_api, clear_page_ziyuan_cache
|
||||
from utils.page_ziyuan_service import DEFAULT_ZIYUAN, build_page_assets_for_api, clear_page_ziyuan_cache, get_ziyuan_miaoshu
|
||||
from utils.xcx_sys_config import clear_xcx_sys_peizhi_cache, wx_cfg
|
||||
from yonghu.models import AdminProfile
|
||||
|
||||
@@ -179,7 +179,7 @@ class XcxPageZiyuanQueryView(APIView):
|
||||
'ziyuan_zu': gzu,
|
||||
'ziyuan_key': key,
|
||||
'ziyuan_path': path,
|
||||
'miaoshu': DEFAULT_ZIYUAN.get(f'{gzu}.{key}', ''),
|
||||
'miaoshu': get_ziyuan_miaoshu(gzu, key),
|
||||
})
|
||||
return Response({'code': 0, 'msg': 'success', 'data': {'list': items, 'groups': groups}})
|
||||
|
||||
|
||||
@@ -44,6 +44,50 @@ DEFAULT_ZIYUAN = {
|
||||
'guanshiduan.iconArrow': 'beijing/guanshiduan/icon-arrow.png',
|
||||
}
|
||||
|
||||
# 后台配置页展示用中文说明(键名 pageBg 等仅供程序识别)
|
||||
ZIYUAN_MIAOSHU = {
|
||||
'paihangbang.pageBg': '排行榜 · 整页背景图',
|
||||
'paihangbang.cardBg': '排行榜 · 列表卡片背景',
|
||||
'paihangbang.emptyIcon': '排行榜 · 暂无数据图标',
|
||||
'paihangbang.refreshIcon': '排行榜 · 刷新按钮图标',
|
||||
'shangjiaduan.pageBg': '商家端 · 首页背景图',
|
||||
'shangjiaduan.avatarCardBg': '商家端 · 头像区域卡片背景',
|
||||
'shangjiaduan.assetCardBg': '商家端 · 余额/资产卡片背景',
|
||||
'shangjiaduan.statCardBg': '商家端 · 数据统计卡片背景',
|
||||
'shangjiaduan.funcItemBg': '商家端 · 普通功能入口背景',
|
||||
'shangjiaduan.primaryFuncBg': '商家端 · 主要功能按钮背景',
|
||||
'shangjiaduan.highlightFuncBg': '商家端 · 高亮功能按钮背景',
|
||||
'shangjiaduan.iconRelease': '商家端 · 发布/派单图标',
|
||||
'shangjiaduan.iconFast': '商家端 · 快捷操作图标',
|
||||
'shangjiaduan.iconOrders': '商家端 · 订单列表图标',
|
||||
'shangjiaduan.iconService': '商家端 · 客服/服务图标',
|
||||
'shangjiaduan.iconPunish': '商家端 · 处罚相关图标',
|
||||
'shangjiaduan.iconRank': '商家端 · 排行榜入口图标',
|
||||
'shangjiaduan.iconRecharge': '商家端 · 充值图标',
|
||||
'shangjiaduan.iconWithdraw': '商家端 · 提现图标',
|
||||
'shangjiaduan.iconRefresh': '商家端 · 刷新图标',
|
||||
'shangjiaduan.iconCopy': '商家端 · 复制图标',
|
||||
'shangjiaduan.avatarFrame': '商家端 · 头像边框装饰',
|
||||
'guanshiduan.pageBg': '管事端 · 首页背景图',
|
||||
'guanshiduan.topDecor': '管事端 · 顶部装饰图',
|
||||
'guanshiduan.cardBg1': '管事端 · 卡片背景(样式一)',
|
||||
'guanshiduan.cardBg2': '管事端 · 卡片背景(样式二)',
|
||||
'guanshiduan.iconRefresh': '管事端 · 刷新图标',
|
||||
'guanshiduan.iconCopy': '管事端 · 复制图标',
|
||||
'guanshiduan.iconInvite': '管事端 · 邀请打手图标',
|
||||
'guanshiduan.iconSub': '管事端 · 下级/下属图标',
|
||||
'guanshiduan.iconRecord': '管事端 · 记录/流水图标',
|
||||
'guanshiduan.iconRank': '管事端 · 排行榜图标',
|
||||
'guanshiduan.iconPoster': '管事端 · 海报/分享图标',
|
||||
'guanshiduan.iconWithdraw': '管事端 · 提现图标',
|
||||
'guanshiduan.iconContact': '管事端 · 联系客服图标',
|
||||
'guanshiduan.iconArrow': '管事端 · 箭头/跳转图标',
|
||||
}
|
||||
|
||||
|
||||
def get_ziyuan_miaoshu(zu: str, key: str) -> str:
|
||||
return ZIYUAN_MIAOSHU.get(f'{zu}.{key}', f'{zu} · {key}')
|
||||
|
||||
|
||||
def clear_page_ziyuan_cache():
|
||||
cache.delete_many([
|
||||
@@ -107,4 +151,5 @@ def build_page_assets_for_api():
|
||||
return {
|
||||
'shangjiaduan': get_ziyuan_group('shangjiaduan'),
|
||||
'paihangbang': get_ziyuan_group('paihangbang'),
|
||||
'guanshiduan': get_ziyuan_group('guanshiduan'),
|
||||
}
|
||||
|
||||
@@ -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