fix: 授信表单改为客户名称查找模式 + 代客充值RBAC路径注册
1. 授信表单: accountid改为customer_name文本输入,后端先精确后模糊查找客户 2. 代客充值: load_path.py添加proxy_recharge.ui和proxy_recharge_submit.dspy路径
This commit is contained in:
parent
f00057bb75
commit
56ae61a992
@ -134,6 +134,10 @@ PATHS_LOGINED = [
|
|||||||
f"/{MOD}/credit_limit/api/credit_summary.dspy",
|
f"/{MOD}/credit_limit/api/credit_summary.dspy",
|
||||||
f"/{MOD}/credit_limit/api/set_credit_form.ui",
|
f"/{MOD}/credit_limit/api/set_credit_form.ui",
|
||||||
f"/{MOD}/credit_limit/api/set_customer_credit.dspy",
|
f"/{MOD}/credit_limit/api/set_customer_credit.dspy",
|
||||||
|
|
||||||
|
# proxy_recharge/
|
||||||
|
f"/{MOD}/proxy_recharge.ui",
|
||||||
|
f"/{MOD}/proxy_recharge_submit.dspy",
|
||||||
]
|
]
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|||||||
@ -13,11 +13,12 @@
|
|||||||
"value": "{{params_kw.get('id', '')}}"
|
"value": "{{params_kw.get('id', '')}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "accountid",
|
"name": "customer_name",
|
||||||
"label": "账户ID",
|
"label": "客户名称",
|
||||||
"uitype": "str",
|
"uitype": "str",
|
||||||
"required": true,
|
"required": true,
|
||||||
"value": "{{params_kw.get('accountid', '')}}"
|
"value": "{{params_kw.get('customer_name', '')}}",
|
||||||
|
"placeholder": "输入客户名称进行查找"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "credit_limit",
|
"name": "credit_limit",
|
||||||
|
|||||||
@ -4,8 +4,8 @@ for k, v in ns.items():
|
|||||||
if v == 'NaN' or v == 'null' or v == '':
|
if v == 'NaN' or v == 'null' or v == '':
|
||||||
ns[k] = None
|
ns[k] = None
|
||||||
|
|
||||||
accountid = ns.get('accountid')
|
customer_name = ns.get('customer_name', '').strip() if ns.get('customer_name') else ''
|
||||||
if not accountid:
|
if not customer_name:
|
||||||
return {
|
return {
|
||||||
"widgettype": "Error",
|
"widgettype": "Error",
|
||||||
"options": {
|
"options": {
|
||||||
@ -13,7 +13,7 @@ if not accountid:
|
|||||||
"cwidth": 16,
|
"cwidth": 16,
|
||||||
"cheight": 9,
|
"cheight": 9,
|
||||||
"timeout": 3,
|
"timeout": 3,
|
||||||
"message": "账户ID不能为空"
|
"message": "客户名称不能为空"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +41,54 @@ orgid = await get_userorgid()
|
|||||||
db = DBPools()
|
db = DBPools()
|
||||||
dbname = get_module_dbname('accounting')
|
dbname = get_module_dbname('accounting')
|
||||||
async with db.sqlorContext(dbname) as sor:
|
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:
|
if record_id:
|
||||||
sql = """
|
sql = """
|
||||||
UPDATE credit_limit
|
UPDATE credit_limit
|
||||||
@ -67,7 +115,7 @@ async with db.sqlorContext(dbname) as sor:
|
|||||||
data = {
|
data = {
|
||||||
'id': new_id,
|
'id': new_id,
|
||||||
'accountid': accountid,
|
'accountid': accountid,
|
||||||
'orgid': orgid,
|
'orgid': customer_orgid,
|
||||||
'credit_limit': credit_limit_amount,
|
'credit_limit': credit_limit_amount,
|
||||||
'used_credit': 0,
|
'used_credit': 0,
|
||||||
'available_credit': credit_limit_amount,
|
'available_credit': credit_limit_amount,
|
||||||
@ -80,7 +128,7 @@ async with db.sqlorContext(dbname) as sor:
|
|||||||
'remark': remark
|
'remark': remark
|
||||||
}
|
}
|
||||||
await sor.C('credit_limit', data)
|
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 {
|
return {
|
||||||
"widgettype": "Message",
|
"widgettype": "Message",
|
||||||
|
|||||||
@ -255,7 +255,7 @@
|
|||||||
"url": "{{entire_url('/accounting/credit_limit/api/set_credit_form.ui')}}",
|
"url": "{{entire_url('/accounting/credit_limit/api/set_credit_form.ui')}}",
|
||||||
"params_kw": {
|
"params_kw": {
|
||||||
"id": "{{c.id}}",
|
"id": "{{c.id}}",
|
||||||
"accountid": "{{c.accountid}}",
|
"customer_name": "{{c.orgname_text or ''}}",
|
||||||
"credit_limit": "{{c.credit_limit}}",
|
"credit_limit": "{{c.credit_limit}}",
|
||||||
"valid_from": "{{c.valid_from or ''}}",
|
"valid_from": "{{c.valid_from or ''}}",
|
||||||
"valid_to": "{{c.valid_to or ''}}",
|
"valid_to": "{{c.valid_to or ''}}",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user