From fd7bcde9d913b2cb35e756ef3893c1674e591478 Mon Sep 17 00:00:00 2001 From: XingQue Date: Thu, 9 Jul 2026 20:39:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BA=97=E9=93=BA=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20PlatformOrderExt=20=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 dianpu_id 改为模型字段 ShopID,修复 ddltj/ddlbhq 的 FieldError;统计聚合改用 id__in 匹配 Order 主键。 Co-authored-by: Cursor --- shop/views/shop_order_views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shop/views/shop_order_views.py b/shop/views/shop_order_views.py index a151196..4a4476f 100644 --- a/shop/views/shop_order_views.py +++ b/shop/views/shop_order_views.py @@ -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') # 应用筛选条件