From 1d4d054c75911b4346a286148277bfbf8c06e6d4 Mon Sep 17 00:00:00 2001 From: XingQue Date: Sat, 20 Jun 2026 03:36:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=95=86=E5=AE=B6?= =?UTF-8?q?=E5=AE=A2=E6=9C=8D=E7=99=BB=E5=BD=95=E8=BA=AB=E4=BB=BD=E6=A0=87?= =?UTF-8?q?=E8=AF=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- merchant_ops/services/authz.py | 9 +++++++++ users/views.py | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/merchant_ops/services/authz.py b/merchant_ops/services/authz.py index f3b5dfe..69273f0 100644 --- a/merchant_ops/services/authz.py +++ b/merchant_ops/services/authz.py @@ -53,6 +53,15 @@ def assert_staff_perm(member, perm_code): raise StaffAuthError(403, f'无权限: {perm_code}') +def staff_fields_for_login(user): + """登录/注册响应附带子客服身份(与 shangjiastatus 并列,互斥)。""" + ctx = resolve_staff_context(user) + return { + 'staffstatus': 1 if ctx else 0, + 'staff_context': ctx, + } + + def resolve_staff_context(user): """子客服上下文;非客服返回 None。""" member = get_active_staff_member(user) diff --git a/users/views.py b/users/views.py index aae931e..f3934c9 100644 --- a/users/views.py +++ b/users/views.py @@ -284,6 +284,9 @@ class WechatMiniProgramLoginView(APIView): # 获取群配置 group_info = self.huoquQunPeizhi() + from merchant_ops.services.authz import staff_fields_for_login + staff_fields = staff_fields_for_login(user_main) + # 返回数据 response_data = { 'token': token, @@ -299,7 +302,8 @@ class WechatMiniProgramLoginView(APIView): 'dashouqun': group_info.get('dashouqun', ''), 'dashouqunid': group_info.get('dashouqunid', ''), 'guanshiqun': group_info.get('guanshiqun', ''), - 'guanshiqunid': group_info.get('guanshiqunid', '') + 'guanshiqunid': group_info.get('guanshiqunid', ''), + **staff_fields, } return Response({'code': 0, 'msg': '登录成功', 'data': response_data})