diff --git a/src/service/order.service.ts b/src/service/order.service.ts index 2b9e527..8625380 100644 --- a/src/service/order.service.ts +++ b/src/service/order.service.ts @@ -731,13 +731,12 @@ export class OrderService { await this.orderSaleModel.delete(currentOrderSale.map(v => v.id)); } if (!orderItem.sku) return; - // 从数据库查询产品,关联查询组件 - const product = await this.productModel.findOne({ - where: { siteSkus: Like(`%${orderItem.sku}%`) }, - relations: ['components','attributes','attributes.dict'], - }); - if (!product) return; + // 从数据库查询产品,关联查询组件 + const productDetail = await this.productService.getComponentDetailFromSiteSku({ sku: orderItem.sku, name: orderItem.name }); + + if (!productDetail || !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({