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:
@@ -6,6 +6,7 @@ from django.conf import settings
|
||||
|
||||
from jituan.constants import CLUB_ID_DEFAULT
|
||||
from jituan.models import Club
|
||||
from jituan.services.club_resolver import get_club_miniapp_appid
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -51,16 +52,25 @@ def get_wechat_v2_config(club_id=None):
|
||||
|
||||
cfg_json = club.config_json or {}
|
||||
mch_key, key_source = _resolve_v2_mch_key(cfg_json, fallback['key'])
|
||||
mini_appid = (club.wx_appid or '').strip()
|
||||
pay_appid = (club.pay_app_id or '').strip()
|
||||
if mini_appid and pay_appid and mini_appid != pay_appid:
|
||||
mini_appid = get_club_miniapp_appid(club)
|
||||
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:
|
||||
logger.warning(
|
||||
'[WX_V2_CONFIG] club=%s wx_appid(%s) 与 pay_app_id(%s) 不一致;'
|
||||
'小程序 JSAPI 支付以 wx_appid 为准(openid 与登录 AppID 绑定)',
|
||||
cid, mini_appid, pay_appid,
|
||||
'小程序 JSAPI 以 wx_appid 优先(openid 与登录 AppID 绑定)',
|
||||
cid, wx_a, pay_a,
|
||||
)
|
||||
# openid 由 jscode2session(club.wx_appid) 换取,支付 AppID 须与登录一致
|
||||
appid = mini_appid or pay_appid or fallback['appid']
|
||||
if mini_appid:
|
||||
appid = mini_appid
|
||||
elif cid == CLUB_ID_DEFAULT:
|
||||
appid = fallback['appid']
|
||||
else:
|
||||
logger.error(
|
||||
'[WX_V2_CONFIG] club=%s 未配置 wx_appid/pay_app_id,禁止回落星阙全局 AppID',
|
||||
cid,
|
||||
)
|
||||
appid = ''
|
||||
mch_id = club.mch_id or fallback['mch_id']
|
||||
|
||||
if mch_id and key_source == 'settings.WEIXIN_SHANGHUMIYAO':
|
||||
@@ -213,10 +223,8 @@ def get_wechat_v3_config(club_id=None):
|
||||
|
||||
cfg_json = club.config_json or {}
|
||||
return {
|
||||
'APPID': (
|
||||
(club.wx_appid or '').strip()
|
||||
or (club.pay_app_id or '').strip()
|
||||
or fallback['APPID']
|
||||
'APPID': get_club_miniapp_appid(club) or (
|
||||
fallback['APPID'] if cid == CLUB_ID_DEFAULT else ''
|
||||
),
|
||||
'MCHID': club.mch_id or fallback['MCHID'],
|
||||
'PRIVATE_KEY_PATH': (
|
||||
|
||||
Reference in New Issue
Block a user