fix: 星之界/星阙支付按俱乐部分别取 openid 与 AppID,启动静默刷新绑定
- resolve_club_payment_openid: xzj 回落 UserName 并 lazy 写绑定;xq 回落 OpenID;禁止跨俱乐部混用 - 统一 get_club_miniapp_appid;非 xq 禁止回落全局 AppID - 新增 /jituan/auth/refresh-wx-bind;小程序有 token 时静默刷新 openid Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -14,7 +14,7 @@ from jituan.constants import SUPER_ADMIN_PHONES, ADMIN_ROLE_LABELS, CLUB_ID_DEFA
|
||||
from jituan.models import Club, AdminAssignment
|
||||
from jituan.services.admin_context import build_admin_club_context, is_kefu_backend_account, can_manage_admin_assignments
|
||||
from jituan.services.kefu_menu import build_menu_access_payload
|
||||
from jituan.services.wechat_login import login_or_register_by_club
|
||||
from jituan.services.wechat_login import login_or_register_by_club, refresh_wx_openid_binding
|
||||
from jituan.services.caiwu_stats import build_caiwu_payload
|
||||
from jituan.services.szxx_stats import build_szxx_payload
|
||||
from jituan.services.admin_assignments import (
|
||||
@@ -75,6 +75,35 @@ class ClubWechatLoginView(APIView):
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
|
||||
|
||||
class ClubWxBindRefreshView(APIView):
|
||||
"""
|
||||
已登录用户静默刷新当前小程序 openid 绑定(支付前 AppID/openid 对齐)。
|
||||
POST /jituan/auth/refresh-wx-bind
|
||||
body: { code, club_id?, app_id? }
|
||||
"""
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def post(self, request):
|
||||
code = (request.data.get('code') or '').strip()
|
||||
club_id = (request.data.get('club_id') or '').strip() or None
|
||||
app_id = (request.data.get('app_id') or '').strip() or None
|
||||
if not code:
|
||||
return Response({'code': 1, 'msg': '微信授权码不能为空', 'data': None},
|
||||
status=status.HTTP_400_BAD_REQUEST)
|
||||
try:
|
||||
data, err = refresh_wx_openid_binding(
|
||||
code, request.user, club_id=club_id, app_id=app_id,
|
||||
)
|
||||
if err:
|
||||
return Response({'code': 2, 'msg': err, 'data': None},
|
||||
status=status.HTTP_400_BAD_REQUEST)
|
||||
return Response({'code': 0, 'msg': 'ok', 'data': data})
|
||||
except Exception:
|
||||
logger.exception('ClubWxBindRefreshView 异常')
|
||||
return Response({'code': 99, 'msg': '刷新绑定失败', 'data': None},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
|
||||
|
||||
class ClubKefuLoginView(APIView):
|
||||
"""
|
||||
多俱乐部客服/集团后台登录(新接口,旧 /yonghu/kefujinru 不变)。
|
||||
|
||||
Reference in New Issue
Block a user