feat(jituan): 订单列表修复、财务 club 过滤、数据范围 API
This commit is contained in:
@@ -7100,19 +7100,17 @@ class KefuGetOrderListView(APIView):
|
||||
'6': platform_orders.filter(Status=6).count(),
|
||||
}
|
||||
|
||||
# ---------- 分页查询 ----------
|
||||
total_count = club_orders.filter(q_conditions).count()
|
||||
|
||||
orders_qs = club_orders.filter(q_conditions).select_related(
|
||||
'pingtai_kuozhan'
|
||||
).only(
|
||||
'OrderID', 'Description', 'Status', 'ProductTypeID', 'Platform',
|
||||
'Amount', 'ImageURL', 'CreateTime', 'Nickname', 'PlayerID',
|
||||
'pingtai_kuozhan__BossID'
|
||||
).order_by('-CreateTime')[(page-1)*page_size : page*page_size]
|
||||
# ---------- 分页查询(避免 only+select_related 导致列表为空) ----------
|
||||
list_qs = club_orders.filter(q_conditions).select_related('pingtai_kuozhan').order_by('-CreateTime')
|
||||
total_count = list_qs.count()
|
||||
orders_page = list_qs[(page - 1) * page_size: page * page_size].to_list()
|
||||
|
||||
# ---------- 获取老板昵称 ----------
|
||||
laoban_ids = [o.pingtai_kuozhan.BossID for o in orders_qs if hasattr(o, 'pingtai_kuozhan') and o.pingtai_kuozhan.BossID]
|
||||
laoban_ids = [
|
||||
o.pingtai_kuozhan.BossID
|
||||
for o in orders_page
|
||||
if getattr(o, 'pingtai_kuozhan', None) and o.pingtai_kuozhan.BossID
|
||||
]
|
||||
nickname_map = {}
|
||||
if laoban_ids:
|
||||
users = User.query.filter(UserUID__in=laoban_ids).select_related('BossProfile').only(
|
||||
@@ -7122,7 +7120,7 @@ class KefuGetOrderListView(APIView):
|
||||
nickname_map[user.UserUID] = (user.BossProfile.nickname or '') if getattr(user, 'BossProfile', None) else ''
|
||||
|
||||
result_list = []
|
||||
for order in orders_qs:
|
||||
for order in orders_page:
|
||||
ext = getattr(order, 'pingtai_kuozhan', None)
|
||||
laoban_id = ext.BossID if ext else ''
|
||||
youxi_nicheng = nickname_map.get(laoban_id, order.Nickname or '')
|
||||
@@ -7183,8 +7181,8 @@ class KefuGetShangjiaOrderListView(APIView):
|
||||
def post(self, request):
|
||||
start_total = time.time()
|
||||
|
||||
# 1. 获取前端参数
|
||||
username = request.data.get('username', '').strip()
|
||||
# 1. 获取前端参数(兼容 phone / username)
|
||||
username = request.data.get('username', '').strip() or request.data.get('phone', '').strip()
|
||||
if not username:
|
||||
return Response({'code': 400, 'msg': '缺少username'})
|
||||
|
||||
@@ -7277,18 +7275,16 @@ class KefuGetShangjiaOrderListView(APIView):
|
||||
}
|
||||
|
||||
# ---------- 分页查询 ----------
|
||||
total_count = club_orders.filter(q_conditions).count()
|
||||
|
||||
orders_qs = club_orders.filter(q_conditions).select_related(
|
||||
'shangjia_kuozhan'
|
||||
).only(
|
||||
'OrderID', 'Description', 'Status', 'ProductTypeID', 'Platform',
|
||||
'Amount', 'ImageURL', 'CreateTime', 'Nickname', 'PlayerID',
|
||||
'shangjia_kuozhan__MerchantID'
|
||||
).order_by('-CreateTime')[(page-1)*page_size : page*page_size]
|
||||
list_qs = club_orders.filter(q_conditions).select_related('shangjia_kuozhan').order_by('-CreateTime')
|
||||
total_count = list_qs.count()
|
||||
orders_page = list_qs[(page - 1) * page_size: page * page_size].to_list()
|
||||
|
||||
# ---------- 获取商家昵称 ----------
|
||||
shangjia_ids = [o.shangjia_kuozhan.MerchantID for o in orders_qs if hasattr(o, 'shangjia_kuozhan') and o.shangjia_kuozhan.MerchantID]
|
||||
shangjia_ids = [
|
||||
o.shangjia_kuozhan.MerchantID
|
||||
for o in orders_page
|
||||
if getattr(o, 'shangjia_kuozhan', None) and o.shangjia_kuozhan.MerchantID
|
||||
]
|
||||
nickname_map = {}
|
||||
if shangjia_ids:
|
||||
users = User.query.filter(UserUID__in=shangjia_ids).select_related('ShopProfile').only(
|
||||
@@ -7298,7 +7294,7 @@ class KefuGetShangjiaOrderListView(APIView):
|
||||
nickname_map[user.UserUID] = user.ShopProfile.nicheng or '' if hasattr(user, 'ShopProfile') else ''
|
||||
|
||||
result_list = []
|
||||
for order in orders_qs:
|
||||
for order in orders_page:
|
||||
ext = getattr(order, 'shangjia_kuozhan', None)
|
||||
shangjia_id = ext.MerchantID if ext else ''
|
||||
youxi_nicheng = order.Nickname or '' # 商家订单的玩家昵称
|
||||
|
||||
Reference in New Issue
Block a user