<feat>缓存客户端
This commit is contained in:
parent
e9a548d31d
commit
2c4974a25f
|
@ -18,8 +18,14 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var WxClientGroup = make(map[string]*wechat.ClientV3)
|
||||||
|
|
||||||
// InitClient 使用提供的支付请求参数初始化微信客户端
|
// InitClient 使用提供的支付请求参数初始化微信客户端
|
||||||
func InitClient(wxConfig WxPay) (*wechat.ClientV3, error) {
|
func InitClient(wxConfig WxPay) (*wechat.ClientV3, error) {
|
||||||
|
clientCache, ex := WxClientGroup[wxConfig.AppId]
|
||||||
|
if ex {
|
||||||
|
return clientCache, nil
|
||||||
|
}
|
||||||
// NewClientV3 初始化微信客户端 v3
|
// NewClientV3 初始化微信客户端 v3
|
||||||
// mchid:商户ID 或者服务商模式的 sp_mchid
|
// mchid:商户ID 或者服务商模式的 sp_mchid
|
||||||
// serialNo:商户证书的证书序列号
|
// serialNo:商户证书的证书序列号
|
||||||
|
@ -45,6 +51,7 @@ func InitClient(wxConfig WxPay) (*wechat.ClientV3, error) {
|
||||||
|
|
||||||
// 打开Debug开关,输出日志,默认是关闭的
|
// 打开Debug开关,输出日志,默认是关闭的
|
||||||
wxClient.DebugSwitch = gopay.DebugOn
|
wxClient.DebugSwitch = gopay.DebugOn
|
||||||
|
WxClientGroup[wxConfig.AppId] = wxClient
|
||||||
return wxClient, nil
|
return wxClient, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue