fix(billing): 修正模型计费配置继承优先级

This commit is contained in:
2026-07-22 00:24:36 +08:00
parent 56d4a3a6b7
commit 6b675c406e
8 changed files with 263 additions and 68 deletions
+28
View File
@@ -0,0 +1,28 @@
package store
// EffectiveBillingConfigInput describes the billing layers used by runtime and
// catalog responses. LegacyPlatformModelConfig is retained only as a fallback
// for models that do not have an effective pricing rule set.
type EffectiveBillingConfigInput struct {
BaseConfig map[string]any
LegacyPlatformModelConfig map[string]any
InheritedRuleSetConfig map[string]any
ModelRuleSetConfig map[string]any
Override map[string]any
}
// ResolveEffectiveBillingConfig keeps inherited pricing rules authoritative over
// the legacy materialized snapshot. Explicit model rules and overrides retain
// their higher-priority exception semantics.
func ResolveEffectiveBillingConfig(input EffectiveBillingConfigInput) map[string]any {
config := mergeObjects(input.BaseConfig, nil)
if len(input.InheritedRuleSetConfig) > 0 {
config = mergeObjects(input.InheritedRuleSetConfig, nil)
} else if len(input.LegacyPlatformModelConfig) > 0 {
config = mergeObjects(input.LegacyPlatformModelConfig, nil)
}
if len(input.ModelRuleSetConfig) > 0 {
config = mergeObjects(input.ModelRuleSetConfig, nil)
}
return mergeObjects(config, input.Override)
}