kboss/b/account/upledger.dspy
2025-07-16 14:27:17 +08:00

30 lines
1.5 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

async def upledger(ns):
""" 客户充值冲账
action: RECHARGE = 充值RECHARGE_REVERSE = 充值冲账
"""
db = DBPools()
async with db.sqlorContext('kboss') as sor:
if not ns.get('apv_id'):
return {'status': False, 'msg': '充值失败'}
if ns.get('apv_id'):
if ns.get('status') != 'agree':
return {'status': False, 'msg': '充值失败'}
apv = await sor.R('apv_data',{'apv_id':ns.get('apv_id')})
balance = float(apv[0]['apv_text'][5:])
date = await get_business_date(sor=None)
recharge_log = {'customerid': apv[0]['result_org'], 'recharge_amt': balance,
'action': 'RECHARGE_REVERSE', 'recharge_path': '2', 'recharge_date': date}
ra = RechargeAccounting(recharge_log)
r = await ra.accounting(sor)
if r == True:
await sor.C('recharge_log', {'id': uuid(), 'customerid': apv[0]['result_org'],'recharge_date': date,
'recharge_path': '2', 'recharge_amt': balance,
'recharge_timestamp': datetime.datetime.now(), 'action': 'RECHARGE_REVERSE',
'original_id': apv[0]['original_id'],
'op_userid': apv[0]['apv_sender']})
return {'status': True, 'msg': '充值冲账成功'}
else:
return {'status': True, 'msg': '充值冲账失败'}
ret = await upledger(params_kw)
return ret