Merge branch 'dev-lwl/wx' into test

This commit is contained in:
lwl0608 2024-05-07 19:25:11 +08:00
commit aeeb97dc7c
10 changed files with 104 additions and 7 deletions

View File

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

View File

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

View File

@ -68,6 +68,7 @@ CREATE INDEX ix_orderid ON vas_ch_charge (order_id);
CREATE INDEX mid_ct ON vas_ch_income (mid, ct); CREATE INDEX mid_ct ON vas_ch_income (mid, ct);
CREATE INDEX uid_ct ON vas_ch_income (uid, ct); CREATE INDEX uid_ct ON vas_ch_income (uid, ct);
CREATE INDEX ix_orderid ON vas_ch_income (order_id); CREATE INDEX ix_orderid ON vas_ch_income (order_id);
CREATE INDEX ix_ct ON vas_ch_income (ct);
CREATE INDEX mid_ct ON vas_ch_withdraw (mid, ct); CREATE INDEX mid_ct ON vas_ch_withdraw (mid, ct);
CREATE INDEX uid_ct ON vas_ch_withdraw (uid, ct); CREATE INDEX uid_ct ON vas_ch_withdraw (uid, ct);
CREATE INDEX ix_orderid ON vas_ch_withdraw (order_id); CREATE INDEX ix_orderid ON vas_ch_withdraw (order_id);

View File

@ -63,6 +63,15 @@ wxpay:
notify_url: "https://api.tiefen.fun/ext/vas/wxpay_callback" notify_url: "https://api.tiefen.fun/ext/vas/wxpay_callback"
app_secret: "ebc325109b91087e22f046bc8ac5c940" app_secret: "ebc325109b91087e22f046bc8ac5c940"
wxpay_tfz:
mchid: "1675813721"
appid: "wxc28fd8aaf31984b6"
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: "ebc325109b91087e22f046bc8ac5c940"
apollo: apollo:
app_id: "wishpal_live_service" app_id: "wishpal_live_service"
cluster: "dev" cluster: "dev"

View File

@ -36,6 +36,16 @@ wxpay:
notify_url: "https://api.wishpal.cn/ext/vas/wxpay_callback" notify_url: "https://api.wishpal.cn/ext/vas/wxpay_callback"
app_secret: "ebc325109b91087e22f046bc8ac5c940" app_secret: "ebc325109b91087e22f046bc8ac5c940"
wxpay_tfz:
mchid: "1675813721"
appid: "wxc28fd8aaf31984b6"
serial_no: "176903F43E78B0BA5AA1F08A3BE852A5F637DC77"
apiv3_key: "5QwY1XMK1HW3JQwGKbA3mfJ5cdsTQGjR"
private_key_path: "/app/wishpal-ironfan/etc/mix/wxpaycert_tfz/apiclient_key.pem"
notify_url: "https://api.wishpal.cn/ext/vas/wxpay_callback"
app_secret: "ebc325109b91087e22f046bc8ac5c940"
apiv2_key: "mot5410nh69k87e22f046bc8anv5xds8"
crypto: crypto:
aes: aes:
private_key: "Xbz1145141919810" private_key: "Xbz1145141919810"

Binary file not shown.

View File

@ -0,0 +1,25 @@
-----BEGIN CERTIFICATE-----
MIIEKDCCAxCgAwIBAgIUF2kD9D54sLpaofCKO+hSpfY33HcwDQYJKoZIhvcNAQEL
BQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsT
FFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3Qg
Q0EwHhcNMjQwNTAyMTc1NzA2WhcNMjkwNTAxMTc1NzA2WjCBgTETMBEGA1UEAwwK
MTY3NTgxMzcyMTEbMBkGA1UECgwS5b6u5L+h5ZWG5oi357O757ufMS0wKwYDVQQL
DCTmiJDpg73lv4PmhI/liLDkuobnp5HmioDmnInpmZDlhazlj7gxCzAJBgNVBAYT
AkNOMREwDwYDVQQHDAhTaGVuWmhlbjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAOaDpU37roG4zQOok/00vHtgPQdVEy/SgxqdakEEygVFXTiCh/PSmynV
wtAiULYkDor+KdPMAqmTO/wVxlkxVWhh0tq3Wr49MWqmSGAdS749H0CKv/TxrL+y
Bmw5OuKolGV7xYne9wJC28M0wJOJH4XFwUSJnQqOec956KdwnSWuZ/X8uI0d8Cs1
It/HRX4tJunEDaPFLCnF4ju6wrr+kAjlZb35laDX7zmDg25/yhpxpmgeAeJgSH7K
EJSCYlUWOpspMb4porEG5NIUxu1TfLXO4kkx3j7Diz8szdzZrTGdLcc4FjKNTdIL
jaJx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SoXn+hag9XUbJQz
QfCC4a18D8eS0HWdwEOBeY68hSST/5U1pbkA1FsCgYBQZX6MqUEybdjPnxeJn/RN
c3wG97sGG87A6Xo2i42koX1w87LT/f9qJrR/sU6kHw/39E/vx2xkMIs6u7I9lO+d
WsBYbtcp4ZDAI1+NwcDtkd6Q1Kbpti2MxkuC6r+1kteE80DEB4lryJ6r4HAry3k8
uCJCasc77UvJcfVnZX5QkA==
-----END PRIVATE KEY-----

View File

@ -30,21 +30,43 @@ const (
DefaultOrderTimeoutSeconds = 900 // 默认订单超时时间,单位: s DefaultOrderTimeoutSeconds = 900 // 默认订单超时时间,单位: s
) )
var defaultWxpayClient *WxpayClient const (
AppIdXinYiDaoLe = "1665016206"
AppIdTieFenZone = "1675813721"
)
var allWxpayClients = map[string]*WxpayClient{}
func GetDefaultWxpayClient() *WxpayClient {
return allWxpayClients[AppIdTieFenZone]
}
type WxpayClient struct { type WxpayClient struct {
clientV3 *wxpayv3.ClientV3 clientV3 *wxpayv3.ClientV3
MchId string `json:"mch_id"`
AppSecret string `json:"app_secret"` AppSecret string `json:"app_secret"`
AppId string `json:"app_id"` AppId string `json:"app_id"`
NotifyUrl string `json:"notify_url"` NotifyUrl string `json:"notify_url"`
PrivateKeyPath string `json:"private_key_path"` PrivateKeyPath string `json:"private_key_path"`
} }
func GetDefaultWxpayClient() *WxpayClient { func InitMulti(cfgList ...*configcenter.WxpayClientConfig) (err error) {
return defaultWxpayClient 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.MchId] = cli
}
return
} }
func Init(cfg *configcenter.WxpayClientConfig) (err error) { func NewWxpayClient(cfg *configcenter.WxpayClientConfig) (ret *WxpayClient, err error) {
// private key // private key
bs, err := os.ReadFile(cfg.PrivateKeyPath) bs, err := os.ReadFile(cfg.PrivateKeyPath)
if err != nil { if err != nil {
@ -59,8 +81,9 @@ func Init(cfg *configcenter.WxpayClientConfig) (err error) {
return return
} }
defaultWxpayClient = &WxpayClient{ ret = &WxpayClient{
clientV3: wxpayCliV3, clientV3: wxpayCliV3,
MchId: cfg.MchId,
AppSecret: cfg.AppSecret, AppSecret: cfg.AppSecret,
AppId: cfg.AppId, AppId: cfg.AppId,
NotifyUrl: cfg.NotifyUrl, NotifyUrl: cfg.NotifyUrl,

View File

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