fix: tiered只展示价格不同的条目,过滤冗余

- 当tiered价格等于主unit_price时不展示
- 去掉重复的model=qwen3.7-max:6.0等冗余行
This commit is contained in:
yumoqing 2026-06-05 18:47:50 +08:00
parent 38ff69ca55
commit 66b4744def

View File

@ -856,18 +856,19 @@ async def get_pricing_display(ppid):
'unit_label': unit_label 'unit_label': unit_label
}] }]
# 处理 filters 区间定价 - 只保留有意义的 filter如 model # 处理 filters 区间定价 - 只保留有意义的 filter如 model且价格与主价格不同
if 'filters' in p: if 'filters' in p:
tiered_pricing = [] tiered_pricing = []
for fi in p['filters']: for fi in p['filters']:
fi_copy = fi.copy() fi_copy = fi.copy()
raw_tier_price = fi.get('unit_prices', unit_price) raw_tier_price = fi.get('unit_prices', unit_price)
fi_copy.pop('unit_prices', None) fi_copy.pop('unit_prices', None)
fi_copy.pop('value_mode', None) # 内部参数不展示 fi_copy.pop('value_mode', None)
# 只保留有意义的 filter key # 只保留有意义的 filter key
meaningful_filters = {k: v for k, v in fi_copy.items() meaningful_filters = {k: v for k, v in fi_copy.items()
if not k.endswith('_tokens') and k != 'value_mode'} if not k.endswith('_tokens') and k != 'value_mode'}
if meaningful_filters: # 有 model 等有意义 filter 才加 tiered # 只展示价格与主价格不同的 tiered
if meaningful_filters and raw_tier_price != unit_price:
tiered_pricing.append({ tiered_pricing.append({
'filters': meaningful_filters, 'filters': meaningful_filters,
'unit_prices': raw_tier_price 'unit_prices': raw_tier_price