fix(billing): correct tiered billing settlement and edge cases

- quota.go: add missing SettleBilling call in PostWssConsumeQuota
- text_quota.go: gate InjectTieredBillingInfo on tieredBillingApplied bool
  instead of tieredResult != nil, so fallback billing still logs metadata
- price.go: remove quotaBeforeGroup == 0 from freeModel condition to avoid
  bypassing settlement for output-only expressions
- tiered_settle.go: split cc/cc1h subtraction using UsageSemantic to
  distinguish OpenAI vs Claude cache creation token formats
- pricing.go: only set BillingMode when a non-empty expression exists
- useModelPricingEditorState.js: only write billing_mode when
  finalBillingExpr is non-empty
This commit is contained in:
CaIon
2026-04-24 00:33:54 +08:00
parent 8eeae00737
commit 3e5f2ee1d6
6 changed files with 25 additions and 10 deletions
@@ -1041,12 +1041,12 @@ export function useModelPricingEditorState({
for (const model of models) {
if (model.billingMode === 'tiered_expr') {
tieredOutput['billing_setting.billing_mode'][model.name] = 'tiered_expr';
const finalBillingExpr = combineBillingExpr(
model.billingExpr,
model.requestRuleExpr,
);
if (finalBillingExpr) {
tieredOutput['billing_setting.billing_mode'][model.name] = 'tiered_expr';
tieredOutput['billing_setting.billing_expr'][model.name] = finalBillingExpr;
}
}