From 56ae61a99296565aa5e4d978283c642722821104 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Mon, 22 Jun 2026 17:26:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=88=E4=BF=A1=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=AE=A2=E6=88=B7=E5=90=8D=E7=A7=B0=E6=9F=A5?= =?UTF-8?q?=E6=89=BE=E6=A8=A1=E5=BC=8F=20+=20=E4=BB=A3=E5=AE=A2=E5=85=85?= =?UTF-8?q?=E5=80=BCRBAC=E8=B7=AF=E5=BE=84=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 授信表单: accountid改为customer_name文本输入,后端先精确后模糊查找客户 2. 代客充值: load_path.py添加proxy_recharge.ui和proxy_recharge_submit.dspy路径 --- scripts/load_path.py | 4 ++ wwwroot/credit_limit/api/set_credit_form.ui | 7 ++- .../credit_limit/api/set_customer_credit.dspy | 58 +++++++++++++++++-- wwwroot/credit_limit/credit_manage.ui | 2 +- 4 files changed, 62 insertions(+), 9 deletions(-) diff --git a/scripts/load_path.py b/scripts/load_path.py index c25ad8d..b7452ba 100644 --- a/scripts/load_path.py +++ b/scripts/load_path.py @@ -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", ] # ============================================================ diff --git a/wwwroot/credit_limit/api/set_credit_form.ui b/wwwroot/credit_limit/api/set_credit_form.ui index 4d2d739..b988917 100644 --- a/wwwroot/credit_limit/api/set_credit_form.ui +++ b/wwwroot/credit_limit/api/set_credit_form.ui @@ -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", diff --git a/wwwroot/credit_limit/api/set_customer_credit.dspy b/wwwroot/credit_limit/api/set_customer_credit.dspy index 7c295ad..68ab8d8 100644 --- a/wwwroot/credit_limit/api/set_customer_credit.dspy +++ b/wwwroot/credit_limit/api/set_customer_credit.dspy @@ -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", diff --git a/wwwroot/credit_limit/credit_manage.ui b/wwwroot/credit_limit/credit_manage.ui index aaaabde..b49dbf0 100644 --- a/wwwroot/credit_limit/credit_manage.ui +++ b/wwwroot/credit_limit/credit_manage.ui @@ -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 ''}}",