feat: 全精油椰子油按实际295mL(2.57瓶)计算成本和可用量
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Failing after 3m40s
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Failing after 3m40s
套装配置支持 bottleCount 字段指定某种油的瓶数倍率 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -24,12 +24,14 @@ export function useKitCost() {
|
||||
// Calculate per-drop costs for a kit
|
||||
function calcKitPerDrop(kit) {
|
||||
const resolved = kit.oils.map(name => resolveOilName(name))
|
||||
// Sum of bottle prices for all oils in kit
|
||||
const bc = kit.bottleCount || {} // e.g. { '椰子油': 2.57 }
|
||||
// Sum of bottle prices for all oils in kit (accounting for multiple bottles)
|
||||
let totalBottlePrice = 0
|
||||
const oilBottlePrices = {}
|
||||
for (const name of resolved) {
|
||||
const meta = oils.oilsMeta[name]
|
||||
const bp = meta ? meta.bottlePrice : 0
|
||||
const count = bc[name] || 1
|
||||
const bp = meta ? meta.bottlePrice * count : 0
|
||||
oilBottlePrices[name] = bp
|
||||
totalBottlePrice += bp
|
||||
}
|
||||
@@ -41,10 +43,11 @@ export function useKitCost() {
|
||||
const perDrop = {}
|
||||
for (const name of resolved) {
|
||||
const meta = oils.oilsMeta[name]
|
||||
const count = bc[name] || 1
|
||||
const bp = oilBottlePrices[name]
|
||||
const kitCostForOil = (bp / totalBottlePrice) * effectivePrice
|
||||
const drops = meta ? meta.dropCount : 1
|
||||
perDrop[name] = drops > 0 ? kitCostForOil / drops : 0
|
||||
const totalDrops = meta ? meta.dropCount * count : 1
|
||||
perDrop[name] = totalDrops > 0 ? kitCostForOil / totalDrops : 0
|
||||
}
|
||||
return perDrop
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// doTERRA 套装配置
|
||||
// 价格和内容更新频率低,手动维护即可
|
||||
// bottleCount: 某种油在套装中的瓶数(用于成本分摊和可做次数计算,默认1)
|
||||
export const KITS = [
|
||||
{
|
||||
id: 'aroma',
|
||||
@@ -52,5 +53,7 @@ export const KITS = [
|
||||
'柑橘清新', '顺畅呼吸', '净化清新', '赋活呼吸', '天然防护',
|
||||
'椰子油',
|
||||
],
|
||||
// 115mL×1 + 30mL×6 = 295mL, 标准瓶115mL, 约2.57瓶
|
||||
bottleCount: { '椰子油': 2.57 },
|
||||
},
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user