feat: 代客充值接入审计日志(customer_recharge)
This commit is contained in:
parent
11475d31c3
commit
863df88fbe
@ -1,3 +1,19 @@
|
||||
async def _audit_recharge(sor, operator_id, operator_name, customerid, customer_name, orgname, amount, client_ip):
|
||||
"""代客充值审计:检查审计模块,有则写入,失败不阻断主流程。"""
|
||||
try:
|
||||
from app_audit import audit_log
|
||||
except ImportError:
|
||||
return
|
||||
try:
|
||||
await audit_log(
|
||||
sor, operator_id, operator_name, 'customer_recharge',
|
||||
target=customerid,
|
||||
detail='代客充值 客户=' + str(customer_name) + ' (' + str(orgname or '') + ') 金额=' + str(amount),
|
||||
result='ok', client_ip=client_ip)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
username = params_kw.get('username', '').strip()
|
||||
amount_raw = params_kw.get('amount', 0)
|
||||
debug(f'{params_kw=},{username=}, {amount_raw=}')
|
||||
@ -133,6 +149,21 @@ async with db.sqlorContext(dbname) as sor:
|
||||
0.0
|
||||
)
|
||||
|
||||
# 审计:代客充值(旁路,失败不阻断主流程)
|
||||
_op_username = userid
|
||||
try:
|
||||
_op_recs = await sor.sqlExe("SELECT username FROM users WHERE id=${u}$", {'u': userid})
|
||||
if _op_recs:
|
||||
_op_username = _op_recs[0].username or userid
|
||||
except Exception:
|
||||
pass
|
||||
_client_ip = ''
|
||||
try:
|
||||
_client_ip = request.get('client_ip', '') or ''
|
||||
except Exception:
|
||||
pass
|
||||
await _audit_recharge(sor, userid, _op_username, customerid, username, customer.orgname or '', amount, _client_ip)
|
||||
|
||||
debug(f'Proxy recharge: user={username}, customerid={customerid}, amount={amount}, operator={userid}')
|
||||
|
||||
orgname = customer.orgname or ''
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user