fix: 修复订单服务中产品详情检查逻辑

添加对productDetail.product的检查,避免在product为undefined时访问components属性
This commit is contained in:
tikkhun 2026-01-27 18:42:00 +08:00 committed by zhuotianyuan
parent 0dac006116
commit 12ebad6570
2 changed files with 3 additions and 2 deletions

View File

@ -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({

View File

@ -1798,7 +1798,7 @@ export class ProductService {
}
let product = await this.getProductBySiteSku(siteProduct.sku, site)
return {
product,
quantity: 1,