From d3d493f85820c56648954315641deb413787cb0f Mon Sep 17 00:00:00 2001 From: tikkhun Date: Tue, 27 Jan 2026 18:42:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=B8=AD=E4=BA=A7=E5=93=81=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加对productDetail.product的检查,避免在product为undefined时访问components属性 --- src/service/order.service.ts | 3 ++- src/service/product.service.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/service/order.service.ts b/src/service/order.service.ts index c764bb4..7553dfc 100644 --- a/src/service/order.service.ts +++ b/src/service/order.service.ts @@ -735,8 +735,9 @@ export class OrderService { // 从数据库查询产品,关联查询组件 const productDetail = await this.productService.getComponentDetailFromSiteSku({ sku: orderItem.sku, name: orderItem.name },site); - if (!productDetail || !productDetail.quantity) return; + if (!productDetail || !productDetail.product || !productDetail.quantity) return; const { product, quantity } = productDetail + const componentDetails: { product: Product, quantity: number }[] = product.components?.length > 0 ? await Promise.all(product.components.map(async comp => { return { product: await this.productModel.findOne({ diff --git a/src/service/product.service.ts b/src/service/product.service.ts index cea866c..fef1c8f 100644 --- a/src/service/product.service.ts +++ b/src/service/product.service.ts @@ -1791,7 +1791,7 @@ export class ProductService { } let product = await this.getProductBySiteSku(siteProduct.sku, site) - + return { product, quantity: 1,