fix: model filter提升为item级适用条件
- model filter从tiered移到item.filters(适用条件) - tiered只保留区间阶梯定价(如token范围) - 区分适用条件vs阶梯定价的业务语义
This commit is contained in:
parent
3ad50beda8
commit
502468e0cb
@ -856,7 +856,8 @@ async def get_pricing_display(ppid):
|
||||
'unit_label': unit_label
|
||||
}]
|
||||
|
||||
# 处理 filters 区间定价 - 只保留有意义的 filter(如 model)且价格与主价格不同
|
||||
# 处理 filters: 提取适用条件(model)到item级,区间条件放tiered
|
||||
model_filters = {}
|
||||
if 'filters' in p:
|
||||
tiered_pricing = []
|
||||
for fi in p['filters']:
|
||||
@ -864,22 +865,29 @@ async def get_pricing_display(ppid):
|
||||
raw_tier_price = fi.get('unit_prices', unit_price)
|
||||
fi_copy.pop('unit_prices', None)
|
||||
fi_copy.pop('value_mode', None)
|
||||
# 只保留有意义的 filter key
|
||||
|
||||
# 区分:model filter 是适用条件,其他是阶梯定价
|
||||
is_model_filter = 'model' in fi_copy and not any(k.endswith('_tokens') for k in fi_copy.keys())
|
||||
if is_model_filter:
|
||||
# 提取为 item 级 filters
|
||||
model_filters['model'] = fi_copy['model']
|
||||
else:
|
||||
# 区间条件放 tiered
|
||||
meaningful_filters = {k: v for k, v in fi_copy.items()
|
||||
if not k.endswith('_tokens') and k != 'value_mode'}
|
||||
# 只展示价格与主价格不同的 tiered
|
||||
if meaningful_filters and raw_tier_price != unit_price:
|
||||
tiered_pricing.append({
|
||||
'filters': meaningful_filters,
|
||||
'unit_prices': raw_tier_price
|
||||
})
|
||||
|
||||
item = {'price_factors': price_factors_display}
|
||||
if model_filters:
|
||||
item['filters'] = model_filters
|
||||
item['filter_labels'] = {'模型': model_filters['model']}
|
||||
min_amount = p.get('min_amount', 0)
|
||||
if min_amount:
|
||||
item['min_amount'] = min_amount
|
||||
if filters:
|
||||
item['filters'] = filters
|
||||
item['filter_labels'] = filter_labels
|
||||
if tiered_pricing:
|
||||
item['price_factors'][0]['tiered'] = tiered_pricing
|
||||
items.append(item)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user