From e0cbfe732058839f65cd0af7501022a5e0497dcf Mon Sep 17 00:00:00 2001 From: tikkhun Date: Wed, 28 Jan 2026 21:27:37 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E8=AE=A2=E5=8D=95=E6=9C=8D=E5=8A=A1):?= =?UTF-8?q?=20=E7=A7=BB=E9=99=A4getComponentDetailFromSiteSku=E4=B8=AD?= =?UTF-8?q?=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84quantity=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 简化组件详情查询逻辑,默认数量设为1,不再需要外部传入quantity参数 --- src/service/order.service.ts | 2 +- src/service/product.service.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/service/order.service.ts b/src/service/order.service.ts index 3a8e70b..2b899c2 100644 --- a/src/service/order.service.ts +++ b/src/service/order.service.ts @@ -733,7 +733,7 @@ export class OrderService { if (!orderItem.sku) return; // 从数据库查询产品,关联查询组件 - const componentDetails = await this.productService.getComponentDetailFromSiteSku({ sku: orderItem.sku, name: orderItem.name },orderItem.quantity,site); + const componentDetails = await this.productService.getComponentDetailFromSiteSku({ sku: orderItem.sku, name: orderItem.name }, site); if(!componentDetails?.length){ return } diff --git a/src/service/product.service.ts b/src/service/product.service.ts index 47b9aa2..9984dcf 100644 --- a/src/service/product.service.ts +++ b/src/service/product.service.ts @@ -1786,7 +1786,7 @@ export class ProductService { } } // 获取库存单品列表 - async getComponentDetailFromSiteSku(siteProduct: { sku: string, name: string }, quantity: number = 1, site: Site): Promise<{ product: Product,parentProduct?: Product, quantity: number }[]> { + async getComponentDetailFromSiteSku(siteProduct: { sku: string, name: string }, site: Site): Promise<{ product: Product,parentProduct?: Product, quantity: number }[]> { if (!siteProduct.sku) { throw new Error('siteSku 不能为空') } @@ -1798,7 +1798,7 @@ export class ProductService { if(!product?.components?.length){ return [{ product, - quantity + quantity:1 }] } @@ -1808,7 +1808,7 @@ export class ProductService { where: { id: comp.productId }, }), parentProduct: product, // 这里得记录一下他的爸爸用来记录 - quantity: comp.quantity * quantity, + quantity: comp.quantity, } })) }