|
|
@@ -172,6 +172,22 @@ func GetEffectivePricing(modelName string, channelId int) (*ChannelPricing, bool |
|
|
return cp, true |
|
|
return cp, true |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ParseTagIds 解析逗号分隔的标签ID字符串为 PricingTag 切片 |
|
|
|
|
|
func ParseTagIds(tagIds string, tagMap map[int]*PricingTag) []*PricingTag { |
|
|
|
|
|
if tagIds == "" { |
|
|
|
|
|
return nil |
|
|
|
|
|
} |
|
|
|
|
|
tags := make([]*PricingTag, 0) |
|
|
|
|
|
for _, idStr := range strings.Split(tagIds, ",") { |
|
|
|
|
|
if id, err := strconv.Atoi(strings.TrimSpace(idStr)); err == nil { |
|
|
|
|
|
if tag, ok := tagMap[id]; ok { |
|
|
|
|
|
tags = append(tags, tag) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return tags |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// LoadChannelPricingCache 全量加载渠道定价到内存(启动时调用) |
|
|
// LoadChannelPricingCache 全量加载渠道定价到内存(启动时调用) |
|
|
func LoadChannelPricingCache() { |
|
|
func LoadChannelPricingCache() { |
|
|
var pricings []*ChannelPricing |
|
|
var pricings []*ChannelPricing |
|
|
@@ -234,8 +250,6 @@ func GetChannelPricingByModelWithChannelInfo(modelName string) ([]*ChannelPricin |
|
|
if !hasPrice { |
|
|
if !hasPrice { |
|
|
globalModelPrice = 0 |
|
|
globalModelPrice = 0 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取全局扩展比率(用于 CASE WHEN 回退) |
|
|
// 获取全局扩展比率(用于 CASE WHEN 回退) |
|
|
globalCacheRatio, _ := ratio_setting.GetCacheRatio(modelName) |
|
|
globalCacheRatio, _ := ratio_setting.GetCacheRatio(modelName) |
|
|
globalCacheCreationRatio, _ := ratio_setting.GetCreateCacheRatio(modelName) |
|
|
globalCacheCreationRatio, _ := ratio_setting.GetCreateCacheRatio(modelName) |
|
|
@@ -283,16 +297,7 @@ func GetChannelPricingByModelWithChannelInfo(modelName string) ([]*ChannelPricin |
|
|
|
|
|
|
|
|
// 为每个渠道定价填充标签 |
|
|
// 为每个渠道定价填充标签 |
|
|
for _, result := range results { |
|
|
for _, result := range results { |
|
|
if result.TagIds != "" { |
|
|
|
|
|
result.Tags = make([]*PricingTag, 0) |
|
|
|
|
|
for _, idStr := range strings.Split(result.TagIds, ",") { |
|
|
|
|
|
if id, err := strconv.Atoi(strings.TrimSpace(idStr)); err == nil { |
|
|
|
|
|
if tag, ok := tagMap[id]; ok { |
|
|
|
|
|
result.Tags = append(result.Tags, tag) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
result.Tags = ParseTagIds(result.TagIds, tagMap) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return results, nil |
|
|
return results, nil |
|
|
|