商家订单列表支持时间段筛选并修正分页has_more
This commit is contained in:
@@ -2058,12 +2058,7 @@ class ShangjiaDingdanHuoquView(APIView):
|
||||
page = max(1, int(data.get('page', 1)))
|
||||
page_size = min(100, max(1, int(data.get('page_size', 10))))
|
||||
|
||||
# 🆕 商品类型筛选(兼容 leixing_id / ProductTypeID)
|
||||
leixing_id = pick_leixing_id(data)
|
||||
|
||||
# 🆕 模糊搜索关键字(支持订单ID、订单介绍、游戏昵称、打手ID、拼多多订单号)
|
||||
keyword = data.get('keyword', '').strip()
|
||||
waibu_dingdan_id = str(data.get('waibuDingdanId') or '').strip()
|
||||
# 商品类型 / 关键字 / 时间段等见 apply_merchant_order_list_filters
|
||||
except (ValueError, TypeError):
|
||||
return Response({
|
||||
'code': 2,
|
||||
@@ -2080,6 +2075,8 @@ class ShangjiaDingdanHuoquView(APIView):
|
||||
}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
try:
|
||||
from orders.services.merchant_order_list_filters import apply_merchant_order_list_filters
|
||||
|
||||
# 4. 构建基础查询(该商家的所有订单)
|
||||
base_qs = MerchantOrderExt.query.filter(
|
||||
MerchantID=yonghuid
|
||||
@@ -2088,28 +2085,8 @@ class ShangjiaDingdanHuoquView(APIView):
|
||||
# 5. 状态过滤
|
||||
base_qs = base_qs.filter(Order__Status__in=zhuangtai_list)
|
||||
|
||||
# 6. 商品类型筛选
|
||||
if leixing_id is not None:
|
||||
base_qs = base_qs.filter(Order__ProductTypeID=leixing_id)
|
||||
|
||||
# 7. 模糊搜索(支持订单ID、订单介绍、游戏昵称、打手ID、拼多多订单号)
|
||||
if waibu_dingdan_id:
|
||||
base_qs = base_qs.filter(Order__ExternalOrderID__exact=waibu_dingdan_id)
|
||||
elif keyword:
|
||||
# 订单ID精确匹配(dingdan_id有唯一索引,先用精确匹配)
|
||||
dingdan_id_match = Q(Order__OrderID__exact=keyword)
|
||||
# 订单介绍模糊匹配
|
||||
jieshao_match = Q(Order__Description__icontains=keyword)
|
||||
# 游戏昵称模糊匹配
|
||||
nicheng_match = Q(Order__Nickname__icontains=keyword)
|
||||
# 打手ID精确匹配
|
||||
dashou_match = Q(Order__PlayerID__exact=keyword)
|
||||
# 拼多多订单号精确匹配
|
||||
waibu_match = Q(Order__ExternalOrderID__exact=keyword)
|
||||
|
||||
base_qs = base_qs.filter(
|
||||
dingdan_id_match | jieshao_match | nicheng_match | dashou_match | waibu_match
|
||||
)
|
||||
# 6–7. 类型 / 关键字 / 时间段
|
||||
base_qs = apply_merchant_order_list_filters(base_qs, data)
|
||||
|
||||
# 8. 计算待结算订单数量(状态为8)
|
||||
pending_count = MerchantOrderExt.query.filter(
|
||||
@@ -2131,7 +2108,7 @@ class ShangjiaDingdanHuoquView(APIView):
|
||||
|
||||
# 11. 判断是否还有更多
|
||||
current_page_count = len(current_page_orders)
|
||||
has_more = current_page_count == page_size and end_index < total_count
|
||||
has_more = start_index + current_page_count < total_count
|
||||
|
||||
return Response({
|
||||
'code': 0,
|
||||
|
||||
Reference in New Issue
Block a user