This commit is contained in:
Mrx
2026-05-11 15:02:57 +08:00
parent 9c4fd95955
commit 467f081a1a
27 changed files with 14 additions and 8 deletions

View File

@@ -52,7 +52,6 @@ Wxpay:
MchPlatformRAS: "PUB_KEY_ID_0111052766902026050900112134001605" MchPlatformRAS: "PUB_KEY_ID_0111052766902026050900112134001605"
NotifyUrl: "https://www.tianyuancha.cn/api/v1/pay/wechat/callback" NotifyUrl: "https://www.tianyuancha.cn/api/v1/pay/wechat/callback"
RefundNotifyUrl: "https://www.tianyuancha.cn/api/v1/wechat/refund_callback" RefundNotifyUrl: "https://www.tianyuancha.cn/api/v1/wechat/refund_callback"
# MchApiv2Key: "Kx9pL2mQ8vR4tY6wE1zA5cD7fH0jN3bS"
Applepay: Applepay:
ProductionVerifyURL: "https://api.storekit.itunes.apple.com/inApps/v1/transactions/receipt" ProductionVerifyURL: "https://api.storekit.itunes.apple.com/inApps/v1/transactions/receipt"
@@ -71,8 +70,8 @@ WechatH5:
AppID: "wxd391e40295bd9dfb" AppID: "wxd391e40295bd9dfb"
AppSecret: "f0fa74f7ed8c3c9953677465d44a4c0c" AppSecret: "f0fa74f7ed8c3c9953677465d44a4c0c"
WechatMini: WechatMini:
AppID: "wx781abb66b3368963" # 小程序的AppID AppID: "wx5bacc94add2da981" # 小程序的AppID
AppSecret: "c7d02cdb0fc23c35c93187af9243b00d" # 小程序的AppSecret AppSecret: "48a2c1e8ff1b7d4c0ff82fbefa64d2d0" # 小程序的AppSecret
TycAppID: "wxe74617f3dd56c196" TycAppID: "wxe74617f3dd56c196"
TycAppSecret: "c8207e54aef5689b2a7c1f91ed7ae8a0" TycAppSecret: "c8207e54aef5689b2a7c1f91ed7ae8a0"
Query: Query:

View File

@@ -113,7 +113,8 @@ var productHandlers = map[string]queryHandlerFunc{
// productHasSmsCode 表示该 product 解密后的请求结构体中是否包含必填短信验证码 Code。 // productHasSmsCode 表示该 product 解密后的请求结构体中是否包含必填短信验证码 Code。
// 有 Code 的产品在「获取验证码」时已经做了滑块,这里不再强制要求 CaptchaVerifyParam。 // 有 Code 的产品在「获取验证码」时已经做了滑块,这里不再强制要求 CaptchaVerifyParam。
// 其他产品(无 Code在查询时必须传并校验 CaptchaVerifyParam防止跳过图形验证 // 其他产品(无 Code在查询时必须传并校验 CaptchaVerifyParam防止跳过图形验证
// 微信小程序X-Platform: wxmini见 ctxdata.GetPlatformFromCtx不嵌入 H5 滑块,由 PreprocessLogic 跳过图形校验。
func productHasSmsCode(product string) bool { func productHasSmsCode(product string) bool {
switch product { switch product {
case "marriage", case "marriage",
@@ -140,8 +141,14 @@ func productHasSmsCode(product string) bool {
} }
func (l *QueryServiceLogic) PreprocessLogic(req *types.QueryServiceReq, product string) (*types.QueryServiceResp, error) { func (l *QueryServiceLogic) PreprocessLogic(req *types.QueryServiceReq, product string) (*types.QueryServiceResp, error) {
// 无短信验证码 Code 的 product查询前必须传并校验滑块,否则不允许跳过 // 无短信验证码 Code 的 product查询前必须传并校验滑块;微信小程序端跳过(依赖登录态与 X-Platform
if !productHasSmsCode(product) { requireCaptcha := !productHasSmsCode(product)
if requireCaptcha {
if plat, platErr := ctxdata.GetPlatformFromCtx(l.ctx); platErr == nil && plat == model.PlatformWxMini {
requireCaptcha = false
}
}
if requireCaptcha {
if req.CaptchaVerifyParam == "" { if req.CaptchaVerifyParam == "" {
return nil, errors.Wrapf(xerr.NewErrMsg("请完成图形验证"), "product %s requires captcha", product) return nil, errors.Wrapf(xerr.NewErrMsg("请完成图形验证"), "product %s requires captcha", product)
} }

View File

@@ -90,7 +90,7 @@ func GetPlatformFromCtx(ctx context.Context) (string, error) {
} }
switch platform { switch platform {
case model.PlatformWxMini: case model.PlatformWxMini, "mp-weixin": // 兼容旧客户端误传的 uni 平台名
return model.PlatformWxMini, nil return model.PlatformWxMini, nil
case model.PlatformWxH5: case model.PlatformWxH5:
return model.PlatformWxH5, nil return model.PlatformWxH5, nil
@@ -99,6 +99,6 @@ func GetPlatformFromCtx(ctx context.Context) (string, error) {
case model.PlatformH5: case model.PlatformH5:
return model.PlatformH5, nil return model.PlatformH5, nil
default: default:
return "", fmt.Errorf("不支持的支付平台: %s", platform) return "", fmt.Errorf("不支持的客户端平台: %s", platform)
} }
} }