fix: admin_audit_log 操作人ID支持手机号解析
This commit is contained in:
@@ -87,6 +87,26 @@ def filter_xiugaijilu_by_request(qs, request):
|
||||
return qs.filter(yonghuid__in=uid_list)
|
||||
|
||||
|
||||
def resolve_operator_yonghuid(xiugaiid):
|
||||
"""
|
||||
xiugaijilu.xiugaiid 多为客服手机号;admin_audit_log.operator_yonghuid 存 UserUID。
|
||||
解析失败时回落为原值(列宽已放宽至 16)。
|
||||
"""
|
||||
s = str(xiugaiid or '').strip()
|
||||
if not s:
|
||||
return ''
|
||||
if len(s) <= 7:
|
||||
return s
|
||||
from users.business_models import User
|
||||
u = User.query.filter(Phone=s).first()
|
||||
if u and getattr(u, 'UserUID', None):
|
||||
return str(u.UserUID)
|
||||
u = User.query.filter(UserUID=s).first()
|
||||
if u and getattr(u, 'UserUID', None):
|
||||
return str(u.UserUID)
|
||||
return s[:16]
|
||||
|
||||
|
||||
def log_admin_audit_from_xiugai(
|
||||
*,
|
||||
yonghuid,
|
||||
@@ -99,9 +119,10 @@ def log_admin_audit_from_xiugai(
|
||||
"""与 write_xiugai_log 同步写入 admin_audit_log(失败不影响主流程)。"""
|
||||
try:
|
||||
cid = club_id or club_id_for_yonghuid(yonghuid)
|
||||
operator_uid = resolve_operator_yonghuid(xiugaiid)
|
||||
AdminAuditLog.query.create(
|
||||
club_id=cid,
|
||||
operator_yonghuid=str(xiugaiid),
|
||||
operator_yonghuid=operator_uid,
|
||||
target_yonghuid=str(yonghuid),
|
||||
action='xiugaijilu',
|
||||
resource_type='user',
|
||||
|
||||
Reference in New Issue
Block a user