From 364c3f1d2449adab9430183b34797e23d706cc8d Mon Sep 17 00:00:00 2001 From: XingQue Date: Tue, 21 Jul 2026 22:25:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E7=A0=81=E6=8E=A5=E5=8F=A3=E5=9C=A8?= =?UTF-8?q?=E5=B7=B2=E6=98=AF=E6=89=93=E6=89=8B=E6=97=A9=E9=80=80=E5=89=8D?= =?UTF-8?q?=E4=BB=8D=E5=86=99=E5=85=A5=20guanshi=5Fsaoma=EF=BC=8C=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E5=8F=AF=E8=B7=B3=E8=BF=87=E6=A0=87=E8=AE=B0=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E8=B7=B3=E8=BF=87=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- utils/dashou_register_service.py | 14 ++++++++++---- yonghu/views.py | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/utils/dashou_register_service.py b/utils/dashou_register_service.py index e47b706..e05bcaa 100644 --- a/utils/dashou_register_service.py +++ b/utils/dashou_register_service.py @@ -19,13 +19,19 @@ def mark_guanshi_qr_scanned(user_main, invite_code_raw): """ 仅当请求明确带了管事邀请码(真实扫码)时,标记用户已扫过管事二维码。 空邀请码走默认码注册的不标记,避免误开隐藏商品。 + 已是打手/老用户同样必须写入,注册流程可跳过,标记不可跳过。 """ if not user_main or not (invite_code_raw or '').strip(): - return - if getattr(user_main, 'guanshi_saoma', 0) == 1: - return - UserMain.objects.filter(pk=user_main.pk).update(guanshi_saoma=1) + return False + updated = UserMain.objects.filter(pk=user_main.pk).exclude(guanshi_saoma=1).update(guanshi_saoma=1) user_main.guanshi_saoma = 1 + if updated: + logger.info( + '扫管事码标记已写入 yonghuid=%s invite=%s', + getattr(user_main, 'yonghuid', ''), + (invite_code_raw or '')[:20], + ) + return True def resolve_guanshi_for_dashou_register(invite_code): diff --git a/yonghu/views.py b/yonghu/views.py index 862047e..4243b35 100644 --- a/yonghu/views.py +++ b/yonghu/views.py @@ -1390,13 +1390,13 @@ class DashouZhuceView(APIView): 'data': None }, status=status.HTTP_404_NOT_FOUND) - # 真实扫码(带了邀请码)才标记,空码走默认不标记 + # 扫码标记:在「是否已是打手」判断之前写入,已注册也会写,绝不跳过 mark_guanshi_qr_scanned(current_user, yaoqingma) # 2. 检查用户是否已是打手 (使用反向查询,性能最优) try: dashou_profile = current_user.dashou_profile - # 用户已是打手,直接返回现有信息 + # 用户已是打手,直接返回现有信息(标记已在上方写完) return self.fanhuiXianyouDashouXinxi(dashou_profile, current_user) except UserDashou.DoesNotExist: # 用户不是打手,继续注册流程