This commit is contained in:
yumoqing 2025-12-15 13:51:34 +08:00
parent 5d66a71e7e
commit eafb497f01
3 changed files with 98 additions and 0 deletions

View File

@ -8,6 +8,11 @@
"name":"payfee",
"label":"充值费率",
"url":"{{entire_url('payfee')}}"
},
{
"name":"manual_recharge",
"label":"替客户充值",
"url":"{{entire_url('manual_recharge.ui')}}"
}
]
}

View File

@ -0,0 +1,30 @@
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"充值失败")

View File

@ -0,0 +1,63 @@
{
"widgettype":"Form",
"options":{
"width": "100%",
"height": "100%",
"fields":[
{
"name":"customerid",
"uitype":"str",
"required":true,
"label":"充值客户id"
},
{
"name":"amount",
"label":"充值金额",
"required":true,
"uitype":"float",
"lenght":18,
"dec":2
},
{
"name":"currency",
"label":"币种",
"uitype":"code",
"defaultvalue":"CNY",
"data":[
{
"value":"CNY",
"text":"人民币"
},
{
"value":"USD",
"text": "美元"
}
]
}
]
},
"binds":[
{
"wid": "self",
"event":"submit",
"actiontype":"urlwidget",
"target":"PopupWindow",
"popup_options":{
{% if params_kw._is_mobile %}
"width": "95%",
"height": "95%",
{% else %}
"width": "50%",
"height": "50%",
{% endif %}
"archor":"cc"
},
"options":{
"url":"{{entire_url('manual_recharge.dspy')}}",
"method":"POST",
"params":{}
}
}
]
}