From 8766cf4a4c46f6ddf3a96604c57f802d29b4c7a9 Mon Sep 17 00:00:00 2001 From: tikkhun Date: Sat, 17 Jan 2026 09:31:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=AE=A2=E5=8D=95):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=88=B6=E4=BA=A7=E5=93=81ID=E5=AD=97=E6=AE=B5=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E7=BB=9F=E8=AE=A1=E5=A5=97=E9=A4=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在订单服务和订单销售实体中添加 parentProductId 字段,用于区分套餐产品和单品。如果是套餐产品则记录父产品ID,单品则不记录该字段 --- src/entity/order_sale.entity.ts | 9 +++++++-- src/service/order.service.ts | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/entity/order_sale.entity.ts b/src/entity/order_sale.entity.ts index 2c11dd9..575eba4 100644 --- a/src/entity/order_sale.entity.ts +++ b/src/entity/order_sale.entity.ts @@ -37,11 +37,16 @@ export class OrderSale { @Expose() externalOrderItemId: string; // WooCommerce 订单item ID + @ApiProperty({name: "父产品 ID"}) + @Column({ nullable: true }) + @Expose() + parentProductId?: number; // 父产品 ID 用于统计套餐 如果是单品则不记录 + @ApiProperty({name: "产品 ID"}) @Column() @Expose() productId: number; - + @ApiProperty() @Column() @Expose() @@ -50,7 +55,7 @@ export class OrderSale { @ApiProperty({ description: 'sku', type: 'string' }) @Expose() @Column() - sku: string; + sku: string;// 库存产品sku @ApiProperty() @Column() diff --git a/src/service/order.service.ts b/src/service/order.service.ts index 586a5b4..6198873 100644 --- a/src/service/order.service.ts +++ b/src/service/order.service.ts @@ -738,6 +738,7 @@ export class OrderService { orderId: orderItem.orderId, siteId: orderItem.siteId, externalOrderItemId: orderItem.externalOrderItemId, + parentProductId: product.id, // 父产品 ID 用于统计套餐 如果是单品则不记录 productId: componentDetail.product.id, name: componentDetail.product.name, quantity: componentDetail.quantity * orderItem.quantity,