This commit is contained in:
lwl0608 2024-05-03 02:26:48 +08:00
parent 0422cb6926
commit 028a5232cd
8 changed files with 91 additions and 7 deletions

View File

@ -8,6 +8,7 @@ type ConfigSt struct {
MixMysql *configcenter.MysqlConfig `json:"mix_mysql" yaml:"mix_mysql"` // mix mysql
Crypto *configcenter.CryptoConfig `json:"crypto" yaml:"crypto"` // 账号相关加密
Wxpay *configcenter.WxpayClientConfig `json:"wxpay" yaml:"wxpay"` // 微信支付
WxpayTFZ *configcenter.WxpayClientConfig `json:"wxpay_tfz" yaml:"wxpay_tfz"` // 微信支付
Alipay *configcenter.AlipayClientConfig `json:"alipay" yaml:"alipay"` // 支付宝 心意到了
AlipayMYTS *configcenter.AlipayClientConfig `json:"alipay_myts" yaml:"alipay_myts"` // 支付宝 觅缘天使
Apollo *configcenter.ApolloConfig `json:"apollo" yaml:"apollo"` // Apollo

View File

@ -159,7 +159,7 @@ func (s *Service) Init(c any) (err error) {
return
}
err = wxpaycli.Init(cfg.Wxpay)
err = wxpaycli.InitMulti(cfg.Wxpay, cfg.WxpayTFZ)
if err != nil {
logger.Error("wxpaycli.Init fail, cfg: %v, err: %v", util.ToJson(cfg.Wxpay), err)
return

View File

@ -63,6 +63,15 @@ wxpay:
notify_url: "https://api.tiefen.fun/ext/vas/wxpay_callback"
app_secret: "ebc325109b91087e22f046bc8ac5c940"
wxpay_tfz:
mchid: "1665016206"
appid: ""
serial_no: "176903F43E78B0BA5AA1F08A3BE852A5F637DC77"
apiv3_key: "5QwY1XMK1HW3JQwGKbA3mfJ5cdsTQGjR"
private_key_path: "/app/wishpal-ironfan/etc/mix/wxpaycert_tfz/apiclient_key.pem"
notify_url: "https://api.tiefen.fun/ext/vas/wxpay_callback"
app_secret: "mot5410nh69k87e22f046bc8anv5xds8"
apollo:
app_id: "wishpal_live_service"
cluster: "dev"

Binary file not shown.

View File

@ -0,0 +1,25 @@
-----BEGIN CERTIFICATE-----
MIIEKDCCAxCgAwIBAgIUF2kD9D54sLpaofCKO+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BVsL3qOLVTpLgIQQZyPSfj0Xg3rG7h
hzab5gLF+TREAFYsHPR1vyDJjzGjimrHjvCWysMxaQKBgQD26GvU2tz5HNMpGeUZ
A0DJmnKxY40sPltZES/l3mTiJzmig6kT+UGxeg3tPkU3Z/zCUFdoXWT1nNA185eD
fFgEka3mxg1g5Iw9PmefqeHbCMs94ICKdxsnJn1PFMhIPqhms9wcjoKJGgKUj3ov
a243HS/yh4gl6EnvMMeBTZMpZQKBgQDvAK7X9ZXb91+F/lBHrhynJjQmsbiDQcqk
synIImWPHJ6M1h2/vJbplmaOQFPOBqQiMWepb3TtKtGcSAYXIsyUFD1OECLb/+Vn
We/P6kVyki7UgDLkQERhNDmsdP1qzzt0UmncUjYUk2eFlfobgwSP3iZ+8aFZ10XF
BSwJTbrwHwKBgD2kpVdNFSI0qht21ZW7FC/BGaVj/1jucIv6GIVBUtqLhH4odMwB
zP7sRBHZHBrLIXW57TinKI+RiQIPQOKY5ritTkdxZuGr7b9UlzZriXHP7j4SkMUB
G4xYtaxKuf4fdpe9i9StV7W3ArHoaE7yeV/VL6VTZRBhwCOxf/2uSnFpAoGAV8S1
cKNEREIkty08SAZ9iThzYF5VdwY7J56P0monR5Xn96pNxHK6LM/Jm6Wt4PP5ZIEm
I0fF9a6KyUx9yBNEc4C3PqqYUpg3o2uYsI7EsB1Uyz7E8aNUOSoXn+hag9XUbJQz
QfCC4a18D8eS0HWdwEOBeY68hSST/5U1pbkA1FsCgYBQZX6MqUEybdjPnxeJn/RN
c3wG97sGG87A6Xo2i42koX1w87LT/f9qJrR/sU6kHw/39E/vx2xkMIs6u7I9lO+d
WsBYbtcp4ZDAI1+NwcDtkd6Q1Kbpti2MxkuC6r+1kteE80DEB4lryJ6r4HAry3k8
uCJCasc77UvJcfVnZX5QkA==
-----END PRIVATE KEY-----

View File

@ -30,7 +30,16 @@ const (
DefaultOrderTimeoutSeconds = 900 // 默认订单超时时间,单位: s
)
var defaultWxpayClient *WxpayClient
const (
AppIdXinYiDaoLe = "wxc28fd8aaf31984b6"
AppIdTieFenZone = ""
)
var allWxpayClients = map[string]*WxpayClient{}
func GetDefaultWxpayClient() *WxpayClient {
return allWxpayClients[AppIdXinYiDaoLe]
}
type WxpayClient struct {
clientV3 *wxpayv3.ClientV3
@ -40,11 +49,23 @@ type WxpayClient struct {
PrivateKeyPath string `json:"private_key_path"`
}
func GetDefaultWxpayClient() *WxpayClient {
return defaultWxpayClient
func InitMulti(cfgList ...*configcenter.WxpayClientConfig) (err error) {
for _, cfg := range cfgList {
var cli *WxpayClient
cli, err = NewWxpayClient(cfg)
if err != nil {
return
}
if cli == nil {
err = errors.New("NewAlipayClient fail")
return
}
allWxpayClients[cli.AppId] = cli
}
return
}
func Init(cfg *configcenter.WxpayClientConfig) (err error) {
func NewWxpayClient(cfg *configcenter.WxpayClientConfig) (ret *WxpayClient, err error) {
// private key
bs, err := os.ReadFile(cfg.PrivateKeyPath)
if err != nil {
@ -59,7 +80,7 @@ func Init(cfg *configcenter.WxpayClientConfig) (err error) {
return
}
defaultWxpayClient = &WxpayClient{
ret = &WxpayClient{
clientV3: wxpayCliV3,
AppSecret: cfg.AppSecret,
AppId: cfg.AppId,

View File

@ -20,7 +20,7 @@ func TestMain(m *testing.M) {
fmt.Printf("%v\n", err)
}
err = Init(cfg.Wxpay)
err = InitMulti(cfg.Wxpay)
if err != nil {
fmt.Println(err)
os.Exit(1)