fix: 小程序支付 AppID 与登录一致,登录覆盖过期 openid 绑定

- JSAPI 支付优先 club.wx_appid(与 jscode2session 一致,不再优先 pay_app_id)
- 登录时同一用户+俱乐部只保留最新 openid,清除旧绑定
- 支付仅读 user_wx_openid,彻底禁用 legacy OpenID/UserName 回落

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-10 20:52:56 +08:00
parent f601541eb0
commit 5d3e4e32a2
3 changed files with 84 additions and 36 deletions

View File

@@ -447,6 +447,18 @@ class ClubManageView(APIView):
warnings.append(
'mch_key 与 api_v3_key 内容相同通常不正确V2小程序支付与 V3转账是两套不同密钥。'
)
wx_a = (club.wx_appid or '').strip()
pay_a = (club.pay_app_id or '').strip()
if wx_a and pay_a and wx_a != pay_a:
warnings.append(
f'wx_appid({wx_a}) 与 pay_app_id({pay_a}) 不一致:'
'小程序登录/支付 openid 与 wx_appid 绑定,请保持一致或留空 pay_app_id。'
)
if not wx_a and pay_a:
warnings.append(
f'wx_appid 为空但 pay_app_id={pay_a}:登录仍可能回落旧全局 AppID'
'导致 openid 与支付 AppID 不匹配,请填写 wx_appid。'
)
return {
'miniapp_wechat_v2_key': mch_key,