adjust
This commit is contained in:
parent
47a804e0a8
commit
7b13120c48
@ -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"
|
||||
}
|
||||
|
@ -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])
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
@ -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{}) {
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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 ""
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user