refactor(service): 重构订单服务中的品牌属性检查逻辑

将硬编码的品牌检查逻辑改为直接存储品牌和其他属性值,提高代码的可维护性和扩展性
This commit is contained in:
tikkhun 2026-01-17 09:39:04 +08:00
parent 72cd20fcd6
commit b7101ac866
1 changed files with 6 additions and 4 deletions

View File

@ -745,11 +745,13 @@ export class OrderService {
quantity: componentDetail.quantity * orderItem.quantity, quantity: componentDetail.quantity * orderItem.quantity,
sku: componentDetail.product.sku, sku: componentDetail.product.sku,
// 理论上直接存 product 的全部数据才是对的,因为这样我的数据才全面。 // 理论上直接存 product 的全部数据才是对的,因为这样我的数据才全面。
isYoone: attrsObj?.['brand']?.name === 'yoone', brand: attrsObj?.['brand']?.name,
isZyn: attrsObj?.['brand']?.name === 'zyn', version: attrsObj?.['version']?.name,
isZex: attrsObj?.['brand']?.name === 'zex',
isYooneNew: attrsObj?.['brand']?.name === 'yoone' && attrsObj?.['version']?.name === 'new',
strength: attrsObj?.['strength']?.name, strength: attrsObj?.['strength']?.name,
flavor: attrsObj?.['flavor']?.name,
humidity: attrsObj?.['humidity']?.name,
size: attrsObj?.['size']?.name,
category: componentDetail.product.category.name,
}); });
return orderSale return orderSale
}).filter(v => v !== null) }).filter(v => v !== null)