zksu
/
API
forked from yoone/API
1
0
Fork 0

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

添加对productDetail.product的检查,避免在product为undefined时访问components属性
This commit is contained in:
tikkhun 2026-01-27 18:42:00 +08:00
parent 96a3e5c76d
commit d3d493f858
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({