Merge branch 'develop' of git.ailuowan.com:zzw/lone-services into develop
CI / changes (push) Successful in 1m28s
CI / ad (push) Successful in 1s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 30s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 23s
CI / express (push) Successful in 1s
CI / factory (push) Successful in 0s
CI / message (push) Successful in 0s
CI / order (push) Successful in 1s
CI / payment (push) Successful in 0s
CI / product (push) Successful in 0s
CI / record (push) Successful in 1s
CI / sale (push) Successful in 0s
CI / support (push) Successful in 0s
CI / task (push) Successful in 1s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 0s
CI / changes (push) Successful in 1m28s
CI / ad (push) Successful in 1s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 30s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 23s
CI / express (push) Successful in 1s
CI / factory (push) Successful in 0s
CI / message (push) Successful in 0s
CI / order (push) Successful in 1s
CI / payment (push) Successful in 0s
CI / product (push) Successful in 0s
CI / record (push) Successful in 1s
CI / sale (push) Successful in 0s
CI / support (push) Successful in 0s
CI / task (push) Successful in 1s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 0s
This commit is contained in:
@@ -36,10 +36,10 @@ func (c *Channel) Prepay(ctx context.Context, client string, req *pkgpay.PrepayR
|
||||
}
|
||||
|
||||
switch client {
|
||||
case pkgpay.ClientMiniProgram:
|
||||
return c.miniProgramPrepay(ctx, req)
|
||||
default:
|
||||
case pkgpay.ClientApp, pkgpay.ClientH5:
|
||||
return nil, pkgpay.ErrUnsupportedClient
|
||||
default:
|
||||
return c.miniProgramPrepay(ctx, req)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
wxpay "lone-services/pkg/wechat/pay"
|
||||
@@ -13,11 +14,15 @@ func NewWechatPayConfig(clientCode string) (wxpay.Config, error) {
|
||||
}
|
||||
|
||||
prefix := "wechat." + clientCode
|
||||
appID := utils.GetConfigString(prefix + ".app_id")
|
||||
if appID == utils.StringEmpty {
|
||||
appID = utils.GetConfigString("wechat.appid")
|
||||
}
|
||||
alias := clientAppAlias(clientCode)
|
||||
|
||||
appID := firstNonEmpty(
|
||||
utils.GetConfigString(prefix+".app_id"),
|
||||
utils.GetConfigString(prefix+".appid"),
|
||||
utils.GetConfigString("wechat."+alias+"_appid"),
|
||||
utils.GetConfigString("wechat.appid"),
|
||||
utils.GetConfigString("wechat.app_id"),
|
||||
)
|
||||
mchID := firstNonEmpty(
|
||||
utils.GetConfigString(prefix+".pay_mchid"),
|
||||
utils.GetConfigString("wechat.pay_mchid"),
|
||||
@@ -59,6 +64,13 @@ func NewWechatPayConfig(clientCode string) (wxpay.Config, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func clientAppAlias(clientCode string) string {
|
||||
if i := strings.IndexByte(clientCode, '_'); i > 0 {
|
||||
return clientCode[:i]
|
||||
}
|
||||
return clientCode
|
||||
}
|
||||
|
||||
func firstNonEmpty(values ...string) string {
|
||||
for _, v := range values {
|
||||
if v != utils.StringEmpty {
|
||||
|
||||
Reference in New Issue
Block a user