fix: 套装折扣改为统一折扣率,配件和精油共享同一折扣
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Has been cancelled
Test / e2e-test (push) Has been cancelled
Test / build-check (push) Has been cancelled
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 13s

折扣率 = 套装价 / (油瓶总价 + 配件零售价)
芳香调理32.4%, 家庭医生32.8%, 居家呵护36.1%

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-14 00:11:00 +00:00
parent 796e3c7a7e
commit 385022002b

View File

@@ -37,15 +37,17 @@ export function useKitCost() {
}
if (totalBottlePrice === 0) return {}
// Proportional allocation — subtract accessory value, then cap at bottle price sum
const oilBudget = kit.price - (kit.accessoryValue || 0)
const effectivePrice = Math.min(oilBudget, totalBottlePrice)
// Uniform discount: kit price covers oils + accessories at the same discount rate
// discount_rate = kit_price / (oil_total + accessory_value)
// each oil's kit cost = bottle_price × discount_rate
const totalValue = totalBottlePrice + (kit.accessoryValue || 0)
const discountRate = Math.min(kit.price / totalValue, 1) // cap at 1 (no markup)
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 kitCostForOil = bp * discountRate
const totalDrops = meta ? meta.dropCount * count : 1
perDrop[name] = totalDrops > 0 ? kitCostForOil / totalDrops : 0
}