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

27 lines
1.4 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 ub_addledgers(ns):
""" 录入客户余额
action: RECHARGE = 充值RECHARGE_REVERSE = 充值冲账
"""
db = DBPools()
async with db.sqlorContext('kboss') as sor:
ns['id'] = (await sor.R('organization', {'orgname': ns['orgname']}))[0]['id']
ns['userid'] = (await sor.R('users', {'username': 'kyy_财务', 'del_flg': '0'}))[0]['id']
# apv = await sor.R('apv_data',{'apv_id':ns.get('apv_id')})
balance = float(ns['balance'])
date = await get_business_date(sor=None)
recharge_log = {'customerid': ns['id'], 'recharge_amt': balance,
'action': 'RECHARGE', 'recharge_path': '2', 'recharge_date': date}
try:
ra = RechargeAccounting(recharge_log)
await ra.accounting(sor)
await sor.C('recharge_log', {'id': uuid(), 'customerid': ns['id'],
'recharge_date': ns['date'],
'recharge_path': '2', 'recharge_amt': balance,
'recharge_timestamp': ns['date'], 'action': 'RECHARGE', 'op_userid': ns['userid'],
})
return {'status': True, 'msg': '充值成功'}
except Exception as e:
return {'status': False, 'msg': str(e)}
ret = await ub_addledgers(params_kw)
return ret