feat: 订单列表/详情返回自动结算倒计时字段,并加小程序结算率接口
仅 eligible 结算中订单下发预计时间;支持 auto_settle_pending 筛选;新增 /dingdan/wo-de-deal-stat。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -114,3 +114,54 @@ class DashouDealStatView(APIView):
|
||||
'msg': 'ok',
|
||||
'data': {'list': [stats_svc.serialize_dashou_stat(r) for r in qs]},
|
||||
})
|
||||
|
||||
|
||||
class MiniappMyDealStatView(APIView):
|
||||
"""
|
||||
POST /dingdan/wo-de-deal-stat
|
||||
小程序订单列表顶:结算率/罚款率。
|
||||
body.role: merchant | dashou(默认按身份推断)
|
||||
商家客服看所属商家指标;无样本返回 data=null。
|
||||
"""
|
||||
permission_classes = [IsAuthenticated]
|
||||
parser_classes = [JSONParser]
|
||||
|
||||
def post(self, request):
|
||||
club_id = (resolve_club_id_from_request(request) or '').strip()
|
||||
if not club_id:
|
||||
return Response({'code': 400, 'msg': '缺少俱乐部', 'data': None})
|
||||
user = request.user
|
||||
uid = getattr(user, 'UserUID', '') or ''
|
||||
role = (request.data.get('role') or '').strip().lower()
|
||||
|
||||
if role not in ('merchant', 'dashou'):
|
||||
# 推断:活跃子客服 → merchant;否则看商家认证 / 打手
|
||||
from merchant_ops.services.authz import get_active_staff_member, is_merchant_owner
|
||||
if get_active_staff_member(user) or is_merchant_owner(user):
|
||||
role = 'merchant'
|
||||
else:
|
||||
role = 'dashou'
|
||||
|
||||
if role == 'merchant':
|
||||
merchant_uid = uid
|
||||
from merchant_ops.services.authz import get_active_staff_member, is_merchant_owner, member_has_perm
|
||||
member = get_active_staff_member(user)
|
||||
if member and not is_merchant_owner(user):
|
||||
if not member_has_perm(member, 'order_view_all') and not member_has_perm(member, 'order_view_self'):
|
||||
return Response({'code': 403, 'msg': '无订单查看权限', 'data': None})
|
||||
merchant_uid = member.merchant_id
|
||||
from jituan.models import MerchantDealStat
|
||||
row = MerchantDealStat.query.filter(club_id=club_id, merchant_uid=merchant_uid).first()
|
||||
return Response({
|
||||
'code': 0,
|
||||
'msg': 'ok',
|
||||
'data': stats_svc.miniapp_merchant_deal_payload(row),
|
||||
})
|
||||
|
||||
from jituan.models import DashouDealStat
|
||||
row = DashouDealStat.query.filter(club_id=club_id, dashou_uid=uid).first()
|
||||
return Response({
|
||||
'code': 0,
|
||||
'msg': 'ok',
|
||||
'data': stats_svc.miniapp_dashou_deal_payload(row),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user