fix: 供应商折扣负数校验,clamp到0~1范围(bug6)

This commit is contained in:
Hermes Agent 2026-06-16 10:45:29 +08:00
parent c5eb5b9399
commit 616c3a1926

View File

@ -485,8 +485,9 @@ class PricingProgram:
prices = PricingProgram.get_pricing_from_ymalstr(data,
r.pricing_data)
amt = 0.0
discount = max(0.0, min(1.0, r.discount)) if r.discount is not None else 1.0
for p in prices:
p.cost = p.amount * r.discount
p.cost = p.amount * discount
return prices
async def charging(sor, ppid, data):
@ -518,8 +519,9 @@ order by b.enabled_date desc"""
r.pricing_data)
debug(f'{r.prices=}')
amt = 0.0
discount = max(0.0, min(1.0, r.discount)) if r.discount is not None else 1.0
for p in r.prices:
p.cost = p.amount * r.discount
p.cost = p.amount * discount
return r.prices
@staticmethod