unipay/wwwroot/manual_recharge.dspy
2025-12-15 13:55:00 +08:00

31 lines
1.2 KiB
Plaintext
Raw 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.

roles = await get_user_roles()
for r in roles:
if not r.startswith("owner."):
return UiError(title="手工充值", message="只有平台用户才能执行")
userorgid = await get_userorgid()
if params_kw.customerid == userorgid:
return UiError(title="手工充值"message="不能给平台机构充值")
db = DBPools()
dbname = get_module_dbname('unipay')
async with db.sqlorContext(dbname) as sor:
recs = await sor.R('organization', {'id': params_kw.customerid})
if len(recs) < 0:
return UiError(title="手工充值", f"客户机构不存在{params_kw.customerid}")
pl = PaymentLog(request._run_ns)
plid = await pl.new_log(serid, params_kw.customerid, 'manual',
'手工充值', params_kw.amount, 0.0,
request['client_ip'], currency='CNY')
async with db.sqlorContext(dbname) as sor:
biz_date = await get_business_date(sor)
await recharge_accounting(sor, params_kw.customerid, 'RECHARGE',
plid,
biz_date,
params_kw.amount,
0.00)
pl.payed_log(plid)
return UiMessage(title="手工充值“message=f"充值{params_kw.amount} 成功")
exception(f'Exception:{db.e_except}')
return UiError(title="手工充值", f"充值失败")