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: # 用户不是打手,继续注册流程