fix(billing): 按次计费回退到默认 PerRequestPrice

ResolvedPricing 新增 DefaultPerRequestPrice,当无层级匹配时使用渠道的默认按次价格
This commit is contained in:
erio
2026-03-30 23:04:48 +08:00
parent 632035aabd
commit 0fbc9a44d3
2 changed files with 11 additions and 0 deletions

View File

@@ -542,6 +542,11 @@ func (s *BillingService) calculatePerRequestCost(resolved *ResolvedPricing, inpu
unitPrice = input.Resolver.GetRequestTierPriceByContext(resolved, totalContext)
}
// 回退到默认按次价格
if unitPrice == 0 {
unitPrice = resolved.DefaultPerRequestPrice
}
totalCost := unitPrice * float64(count)
actualCost := totalCost * input.RateMultiplier