diff --git a/backend/internal/app/channel_model_pricing_test.go b/backend/internal/app/channel_model_pricing_test.go index 68fed0790..aa5e61ee2 100644 --- a/backend/internal/app/channel_model_pricing_test.go +++ b/backend/internal/app/channel_model_pricing_test.go @@ -219,7 +219,17 @@ func TestRepriceTierFieldValidation(t *testing.T) { } } -func TestBatchRepricingRollsBackOnConcurrentChange(t *testing.T) { +func TestNormalizeChannelModelTierSelectorAcceptsResolutionTypo(t *testing.T) { + selector, resolution, videoSeconds, err := normalizeChannelModelTierSelector("image", ChannelModelPriceTierRequest{ + Selector: map[string]string{"resoluton": "2K"}, + }) + if err != nil { + t.Fatal(err) + } + if selector["resolution"] != "2k" || selector["resoluton"] != "" || resolution != "*" || videoSeconds != 0 { + t.Fatalf("selector=%v resolution=%q videoSeconds=%d", selector, resolution, videoSeconds) + } +} for _, target := range []string{"model", "tier"} { t.Run(target, func(t *testing.T) { svc, db, _ := seedRepricingModels(t) diff --git a/backend/internal/app/channel_models_pricing.go b/backend/internal/app/channel_models_pricing.go index 07a86ce8f..773ce4d68 100644 --- a/backend/internal/app/channel_models_pricing.go +++ b/backend/internal/app/channel_models_pricing.go @@ -144,6 +144,10 @@ func normalizeChannelModelTierSelector(capability string, input ChannelModelPric } case "vquality": value = normalizeChannelModelTierResolution(value) + case "resolution", "resoluton": + // 兼容图片价格档的标准字段,以及历史接口误拼写 resoluton。 + key = "resolution" + value = strings.ToLower(strings.TrimSpace(value)) case "videoSeconds": seconds, err := strconv.Atoi(value) if err != nil || seconds < 0 { @@ -200,6 +204,9 @@ func normalizeChannelModelTierSelector(capability string, input ChannelModelPric if _, exists := selector["vquality"]; exists && capability != "video" { return nil, "", 0, BadAuthRequest("只有视频模型可以按分辨率配置价格档") } + if _, exists := selector["resolution"]; exists && capability != "image" { + return nil, "", 0, BadAuthRequest("只有图片模型可以按分辨率配置价格档") + } if _, exists := selector["videoSeconds"]; exists && capability != "video" { return nil, "", 0, BadAuthRequest("只有视频模型可以按时长配置价格档") }