feat: 套装方案对比与导出功能 #32

Merged
hera merged 37 commits from feat/kit-comparison-export into main 2026-04-14 13:32:34 +00:00
Showing only changes of commit 385022002b - Show all commits

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
}