fix: 供应商折扣负数校验,clamp到0~1范围(bug6)
This commit is contained in:
parent
c5eb5b9399
commit
616c3a1926
@ -483,10 +483,11 @@ class PricingProgram:
|
|||||||
async def buffered_charging(ppid, data):
|
async def buffered_charging(ppid, data):
|
||||||
r = await PricingProgram.get_ppid_pricing(ppid)
|
r = await PricingProgram.get_ppid_pricing(ppid)
|
||||||
prices = PricingProgram.get_pricing_from_ymalstr(data,
|
prices = PricingProgram.get_pricing_from_ymalstr(data,
|
||||||
r.pricing_data)
|
r.pricing_data)
|
||||||
amt = 0.0
|
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:
|
for p in prices:
|
||||||
p.cost = p.amount * r.discount
|
p.cost = p.amount * discount
|
||||||
return prices
|
return prices
|
||||||
|
|
||||||
async def charging(sor, ppid, data):
|
async def charging(sor, ppid, data):
|
||||||
@ -518,8 +519,9 @@ order by b.enabled_date desc"""
|
|||||||
r.pricing_data)
|
r.pricing_data)
|
||||||
debug(f'{r.prices=}')
|
debug(f'{r.prices=}')
|
||||||
amt = 0.0
|
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:
|
for p in r.prices:
|
||||||
p.cost = p.amount * r.discount
|
p.cost = p.amount * discount
|
||||||
return r.prices
|
return r.prices
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user