From eafb497f01e3c1d3cb994ed58981236fec637783 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 15 Dec 2025 13:51:34 +0800 Subject: [PATCH] bugfix --- wwwroot/adm_menu.ui | 5 +++ wwwroot/manual_recharge.dspy | 30 +++++++++++++++++ wwwroot/manual_recharge.ui | 63 ++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 wwwroot/manual_recharge.dspy create mode 100644 wwwroot/manual_recharge.ui diff --git a/wwwroot/adm_menu.ui b/wwwroot/adm_menu.ui index ec00f95..6ccae49 100644 --- a/wwwroot/adm_menu.ui +++ b/wwwroot/adm_menu.ui @@ -8,6 +8,11 @@ "name":"payfee", "label":"充值费率", "url":"{{entire_url('payfee')}}" + }, + { + "name":"manual_recharge", + "label":"替客户充值", + "url":"{{entire_url('manual_recharge.ui')}}" } ] } diff --git a/wwwroot/manual_recharge.dspy b/wwwroot/manual_recharge.dspy new file mode 100644 index 0000000..727a149 --- /dev/null +++ b/wwwroot/manual_recharge.dspy @@ -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"充值失败") diff --git a/wwwroot/manual_recharge.ui b/wwwroot/manual_recharge.ui new file mode 100644 index 0000000..98c3ecf --- /dev/null +++ b/wwwroot/manual_recharge.ui @@ -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":{} + } + } + ] +}