This commit is contained in:
yumoqing 2025-12-23 17:16:53 +08:00
parent d386373abb
commit d407b312cf

View File

@ -1,3 +1,4 @@
import json
from ahserver.serverenv import ServerEnv from ahserver.serverenv import ServerEnv
from sqlor.dbpools import DBPools from sqlor.dbpools import DBPools
from appPublic.log import debug, exception from appPublic.log import debug, exception
@ -104,13 +105,13 @@ async def pricing_program_charging(sor, pricing_program_id, data):
for item in pp_items: for item in pp_items:
charge = item.copy() charge = item.copy()
spec = await get_specs(sor, charge.psid) spec = await get_specs(sor, charge.psid)
if spec.pricing_spec_mode == 'spec_name': if spec.pricing_spec_mode == 'spec_amount':
d = data.get(spec.spec_name) if item.spec_value:
if d == item.spec_value: d = json.loads(item.spec_value)
change[spec.count_name] = cnt for k,v in d.items():
charge.amount = item.pricing_amount * cnt if v != item['k']:
charges.append(charge) continue
elif spec.pricing_spec_mode == 'spec_amount':
cnt = data.get(spec.count_name, 1) cnt = data.get(spec.count_name, 1)
if charge.pricing_unit is None or charge.pricing_unit < 1: if charge.pricing_unit is None or charge.pricing_unit < 1:
charge.pricing_unit = 1 charge.pricing_unit = 1