fix(pricing): storage_charging 用错定价函数——pricing_program_charging(三参) 改 buffered_charging(两参)
buffered_charging 返回价格对象列表,需 sum(getattr(p,'amount',0)) 汇总。 原用 pricing_program_charging=charging(sor,ppid,data) 三参,传两参导致 'missing 1 required positional argument: data',存储计费金额恒为 0。
This commit is contained in:
parent
7f586a9b12
commit
3e6f448a39
BIN
storage_resource/__pycache__/init.cpython-310.pyc
Normal file
BIN
storage_resource/__pycache__/init.cpython-310.pyc
Normal file
Binary file not shown.
@ -262,16 +262,16 @@ async def storage_charging(spec_id_or_code, meter_mode, userid, userorgid,
|
||||
|
||||
amount = 0.0
|
||||
if ppid:
|
||||
charging = getattr(env, 'pricing_program_charging', None)
|
||||
charging = getattr(env, 'buffered_charging', None)
|
||||
if charging is None:
|
||||
logger.warning('pricing 模块未加载,存储计费金额记 0(ppid=%s)', ppid)
|
||||
else:
|
||||
try:
|
||||
r = await charging(ppid, usages)
|
||||
if isinstance(r, dict):
|
||||
amount = float(r.get('amount', 0) or 0)
|
||||
elif isinstance(r, (int, float)):
|
||||
amount = float(r)
|
||||
prices = await charging(ppid, usages)
|
||||
if prices is None:
|
||||
logger.error('存储定价计算返回空 ppid=%s', ppid)
|
||||
else:
|
||||
amount = float(sum(getattr(p, 'amount', 0) or 0 for p in prices))
|
||||
except Exception as e:
|
||||
logger.error('存储计费失败 ppid=%s: %s', ppid, e)
|
||||
else:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user