diff --git a/account_resource/__pycache__/init.cpython-310.pyc b/account_resource/__pycache__/init.cpython-310.pyc new file mode 100644 index 0000000..71cc293 Binary files /dev/null and b/account_resource/__pycache__/init.cpython-310.pyc differ diff --git a/account_resource/init.py b/account_resource/init.py index 17fd295..6d43bb9 100644 --- a/account_resource/init.py +++ b/account_resource/init.py @@ -218,16 +218,16 @@ async def account_charging(spec_id_or_code, charge_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: