refactor(订单服务): 移除getComponentDetailFromSiteSku中不必要的quantity参数
简化组件详情查询逻辑,默认数量设为1,不再需要外部传入quantity参数
This commit is contained in:
parent
d8a3422015
commit
534cc3f2c7
|
|
@ -733,7 +733,7 @@ export class OrderService {
|
|||
if (!orderItem.sku) return;
|
||||
|
||||
// 从数据库查询产品,关联查询组件
|
||||
const componentDetails = await this.productService.getComponentDetailFromSiteSku({ sku: orderItem.sku, name: orderItem.name },orderItem.quantity,site);
|
||||
const componentDetails = await this.productService.getComponentDetailFromSiteSku({ sku: orderItem.sku, name: orderItem.name }, site);
|
||||
if(!componentDetails?.length){
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1786,7 +1786,7 @@ export class ProductService {
|
|||
}
|
||||
}
|
||||
// 获取库存单品列表
|
||||
async getComponentDetailFromSiteSku(siteProduct: { sku: string, name: string }, quantity: number = 1, site: Site): Promise<{ product: Product,parentProduct?: Product, quantity: number }[]> {
|
||||
async getComponentDetailFromSiteSku(siteProduct: { sku: string, name: string }, site: Site): Promise<{ product: Product,parentProduct?: Product, quantity: number }[]> {
|
||||
if (!siteProduct.sku) {
|
||||
throw new Error('siteSku 不能为空')
|
||||
}
|
||||
|
|
@ -1798,7 +1798,7 @@ export class ProductService {
|
|||
if(!product?.components?.length){
|
||||
return [{
|
||||
product,
|
||||
quantity
|
||||
quantity:1
|
||||
}]
|
||||
}
|
||||
|
||||
|
|
@ -1808,7 +1808,7 @@ export class ProductService {
|
|||
where: { id: comp.productId },
|
||||
}),
|
||||
parentProduct: product, // 这里得记录一下他的爸爸用来记录
|
||||
quantity: comp.quantity * quantity,
|
||||
quantity: comp.quantity,
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue