fix(wallet): 充值登记显示层——msg带回余额/累计充值前后值(登记即见随之改变)+弹窗改VScrollPanel填充防按钮溢出不可点+弹窗放大
This commit is contained in:
parent
123e4aaa74
commit
0335083b71
@ -61,8 +61,8 @@
|
|||||||
"target": "PopupWindow",
|
"target": "PopupWindow",
|
||||||
"popup_options": {
|
"popup_options": {
|
||||||
"title": "充值登记",
|
"title": "充值登记",
|
||||||
"width": "46%",
|
"width": "52%",
|
||||||
"height": "52%",
|
"height": "62%",
|
||||||
"resizable": true
|
"resizable": true
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
|
|||||||
@ -734,7 +734,12 @@ async def govern_settle(ctx: dict, ok_call: bool, note: str = '', usages: dict =
|
|||||||
# ────────────────────────── 充值 ──────────────────────────
|
# ────────────────────────── 充值 ──────────────────────────
|
||||||
|
|
||||||
async def recharge_account(account_id: str, amount, note: str = '', operator: str = ''):
|
async def recharge_account(account_id: str, amount, note: str = '', operator: str = ''):
|
||||||
"""供应商账号充值(成本侧钱包)。返回 (ok, msg)。"""
|
"""供应商账号充值登记(成本侧钱包)。返回 (ok, msg)。
|
||||||
|
|
||||||
|
真实充值动作在供应商侧完成,本平台只做登记:balance += 金额、
|
||||||
|
total_recharge += 金额、写 recharge 流水。msg 带回变动前后值
|
||||||
|
(余额/累计充值 旧→新),前端无需再查即可展示「随之改变」。
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
amount = float(amount)
|
amount = float(amount)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
@ -743,17 +748,22 @@ async def recharge_account(account_id: str, amount, note: str = '', operator: st
|
|||||||
return False, '充值金额必须大于 0'
|
return False, '充值金额必须大于 0'
|
||||||
db, dbname = _get_db()
|
db, dbname = _get_db()
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
recs = await sor.sqlExe("SELECT id FROM llm_account WHERE id=${i}$", {"i": account_id})
|
recs = await sor.sqlExe(
|
||||||
|
"SELECT id, balance, total_recharge FROM llm_account WHERE id=${i}$",
|
||||||
|
{"i": account_id})
|
||||||
await sor.sqlExe("COMMIT", {})
|
await sor.sqlExe("COMMIT", {})
|
||||||
if not recs:
|
if not recs:
|
||||||
return False, '账号不存在'
|
return False, '账号不存在'
|
||||||
|
old_bal = float(recs[0]['balance'] or 0)
|
||||||
|
old_tot = float(recs[0]['total_recharge'] or 0)
|
||||||
await sor.sqlExe(
|
await sor.sqlExe(
|
||||||
"UPDATE llm_account SET balance=balance+${a}$, total_recharge=total_recharge+${a}$ "
|
"UPDATE llm_account SET balance=balance+${a}$, total_recharge=total_recharge+${a}$ "
|
||||||
"WHERE id=${i}$", {"a": amount, "i": account_id})
|
"WHERE id=${i}$", {"a": amount, "i": account_id})
|
||||||
await sor.sqlExe("COMMIT", {})
|
await sor.sqlExe("COMMIT", {})
|
||||||
await _write_recharge_usage(sor, '', '', account_id, amount, note, operator)
|
await _write_recharge_usage(sor, '', '', account_id, amount, note, operator)
|
||||||
_govern_cache.clear()
|
_govern_cache.clear()
|
||||||
return True, '账号充值 %.4f 成功' % amount
|
return True, ('账号充值 %.4f 成功(余额 %.4f→%.4f,累计充值 %.4f→%.4f)'
|
||||||
|
% (amount, old_bal, old_bal + amount, old_tot, old_tot + amount))
|
||||||
|
|
||||||
|
|
||||||
async def recharge_org(org_id: str, amount, note: str = '', operator: str = ''):
|
async def recharge_org(org_id: str, amount, note: str = '', operator: str = ''):
|
||||||
|
|||||||
@ -78,9 +78,10 @@ do_js = (_read_input_js('llm_acc_amt')
|
|||||||
+ "else{new bricks.Message({title:'充值失败',message:(d&&(d.message||d.error))||('请求失败 HTTP '+r.status)}).open();}")
|
+ "else{new bricks.Message({title:'充值失败',message:(d&&(d.message||d.error))||('请求失败 HTTP '+r.status)}).open();}")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"widgettype": "VBox",
|
"widgettype": "VScrollPanel",
|
||||||
"id": "llm_acc_recharge_box",
|
"id": "llm_acc_recharge_box",
|
||||||
"options": {"width": "100%", "height": "100%", "padding": "16px", "gap": "12px"},
|
"options": {"css": "filler", "width": "100%", "height": "100%",
|
||||||
|
"padding": "14px", "gap": "12px"},
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
{"widgettype": "MdWidget", "options": {"mdtext": '\n'.join(head_md), "width": "100%"}},
|
{"widgettype": "MdWidget", "options": {"mdtext": '\n'.join(head_md), "width": "100%"}},
|
||||||
{"widgettype": "HBox",
|
{"widgettype": "HBox",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user