fix: 授信表单改为客户名称查找模式 + 代客充值RBAC路径注册

1. 授信表单: accountid改为customer_name文本输入,后端先精确后模糊查找客户
2. 代客充值: load_path.py添加proxy_recharge.ui和proxy_recharge_submit.dspy路径
This commit is contained in:
Hermes Agent 2026-06-22 17:26:03 +08:00
parent f00057bb75
commit 56ae61a992
4 changed files with 62 additions and 9 deletions

View File

@ -134,6 +134,10 @@ PATHS_LOGINED = [
f"/{MOD}/credit_limit/api/credit_summary.dspy",
f"/{MOD}/credit_limit/api/set_credit_form.ui",
f"/{MOD}/credit_limit/api/set_customer_credit.dspy",
# proxy_recharge/
f"/{MOD}/proxy_recharge.ui",
f"/{MOD}/proxy_recharge_submit.dspy",
]
# ============================================================

View File

@ -13,11 +13,12 @@
"value": "{{params_kw.get('id', '')}}"
},
{
"name": "accountid",
"label": "账户ID",
"name": "customer_name",
"label": "客户名称",
"uitype": "str",
"required": true,
"value": "{{params_kw.get('accountid', '')}}"
"value": "{{params_kw.get('customer_name', '')}}",
"placeholder": "输入客户名称进行查找"
},
{
"name": "credit_limit",

View File

@ -4,8 +4,8 @@ for k, v in ns.items():
if v == 'NaN' or v == 'null' or v == '':
ns[k] = None
accountid = ns.get('accountid')
if not accountid:
customer_name = ns.get('customer_name', '').strip() if ns.get('customer_name') else ''
if not customer_name:
return {
"widgettype": "Error",
"options": {
@ -13,7 +13,7 @@ if not accountid:
"cwidth": 16,
"cheight": 9,
"timeout": 3,
"message": "账户ID不能为空"
"message": "客户名称不能为空"
}
}
@ -41,6 +41,54 @@ orgid = await get_userorgid()
db = DBPools()
dbname = get_module_dbname('accounting')
async with db.sqlorContext(dbname) as sor:
# Look up customer by name
lookup_sql = """
select o.id as orgid, o.orgname, a.id as accountid
from organization o
left join account a on a.orgid = o.id COLLATE utf8mb4_unicode_ci
where o.orgname = ${customer_name}$
limit 1
"""
recs = await sor.sqlExe(lookup_sql, {'customer_name': customer_name})
if not recs or len(recs) == 0:
# Try fuzzy match
fuzzy_sql = """
select o.id as orgid, o.orgname, a.id as accountid
from organization o
left join account a on a.orgid = o.id COLLATE utf8mb4_unicode_ci
where o.orgname LIKE ${customer_name}$
limit 1
"""
recs = await sor.sqlExe(fuzzy_sql, {'customer_name': f'%{customer_name}%'})
if not recs or len(recs) == 0:
return {
"widgettype": "Error",
"options": {
"title": "查找失败",
"cwidth": 16,
"cheight": 9,
"timeout": 3,
"message": f"未找到客户: {customer_name}"
}
}
customer = recs[0]
customer_orgid = customer.orgid
accountid = customer.accountid
if not accountid:
return {
"widgettype": "Error",
"options": {
"title": "查找失败",
"cwidth": 16,
"cheight": 9,
"timeout": 3,
"message": f"客户 {customer.orgname} 尚未开设账户"
}
}
if record_id:
sql = """
UPDATE credit_limit
@ -67,7 +115,7 @@ async with db.sqlorContext(dbname) as sor:
data = {
'id': new_id,
'accountid': accountid,
'orgid': orgid,
'orgid': customer_orgid,
'credit_limit': credit_limit_amount,
'used_credit': 0,
'available_credit': credit_limit_amount,
@ -80,7 +128,7 @@ async with db.sqlorContext(dbname) as sor:
'remark': remark
}
await sor.C('credit_limit', data)
debug(f'Created credit limit for {accountid}: {credit_limit_amount}')
debug(f'Created credit limit for {customer.orgname}(orgid={customer_orgid}, accountid={accountid}): {credit_limit_amount}')
return {
"widgettype": "Message",

View File

@ -255,7 +255,7 @@
"url": "{{entire_url('/accounting/credit_limit/api/set_credit_form.ui')}}",
"params_kw": {
"id": "{{c.id}}",
"accountid": "{{c.accountid}}",
"customer_name": "{{c.orgname_text or ''}}",
"credit_limit": "{{c.credit_limit}}",
"valid_from": "{{c.valid_from or ''}}",
"valid_to": "{{c.valid_to or ''}}",