From 7b13120c48d23cbe1a43d31fed40ec5d123892ff Mon Sep 17 00:00:00 2001 From: yangduo Date: Thu, 9 Jan 2025 11:34:47 +0800 Subject: [PATCH] adjust --- bin/payserver/config/config.json | 4 +++- .../api/v1/mainservice/mainservice.go | 4 ++-- server/payserver/constant/constant.go | 2 -- server/payserver/mt/Config.go | 10 ++++++---- server/payserver/mtb/mtb.auto_gen.go | 20 +++++++++++++++++++ server/payserver/proto/mt.proto | 2 ++ .../router/mainservice/mainservice.go | 4 ++-- server/payserver/service/wxpaybase.go | 7 ++++--- 8 files changed, 39 insertions(+), 14 deletions(-) diff --git a/bin/payserver/config/config.json b/bin/payserver/config/config.json index f637e8d..cafe399 100644 --- a/bin/payserver/config/config.json +++ b/bin/payserver/config/config.json @@ -1,4 +1,6 @@ { "gameapi_url": "https://game2006api-test.kingsome.cn", - "wx_url": "api.weixin.qq.com|api2.weixin.qq.com|sh.api.weixin.qq.com|sz.api.weixin.qq.com|hk.api.weixin.qq.com" + "wx_url": "api.weixin.qq.com|api2.weixin.qq.com|sh.api.weixin.qq.com|sz.api.weixin.qq.com|hk.api.weixin.qq.com", + "wx_notify_token": "dV93f4FwSGMwkYcvsRHD8egdW5egPMhF", + "wx_notify_encoding_aes_key": "H60uFIXjyd431hLVhlsKyus3U28RVIzWncey424DqpY" } diff --git a/server/payserver/api/v1/mainservice/mainservice.go b/server/payserver/api/v1/mainservice/mainservice.go index 830116e..cc6b2c3 100644 --- a/server/payserver/api/v1/mainservice/mainservice.go +++ b/server/payserver/api/v1/mainservice/mainservice.go @@ -52,7 +52,7 @@ func (this *MainServiceApi) WxTNotify(c *gin.Context) { timestamp := c.Query("timestamp") nonce := c.Query("nonce") echostr := c.Query("echostr") - strs := []string{constant.WX_NOTIFY_TOKEN, timestamp, nonce} + strs := []string{mt.Table.Config.GetWxNotifyToken(), timestamp, nonce} sort.Strings(strs) sb := strings.Builder{} sb.WriteString(strs[0]) @@ -78,7 +78,7 @@ func (this *MainServiceApi) WxNotifyPurchase(c *gin.Context) { timestamp := c.Query("timestamp") nonce := c.Query("nonce") - strs := []string{constant.WX_NOTIFY_TOKEN, timestamp, nonce} + strs := []string{mt.Table.Config.GetWxNotifyToken(), timestamp, nonce} sort.Strings(strs) sb := strings.Builder{} sb.WriteString(strs[0]) diff --git a/server/payserver/constant/constant.go b/server/payserver/constant/constant.go index 8741ee6..5ea8f09 100644 --- a/server/payserver/constant/constant.go +++ b/server/payserver/constant/constant.go @@ -59,8 +59,6 @@ const ( ) const ( - WX_NOTIFY_TOKEN = "dV93f4FwSGMwkYcvsRHD8egdW5egPMhF" //必须32位 - WX_NOTIFY_ENCODING_AES_KEY = "H60uFIXjyd431hLVhlsKyus3U28RVIzWncey424DqpY" WX_AESKEY_SIZE = 32 WX_ENCODING_KEY_SIZE = 43 WX_RANDENCRYPT_STRLEN = 16 diff --git a/server/payserver/mt/Config.go b/server/payserver/mt/Config.go index e106490..7b904c5 100644 --- a/server/payserver/mt/Config.go +++ b/server/payserver/mt/Config.go @@ -23,11 +23,13 @@ func (this *ConfigTable) GetWxUrl() []string { return strings.Split(this.selfConf.GetWxUrl(), "|") } -/* -func (this *ConfigTable) GetEmailBuyerPassportAddress() string { - return this.selfConf.GetEmailBuyerPassportAddress() +func (this *ConfigTable) GetWxNotifyToken() string { + return this.selfConf.GetWxNotifyToken() +} + +func (this *ConfigTable) GetWxNotifyEncodingAesKey() string { + return this.selfConf.GetWxNotifyEncodingAesKey() } -*/ func (this *ConfigTable) PostInit1() { this.selfConf = this.GetById(int64(0)) diff --git a/server/payserver/mtb/mtb.auto_gen.go b/server/payserver/mtb/mtb.auto_gen.go index 9453a71..f3c8485 100644 --- a/server/payserver/mtb/mtb.auto_gen.go +++ b/server/payserver/mtb/mtb.auto_gen.go @@ -68,6 +68,8 @@ type ConfDb struct { type Config struct { gameapi_url string wx_url string + wx_notify_token string + wx_notify_encoding_aes_key string _flags1_ uint64 _flags2_ uint64 @@ -401,6 +403,22 @@ func (this *Config) HasWxUrl() bool { return (this._flags1_ & (uint64(1) << 2)) > 0 } +func (this *Config) GetWxNotifyToken() string { + return this.wx_notify_token +} + +func (this *Config) HasWxNotifyToken() bool { + return (this._flags1_ & (uint64(1) << 3)) > 0 +} + +func (this *Config) GetWxNotifyEncodingAesKey() string { + return this.wx_notify_encoding_aes_key +} + +func (this *Config) HasWxNotifyEncodingAesKey() bool { + return (this._flags1_ & (uint64(1) << 4)) > 0 +} + func (this *RechargeCurrency) GetCurrencyName() string { return this.currency_name } @@ -675,6 +693,8 @@ func (this *ConfDb) LoadFromKv(kv map[string]interface{}) { func (this *Config) LoadFromKv(kv map[string]interface{}) { f5.ReadMetaTableField(&this.gameapi_url, "gameapi_url", &this._flags1_, 1, kv) f5.ReadMetaTableField(&this.wx_url, "wx_url", &this._flags1_, 2, kv) + f5.ReadMetaTableField(&this.wx_notify_token, "wx_notify_token", &this._flags1_, 3, kv) + f5.ReadMetaTableField(&this.wx_notify_encoding_aes_key, "wx_notify_encoding_aes_key", &this._flags1_, 4, kv) } func (this *RechargeCurrency) LoadFromKv(kv map[string]interface{}) { diff --git a/server/payserver/proto/mt.proto b/server/payserver/proto/mt.proto index 9eefec2..a8046f5 100644 --- a/server/payserver/proto/mt.proto +++ b/server/payserver/proto/mt.proto @@ -57,6 +57,8 @@ message Config { optional string gameapi_url = 1; optional string wx_url = 2; + optional string wx_notify_token = 3; + optional string wx_notify_encoding_aes_key = 4; } message RechargeCurrency diff --git a/server/payserver/router/mainservice/mainservice.go b/server/payserver/router/mainservice/mainservice.go index 0b27ed0..172235f 100644 --- a/server/payserver/router/mainservice/mainservice.go +++ b/server/payserver/router/mainservice/mainservice.go @@ -11,8 +11,8 @@ func (this *MainServiceRouter) InitRouter() { api := v1.ApiGroupApp.MainServiceApiGroup f5.GetApp().GetGinEngine().GET("/api/service/refresh", api.RefreshToken) + // f5.GetApp().GetGinEngine().GET("/wx/tnotify", + // api.WxTNotify) f5.GetApp().GetGinEngine().GET("/wx/tnotify", - api.WxTNotify) - f5.GetApp().GetGinEngine().GET("/wx/notify", api.WxNotifyPurchase) } diff --git a/server/payserver/service/wxpaybase.go b/server/payserver/service/wxpaybase.go index ecfd5c0..2d6a060 100644 --- a/server/payserver/service/wxpaybase.go +++ b/server/payserver/service/wxpaybase.go @@ -11,6 +11,7 @@ import ( "encoding/binary" "encoding/hex" "main/constant" + "main/mt" "sort" "strings" ) @@ -35,7 +36,7 @@ func (wp *wxpay) DecryptMsg(sMsgSignature string, sTimeStamp string, sNonce stri } //4.decode aes - sAesKey := wp.GenAesKeyFromEncodingKey(constant.WX_NOTIFY_ENCODING_AES_KEY) + sAesKey := wp.GenAesKeyFromEncodingKey(mt.Table.Config.GetWxNotifyEncodingAesKey()) if sAesKey == "" { return } @@ -60,7 +61,7 @@ func (wp *wxpay) DecryptMsg(sMsgSignature string, sTimeStamp string, sNonce stri } func (wp *wxpay) ValidateSignature(sMsgSignature string, sTimeStamp string, sNonce string, sEncryptMsg string) bool { - sSignature := wp.ComputeSignature(constant.WX_NOTIFY_TOKEN, sTimeStamp, sNonce, sEncryptMsg) + sSignature := wp.ComputeSignature(mt.Table.Config.GetWxNotifyToken(), sTimeStamp, sNonce, sEncryptMsg) if sSignature == "" { return false } @@ -93,7 +94,7 @@ func (wp *wxpay) ComputeSignature(sToken string, sTimeStamp string, sNonce strin } func (wp *wxpay) GenAesKeyFromEncodingKey(sEncodingKey string) string { - if len(sEncodingKey) != len(constant.WX_NOTIFY_ENCODING_AES_KEY) { + if len(sEncodingKey) != len(mt.Table.Config.GetWxNotifyEncodingAesKey()) { return "" }