fix: bind kefu role by yonghuid when phone duplicated

This commit is contained in:
XingQue
2026-06-28 23:18:14 +08:00
parent de91089743
commit 218001399c
4 changed files with 22 additions and 7 deletions

View File

@@ -596,15 +596,13 @@ class ModifyAdminUserView(APIView):
if '000001' not in permissions:
return Response({'code': 403, 'msg': '您无权进行此操作'})
target_yonghuid = request.data.get('yonghuid', '').strip()
target_phone = request.data.get('phone', '').strip()
if not target_phone:
return Response({'code': 400, 'msg': '缺少目标用户账号'})
if not target_yonghuid and not target_phone:
return Response({'code': 400, 'msg': '缺少目标用户yonghuid 或 phone'})
# Phone 非唯一,同一手机号可能对应多个微信用户;后台操作只定位客服账号
target_user = User.query.filter(
Phone=target_phone,
KefuProfile__isnull=False,
).first()
from jituan.services.club_rbac import resolve_kefu_admin_user
target_user = resolve_kefu_admin_user(yonghuid=target_yonghuid, phone=target_phone)
if not target_user:
return Response({'code': 404, 'msg': '用户不存在或非后台账号'})
try: