fix: 修复订单服务中产品详情检查逻辑
添加对productDetail.product的检查,避免在product为undefined时访问components属性
This commit is contained in:
parent
96a3e5c76d
commit
d3d493f858
|
|
@ -735,8 +735,9 @@ export class OrderService {
|
||||||
// 从数据库查询产品,关联查询组件
|
// 从数据库查询产品,关联查询组件
|
||||||
const productDetail = await this.productService.getComponentDetailFromSiteSku({ sku: orderItem.sku, name: orderItem.name },site);
|
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 { product, quantity } = productDetail
|
||||||
|
|
||||||
const componentDetails: { product: Product, quantity: number }[] = product.components?.length > 0 ? await Promise.all(product.components.map(async comp => {
|
const componentDetails: { product: Product, quantity: number }[] = product.components?.length > 0 ? await Promise.all(product.components.map(async comp => {
|
||||||
return {
|
return {
|
||||||
product: await this.productModel.findOne({
|
product: await this.productModel.findOne({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue