fix: 店铺订单接口 PlatformOrderExt 查询字段修正
将 dianpu_id 改为模型字段 ShopID,修复 ddltj/ddlbhq 的 FieldError;统计聚合改用 id__in 匹配 Order 主键。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -143,7 +143,7 @@ class ShopOrderStatisticsView(APIView):
|
||||
|
||||
# 3. 获取本店铺所有订单的主键ID列表(通过平台扩展表)
|
||||
order_pks = list(
|
||||
PlatformOrderExt.query.filter(dianpu_id=shop_id)
|
||||
PlatformOrderExt.query.filter(ShopID=shop_id)
|
||||
.values_list('Order_id', flat=True) # 这里取的是订单主表的主键id
|
||||
)
|
||||
|
||||
@@ -401,7 +401,7 @@ class ShopOrderManageView(APIView):
|
||||
# 从 DingdanPingtai 中过滤出属于当前店铺的订单扩展记录,并提取订单主表ID
|
||||
order_ids = list(
|
||||
PlatformOrderExt.query.filter(
|
||||
dianpu_id=shop_id # 店铺ID匹配
|
||||
ShopID=shop_id # 店铺ID匹配
|
||||
).values_list('Order_id', flat=True) # 只取订单ID字段
|
||||
)
|
||||
|
||||
@@ -415,7 +415,7 @@ class ShopOrderManageView(APIView):
|
||||
if order_ids:
|
||||
# 使用 Django 聚合查询:按 leixing_id(商品类型)和 zhuangtai(订单状态)分组计数
|
||||
aggregation = Order.query.filter(
|
||||
OrderID__in=order_ids # 从该店铺的订单中查询
|
||||
id__in=order_ids # Order_id 为订单主键 id
|
||||
).values(
|
||||
'ProductTypeID', # 按类型ID分组
|
||||
'Status' # 按状态分组
|
||||
@@ -482,7 +482,7 @@ class ShopOrderManageView(APIView):
|
||||
|
||||
# 基础查询:从平台扩展表关联订单主表,并按创建时间倒序
|
||||
qs = PlatformOrderExt.query.filter(
|
||||
dianpu_id=shop_id
|
||||
ShopID=shop_id
|
||||
).select_related('Order').order_by('-Order__CreateTime')
|
||||
|
||||
# 应用筛选条件
|
||||
|
||||
Reference in New Issue
Block a user