feat: UFO H5 服务号 OAuth 登录与同商户公众号 JSAPI 支付

This commit is contained in:
XingQue
2026-07-30 00:12:37 +08:00
parent 531639731a
commit 148a35f04b
11 changed files with 449 additions and 64 deletions

View File

@@ -172,10 +172,12 @@ def _resolve_v2_mch_key(club, cfg_json, fallback_key, club_id=None):
return '', 'missing'
def get_wechat_v2_config(club_id=None):
def get_wechat_v2_config(club_id=None, app_source='mini'):
"""
小程序 JSAPI 支付 V2 配置。
各俱乐部(含 xq优先读 club 表;字段为空时按项回落 settings兼容旧部署。
微信 JSAPI 支付 V2 配置。
app_source:
- mini小程序 AppID默认现网行为
- official服务号 AppIDH5商户号/密钥与小程序相同,仅换 AppID
"""
cid = (club_id or '').strip() or CLUB_ID_DEFAULT
fallback = {
@@ -194,6 +196,7 @@ def get_wechat_v2_config(club_id=None):
cfg_json = club.config_json or {}
mch_key, key_source = _resolve_v2_mch_key(club, cfg_json, fallback['key'], club_id=cid)
mini_appid = get_club_miniapp_appid(club)
official_appid = (club.official_appid or '').strip()
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:
@@ -202,7 +205,13 @@ def get_wechat_v2_config(club_id=None):
'小程序 JSAPI 以 wx_appid 优先openid 与登录 AppID 绑定)',
cid, wx_a, pay_a,
)
if mini_appid:
source = (app_source or 'mini').strip().lower()
if source in ('official', 'h5', 'oa'):
appid = official_appid
if not appid:
logger.error('[WX_V2_CONFIG] club=%s H5 支付需要 official_appid', cid)
elif mini_appid:
appid = mini_appid
elif cid == CLUB_ID_DEFAULT:
appid = fallback['appid']
@@ -236,6 +245,7 @@ def get_wechat_v2_config(club_id=None):
'key': mch_key,
'club_id': cid,
'_key_source': key_source,
'_app_source': source if source in ('official', 'h5', 'oa') else 'mini',
# 明确标记:这是点单/会员收款商户
'merchant_role': 'pay',
'cert_path': pay_cert,