fix: 点单端推荐官按UID绑定,二维码进首页且去掉邀请码

扫码参数改为 yaoqingren=UserUID 落地点单首页;海报默认不再复用管事背景;不影响打手端与支付抢单分红。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-21 02:48:16 +08:00
parent 60d8b52693
commit 435422e716
4 changed files with 76 additions and 76 deletions

View File

@@ -353,7 +353,7 @@ class GuanshiQRCodeView(APIView):
class CYaoqingQRCodeView(APIView):
"""
点单端用户邀请小程序码
点单端老板推荐官小程序码(落地点单首页,按 UserUID 绑定,无邀请码)
POST /peizhi/cyaoqingewm
"""
permission_classes = [permissions.IsAuthenticated]
@@ -363,11 +363,18 @@ class CYaoqingQRCodeView(APIView):
try:
from jituan.services.club_context import resolve_effective_club_id
from utils.weixin_token import get_club_mini_access_token, is_weixin_token_invalid
from users.services.c_invite import ensure_c_invite_code
from users.services.c_invite import get_or_create_c_yaoqing
from users.models import YonghuCYaoqing
if not getattr(current_user, 'UserUID', None):
return Response(
{'code': 500, 'message': '用户身份异常', 'data': None},
status=status.HTTP_500_INTERNAL_SERVER_ERROR
)
club_id = resolve_effective_club_id(request, current_user)
profile, invite_code, _ = ensure_c_invite_code(current_user)
profile = get_or_create_c_yaoqing(current_user)
inviter_uid = str(current_user.UserUID)
access_token = get_club_mini_access_token(club_id)
if not access_token:
@@ -376,8 +383,8 @@ class CYaoqingQRCodeView(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR
)
encoded_invite = urllib.parse.quote(invite_code, safe='')
page_path = f'pages/index/index?inviteCode={encoded_invite}'
# 必须进点单首页,禁止进打手/管事页
page_path = f'pages/index/index?yaoqingren={urllib.parse.quote(inviter_uid, safe="")}'
post_data = {
'path': page_path,
'width': 430,
@@ -457,7 +464,7 @@ class CYaoqingQRCodeView(APIView):
try:
delete_from_oss(old_url)
except Exception as e:
logger.warning('删除旧 C 端二维码失败: %s', e)
logger.warning('删除旧点单端推荐二维码失败: %s', e)
with transaction.atomic():
locked = YonghuCYaoqing.objects.select_for_update().get(pk=profile.pk)
@@ -467,10 +474,10 @@ class CYaoqingQRCodeView(APIView):
return Response({
'code': 0,
'message': 'success',
'data': {'url': relative_path, 'yaoqingma': invite_code},
'data': {'url': relative_path, 'uid': inviter_uid},
})
except Exception as e:
logger.error('生成点单端邀请二维码失败: %s', e, exc_info=True)
logger.error('生成点单端推荐二维码失败: %s', e, exc_info=True)
return Response(
{'code': 500, 'message': '服务器内部错误', 'data': None},
status=status.HTTP_500_INTERNAL_SERVER_ERROR