refactor(订单服务): 移除getComponentDetailFromSiteSku中不必要的quantity参数

简化组件详情查询逻辑,默认数量设为1,不再需要外部传入quantity参数
This commit is contained in:
tikkhun 2026-01-28 21:27:37 +08:00
parent 4481cce886
commit f37de5ac32
2 changed files with 4 additions and 4 deletions

View File

@ -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
}

View File

@ -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,
}
}))
}