From 064f6c306ca487ecc7c54a3ad5ecd6372f0b16c7 Mon Sep 17 00:00:00 2001 From: yangduo Date: Thu, 27 Mar 2025 13:50:28 +0800 Subject: [PATCH] adjust --- bin/payserver/config/config.json | 11 +- bin/payserver/res/wxconfig@wxconfig.json | 9 +- .../api/v1/mainservice/mainservice.go | 88 ++++++---- server/payserver/mt/Config.go | 32 +--- server/payserver/mtb/mtb.auto_gen.go | 150 +++++++++--------- server/payserver/proto/mt.proto | 16 +- .../router/mainservice/mainservice.go | 10 +- server/payserver/service/wxpay.go | 8 +- server/payserver/service/wxpay_prepare.go | 12 +- 9 files changed, 168 insertions(+), 168 deletions(-) diff --git a/bin/payserver/config/config.json b/bin/payserver/config/config.json index 8ec0fc1..ec01ffd 100644 --- a/bin/payserver/config/config.json +++ b/bin/payserver/config/config.json @@ -1,15 +1,8 @@ { "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_notify_token": "dV93f4FwSGMwkYcvsRHD8egdW5egPMhF", - "wx_notify_encoding_aes_key": "t7zDjlqSow7OY4s61q8wp4EabjWnUtTSi5w0KM48O1K", + "wx_api_hosts": "api.weixin.qq.com|api2.weixin.qq.com|sh.api.weixin.qq.com|sz.api.weixin.qq.com|hk.api.weixin.qq.com", "wx_merchant_id": "1509252791", "wx_certificate_sn": "3490963E4E2767E6D8EC99CFE406A2CBEB3CD195", "wx_merchant_api_key": "fgRnUvC5Zu04ir9HQPHWesrsh49ZnfpC", - "wx_merchant_public_key_id": "PUB_KEY_ID_0115092527912025021200388000001392", - "wx_msg_notify_token": "kingsome", - "wx_msg_notify_encoding_aes_key": "2LO2BseGYDjPRK6xSf0Opv3PzWtOq2c3d8NhZHAVYbL", - "wx_nofity_host": "https://payservice-test.kingsome.cn", - "wx_link_title": "点我购买 %s", - "wx_link_description": "完成支付后返回游戏查看" + "wx_merchant_public_key_id": "PUB_KEY_ID_0115092527912025021200388000001392" } diff --git a/bin/payserver/res/wxconfig@wxconfig.json b/bin/payserver/res/wxconfig@wxconfig.json index 39c8327..e450f01 100644 --- a/bin/payserver/res/wxconfig@wxconfig.json +++ b/bin/payserver/res/wxconfig@wxconfig.json @@ -14,6 +14,13 @@ "appsecret": "148509437b331acd15580b279e8511af", "zoneid": "1", "offerid": "1450318181", - "notifyurl": "https://game2004api-test.kingsome.cn/6001/webapp/index.php" + "notifyurl": "https://game2004api-test.kingsome.cn/6001/webapp/index.php", + "wx_notify_token": "dV93f4FwSGMwkYcvsRHD8egdW5egPMhF", + "wx_notify_encoding_aes_key": "t7zDjlqSow7OY4s61q8wp4EabjWnUtTSi5w0KM48O1K", + "wx_msg_notify_token": "kingsome", + "wx_msg_notify_encoding_aes_key": "2LO2BseGYDjPRK6xSf0Opv3PzWtOq2c3d8NhZHAVYbL", + "wx_pay_notify_host": "payservice-test.kingsome.cn", + "wx_pay_link_title": "点我购买 %s", + "wx_pay_link_description": "完成支付后返回游戏查看" } ] \ No newline at end of file diff --git a/server/payserver/api/v1/mainservice/mainservice.go b/server/payserver/api/v1/mainservice/mainservice.go index e363840..f857478 100644 --- a/server/payserver/api/v1/mainservice/mainservice.go +++ b/server/payserver/api/v1/mainservice/mainservice.go @@ -47,13 +47,20 @@ func (this *MainServiceApi) RefreshToken(c *gin.Context) { } func (this *MainServiceApi) WxTNotify(c *gin.Context) { - f5.GetSysLog().Debug("wx test notify:%s", c.Request.URL.RawQuery) + f5.GetSysLog().Debug("wx test notify:%s, %s", c.Param("gameid"), c.Request.URL.RawQuery) signature := c.Query("signature") timestamp := c.Query("timestamp") nonce := c.Query("nonce") echostr := c.Query("echostr") - strs := []string{mt.Table.Config.GetWxNotifyToken(), timestamp, nonce} + gameid := q5.SafeToInt64(c.Param("gameid")) + cfg := mt.Table.Wxconfig.GetById(gameid) + if cfg == nil { + c.String(200, "wrong") + return + } + + strs := []string{cfg.GetWxNotifyToken(), timestamp, nonce} sort.Strings(strs) sb := strings.Builder{} sb.WriteString(strs[0]) @@ -63,17 +70,18 @@ func (this *MainServiceApi) WxTNotify(c *gin.Context) { io.WriteString(m, sb.String()) sign := string(hex.EncodeToString(m.Sum(nil))) - f5.GetSysLog().Debug("wx sign:%s, %s", sign, signature) + f5.GetSysLog().Debug("game:%d, wx sign:%s, %s", gameid, sign, signature) if sign != signature { c.String(200, "wrong") return } + c.String(200, echostr) } func (this *MainServiceApi) WxNotifyPurchase(c *gin.Context) { - f5.GetSysLog().Debug("wx notify purchase:%s", c.Request.URL.RawQuery) + f5.GetSysLog().Debug("wx notify purchase:%s, %s", c.Param("gameid"), c.Request.URL.RawQuery) timestamp := c.Query("timestamp") nonce := c.Query("nonce") @@ -86,6 +94,13 @@ func (this *MainServiceApi) WxNotifyPurchase(c *gin.Context) { ErrMsg: "internal error", } + gameid := q5.SafeToInt64(c.Param("gameid")) + cfg := mt.Table.Wxconfig.GetById(gameid) + if cfg == nil { + c.JSON(200, rspObj) + return + } + msg_signature := c.Query("msg_signature") if msg_signature != "" { postObj := struct { @@ -100,7 +115,7 @@ func (this *MainServiceApi) WxNotifyPurchase(c *gin.Context) { return } - smsg, appid := service.Wxpay.DecryptMsg(msg_signature, timestamp, nonce, postObj.Encrypt, mt.Table.Config.GetWxNotifyToken(), mt.Table.Config.GetWxNotifyEncodingAesKey()) + smsg, appid := service.Wxpay.DecryptMsg(msg_signature, timestamp, nonce, postObj.Encrypt, cfg.GetWxNotifyToken(), cfg.GetWxNotifyEncodingAesKey()) if len(smsg) == 0 || len(appid) == 0 { f5.GetSysLog().Debug("decrypt data error") c.JSON(200, rspObj) @@ -215,6 +230,10 @@ func (this *MainServiceApi) WxNotifyPurchase(c *gin.Context) { } orderModel.GameId = int32(gameid) + orderModel.Status = 1 + + rspObj.ErrorCode = 0 + rspObj.ErrMsg = "Success" f5.GetSysLog().Debug("notify url:%s, %s", appid, notifyurl) nowtimestr := q5.SafeToString(f5.GetApp().GetRealSeconds()) @@ -253,24 +272,30 @@ func (this *MainServiceApi) WxNotifyPurchase(c *gin.Context) { if gamerspObj.ErrCode == 0 { orderModel.Status = 2 - orderModel.UpdateFields([]string{"status"}) - rspObj.ErrorCode = 0 - rspObj.ErrMsg = "Success" } }) + + orderModel.UpdateFields([]string{"status", "gameid"}) } c.JSON(200, rspObj) } func (this *MainServiceApi) WxMsgTNotify(c *gin.Context) { - f5.GetSysLog().Debug("wx msg test notify:%s", c.Request.URL.RawQuery) + f5.GetSysLog().Debug("wx msg test notify:%s, %s", c.Param("gameid"), c.Request.URL.RawQuery) signature := c.Query("signature") timestamp := c.Query("timestamp") nonce := c.Query("nonce") echostr := c.Query("echostr") - strs := []string{mt.Table.Config.GetWxMsgNotifyToken(), timestamp, nonce} + gameid := q5.SafeToInt64(c.Param("gameid")) + cfg := mt.Table.Wxconfig.GetById(gameid) + if cfg == nil { + c.String(200, "wrong") + return + } + + strs := []string{cfg.GetWxMsgNotifyToken(), timestamp, nonce} sort.Strings(strs) sb := strings.Builder{} sb.WriteString(strs[0]) @@ -290,7 +315,7 @@ func (this *MainServiceApi) WxMsgTNotify(c *gin.Context) { } func (this *MainServiceApi) WxMsgNotify(c *gin.Context) { - f5.GetSysLog().Debug("wx msg notify:%s", c.Request.URL.RawQuery) + f5.GetSysLog().Debug("wx msg notify:%s, %s", c.Param("gameid"), c.Request.URL.RawQuery) timestamp := c.Query("timestamp") nonce := c.Query("nonce") @@ -303,6 +328,13 @@ func (this *MainServiceApi) WxMsgNotify(c *gin.Context) { ErrMsg: "internal error", } + gameid := q5.SafeToInt64(c.Param("gameid")) + cfg := mt.Table.Wxconfig.GetById(gameid) + if cfg == nil { + c.JSON(200, rspObj) + return + } + msg_signature := c.Query("msg_signature") if msg_signature != "" { postObj := struct { @@ -316,7 +348,7 @@ func (this *MainServiceApi) WxMsgNotify(c *gin.Context) { return } - smsg, appid := service.Wxpay.DecryptMsg(msg_signature, timestamp, nonce, postObj.Encrypt, mt.Table.Config.GetWxMsgNotifyToken(), mt.Table.Config.GetWxMsgNotifyEncodingAesKey()) + smsg, appid := service.Wxpay.DecryptMsg(msg_signature, timestamp, nonce, postObj.Encrypt, cfg.GetWxMsgNotifyToken(), cfg.GetWxMsgNotifyEncodingAesKey()) if len(smsg) == 0 || len(appid) == 0 { f5.GetSysLog().Debug("decrypt msg data error") c.JSON(200, rspObj) @@ -365,7 +397,7 @@ func (this *MainServiceApi) WxMsgNotify(c *gin.Context) { itemname, _ := service.Wxpay.GetGoodsName(int64(orderModel.GameId), int64(orderModel.ItemId)) // 发给客服系统的clicklink - clickurl := fmt.Sprintf("%s/wx/clicknotify?orderid=%s", mt.Table.Config.GetWxNofityHost(), orderid) + clickurl := fmt.Sprintf("https://%s/wx/clicknotify?orderid=%s", cfg.GetWxPayNotifyHost(), orderid) req := struct { ToUser string `json:"touser"` MsgType string `json:"msgtype"` @@ -379,8 +411,8 @@ func (this *MainServiceApi) WxMsgNotify(c *gin.Context) { Url string `json:"url"` Thumb_url string `json:"thumb_url"` }{ - Title: fmt.Sprintf(mt.Table.Config.GetWxLinkTitle(), itemname), - Description: mt.Table.Config.GetWxLinkDescription(), + Title: fmt.Sprintf(cfg.GetWxPayLinkTitle(), itemname), + Description: cfg.GetWxPayLinkDescription(), Url: clickurl, Thumb_url: thumburl, }, @@ -650,22 +682,20 @@ func (this *MainServiceApi) WxPayNotify(c *gin.Context) { return } - gameid := int64(0) - notifyurl := "" - mt.Table.Wxconfig.Traverse(func(w *mt.Wxconfig) bool { - if w.GetAppid() == string(resObj.AppId) { - gameid = w.GetGameid() - notifyurl = w.GetNotifyurl() - return false - } - return true - }) - + gameid := q5.SafeToInt64(c.Param("gameid")) if gameid == 0 { c.JSON(501, failrspobj) return } + cfg := mt.Table.Wxconfig.GetById(gameid) + if cfg == nil || cfg.GetAppid() != resObj.AppId { + c.JSON(501, failrspobj) + return + } + + notifyurl := cfg.GetNotifyurl() + orderModel := new(model.InAppOrder) if err, found := orderModel.FindByOrderId(resObj.OrderId); err != nil || !found { c.JSON(501, failrspobj) @@ -698,6 +728,8 @@ func (this *MainServiceApi) WxPayNotify(c *gin.Context) { f5.GetSysLog().Debug("notify url:%d, %s", gameid, notifyurl) fields := []string{"status", "sp_orderid"} + orderModel.Status = 1 + orderModel.SpOrderId = resObj.TransId if len(notifyurl) > 0 { goodsidstr := q5.SafeToString(orderModel.ItemId) totalamountstr := q5.SafeToString(resObj.Amount.Total) @@ -738,17 +770,13 @@ func (this *MainServiceApi) WxPayNotify(c *gin.Context) { if gamerspObj.ErrCode == 0 { orderModel.Status = 2 - } else { - orderModel.Status = 1 } }) } else { - orderModel.Status = 1 count, _ := service.Wxpay.GetGoodsCount(gameid, int64(orderModel.ItemId)) orderModel.SpAmount = int32(count) fields = append(fields, "sp_amount") } - orderModel.SpOrderId = resObj.TransId orderModel.UpdateFields(fields) c.String(200, "") diff --git a/server/payserver/mt/Config.go b/server/payserver/mt/Config.go index a6c4c48..d6a554f 100644 --- a/server/payserver/mt/Config.go +++ b/server/payserver/mt/Config.go @@ -19,16 +19,8 @@ func (ct *ConfigTable) GetGameApiUrl() string { return ct.selfConf.GetGameapiUrl() } -func (ct *ConfigTable) GetWxUrl() []string { - return strings.Split(ct.selfConf.GetWxUrl(), "|") -} - -func (ct *ConfigTable) GetWxNotifyToken() string { - return ct.selfConf.GetWxNotifyToken() -} - -func (ct *ConfigTable) GetWxNotifyEncodingAesKey() string { - return ct.selfConf.GetWxNotifyEncodingAesKey() +func (ct *ConfigTable) GetWxApiHosts() []string { + return strings.Split(ct.selfConf.GetWxApiHosts(), "|") } func (ct *ConfigTable) GetWxMerchantId() string { @@ -43,26 +35,6 @@ func (ct *ConfigTable) GetWxMerchantApiKey() string { return ct.selfConf.GetWxMerchantApiKey() } -func (ct *ConfigTable) GetWxMsgNotifyToken() string { - return ct.selfConf.GetWxMsgNotifyToken() -} - -func (ct *ConfigTable) GetWxMsgNotifyEncodingAesKey() string { - return ct.selfConf.GetWxMsgNotifyEncodingAesKey() -} - -func (ct *ConfigTable) GetWxNofityHost() string { - return ct.selfConf.GetWxNofityHost() -} - -func (ct *ConfigTable) GetWxLinkTitle() string { - return ct.selfConf.GetWxLinkTitle() -} - -func (ct *ConfigTable) GetWxLinkDescription() string { - return ct.selfConf.GetWxLinkDescription() -} - func (ct *ConfigTable) GetWxMerchantPublicKeyId() string { return ct.selfConf.GetWxMerchantPublicKeyId() } diff --git a/server/payserver/mtb/mtb.auto_gen.go b/server/payserver/mtb/mtb.auto_gen.go index 9344efa..c4f4558 100644 --- a/server/payserver/mtb/mtb.auto_gen.go +++ b/server/payserver/mtb/mtb.auto_gen.go @@ -67,17 +67,10 @@ type ConfDb struct { type Config struct { gameapi_url string - wx_url string - wx_notify_token string - wx_notify_encoding_aes_key string + wx_api_hosts string wx_merchant_id string wx_certificate_sn string wx_merchant_api_key string - wx_msg_notify_token string - wx_msg_notify_encoding_aes_key string - wx_nofity_host string - wx_link_title string - wx_link_description string wx_merchant_public_key_id string _flags1_ uint64 @@ -131,6 +124,13 @@ type Wxconfig struct { zoneid string offerid string notifyurl string + wx_notify_token string + wx_notify_encoding_aes_key string + wx_msg_notify_token string + wx_msg_notify_encoding_aes_key string + wx_pay_notify_host string + wx_pay_link_title string + wx_pay_link_description string _flags1_ uint64 _flags2_ uint64 @@ -404,30 +404,14 @@ func (this *Config) HasGameapiUrl() bool { return (this._flags1_ & (uint64(1) << 1)) > 0 } -func (this *Config) GetWxUrl() string { - return this.wx_url +func (this *Config) GetWxApiHosts() string { + return this.wx_api_hosts } -func (this *Config) HasWxUrl() bool { +func (this *Config) HasWxApiHosts() 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 *Config) GetWxMerchantId() string { return this.wx_merchant_id } @@ -452,46 +436,6 @@ func (this *Config) HasWxMerchantApiKey() bool { return (this._flags1_ & (uint64(1) << 7)) > 0 } -func (this *Config) GetWxMsgNotifyToken() string { - return this.wx_msg_notify_token -} - -func (this *Config) HasWxMsgNotifyToken() bool { - return (this._flags1_ & (uint64(1) << 8)) > 0 -} - -func (this *Config) GetWxMsgNotifyEncodingAesKey() string { - return this.wx_msg_notify_encoding_aes_key -} - -func (this *Config) HasWxMsgNotifyEncodingAesKey() bool { - return (this._flags1_ & (uint64(1) << 9)) > 0 -} - -func (this *Config) GetWxNofityHost() string { - return this.wx_nofity_host -} - -func (this *Config) HasWxNofityHost() bool { - return (this._flags1_ & (uint64(1) << 10)) > 0 -} - -func (this *Config) GetWxLinkTitle() string { - return this.wx_link_title -} - -func (this *Config) HasWxLinkTitle() bool { - return (this._flags1_ & (uint64(1) << 11)) > 0 -} - -func (this *Config) GetWxLinkDescription() string { - return this.wx_link_description -} - -func (this *Config) HasWxLinkDescription() bool { - return (this._flags1_ & (uint64(1) << 12)) > 0 -} - func (this *Config) GetWxMerchantPublicKeyId() string { return this.wx_merchant_public_key_id } @@ -676,6 +620,62 @@ func (this *Wxconfig) HasNotifyurl() bool { return (this._flags1_ & (uint64(1) << 7)) > 0 } +func (this *Wxconfig) GetWxNotifyToken() string { + return this.wx_notify_token +} + +func (this *Wxconfig) HasWxNotifyToken() bool { + return (this._flags1_ & (uint64(1) << 8)) > 0 +} + +func (this *Wxconfig) GetWxNotifyEncodingAesKey() string { + return this.wx_notify_encoding_aes_key +} + +func (this *Wxconfig) HasWxNotifyEncodingAesKey() bool { + return (this._flags1_ & (uint64(1) << 9)) > 0 +} + +func (this *Wxconfig) GetWxMsgNotifyToken() string { + return this.wx_msg_notify_token +} + +func (this *Wxconfig) HasWxMsgNotifyToken() bool { + return (this._flags1_ & (uint64(1) << 10)) > 0 +} + +func (this *Wxconfig) GetWxMsgNotifyEncodingAesKey() string { + return this.wx_msg_notify_encoding_aes_key +} + +func (this *Wxconfig) HasWxMsgNotifyEncodingAesKey() bool { + return (this._flags1_ & (uint64(1) << 11)) > 0 +} + +func (this *Wxconfig) GetWxPayNotifyHost() string { + return this.wx_pay_notify_host +} + +func (this *Wxconfig) HasWxPayNotifyHost() bool { + return (this._flags1_ & (uint64(1) << 12)) > 0 +} + +func (this *Wxconfig) GetWxPayLinkTitle() string { + return this.wx_pay_link_title +} + +func (this *Wxconfig) HasWxPayLinkTitle() bool { + return (this._flags1_ & (uint64(1) << 13)) > 0 +} + +func (this *Wxconfig) GetWxPayLinkDescription() string { + return this.wx_pay_link_description +} + +func (this *Wxconfig) HasWxPayLinkDescription() bool { + return (this._flags1_ & (uint64(1) << 14)) > 0 +} + func (this *LoginRedis) GetHost() string { return this.host } @@ -773,17 +773,10 @@ 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) + f5.ReadMetaTableField(&this.wx_api_hosts, "wx_api_hosts", &this._flags1_, 2, kv) f5.ReadMetaTableField(&this.wx_merchant_id, "wx_merchant_id", &this._flags1_, 5, kv) f5.ReadMetaTableField(&this.wx_certificate_sn, "wx_certificate_sn", &this._flags1_, 6, kv) f5.ReadMetaTableField(&this.wx_merchant_api_key, "wx_merchant_api_key", &this._flags1_, 7, kv) - f5.ReadMetaTableField(&this.wx_msg_notify_token, "wx_msg_notify_token", &this._flags1_, 8, kv) - f5.ReadMetaTableField(&this.wx_msg_notify_encoding_aes_key, "wx_msg_notify_encoding_aes_key", &this._flags1_, 9, kv) - f5.ReadMetaTableField(&this.wx_nofity_host, "wx_nofity_host", &this._flags1_, 10, kv) - f5.ReadMetaTableField(&this.wx_link_title, "wx_link_title", &this._flags1_, 11, kv) - f5.ReadMetaTableField(&this.wx_link_description, "wx_link_description", &this._flags1_, 12, kv) f5.ReadMetaTableField(&this.wx_merchant_public_key_id, "wx_merchant_public_key_id", &this._flags1_, 13, kv) } @@ -822,6 +815,13 @@ func (this *Wxconfig) LoadFromKv(kv map[string]interface{}) { f5.ReadMetaTableField(&this.zoneid, "zoneid", &this._flags1_, 5, kv) f5.ReadMetaTableField(&this.offerid, "offerid", &this._flags1_, 6, kv) f5.ReadMetaTableField(&this.notifyurl, "notifyurl", &this._flags1_, 7, kv) + f5.ReadMetaTableField(&this.wx_notify_token, "wx_notify_token", &this._flags1_, 8, kv) + f5.ReadMetaTableField(&this.wx_notify_encoding_aes_key, "wx_notify_encoding_aes_key", &this._flags1_, 9, kv) + f5.ReadMetaTableField(&this.wx_msg_notify_token, "wx_msg_notify_token", &this._flags1_, 10, kv) + f5.ReadMetaTableField(&this.wx_msg_notify_encoding_aes_key, "wx_msg_notify_encoding_aes_key", &this._flags1_, 11, kv) + f5.ReadMetaTableField(&this.wx_pay_notify_host, "wx_pay_notify_host", &this._flags1_, 12, kv) + f5.ReadMetaTableField(&this.wx_pay_link_title, "wx_pay_link_title", &this._flags1_, 13, kv) + f5.ReadMetaTableField(&this.wx_pay_link_description, "wx_pay_link_description", &this._flags1_, 14, kv) } func (this *LoginRedis) LoadFromKv(kv map[string]interface{}) { diff --git a/server/payserver/proto/mt.proto b/server/payserver/proto/mt.proto index 6d6e75f..7d6bd58 100644 --- a/server/payserver/proto/mt.proto +++ b/server/payserver/proto/mt.proto @@ -56,17 +56,10 @@ message ConfDb 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; + optional string wx_api_hosts = 2; optional string wx_merchant_id = 5; optional string wx_certificate_sn = 6; optional string wx_merchant_api_key = 7; - optional string wx_msg_notify_token = 8; - optional string wx_msg_notify_encoding_aes_key = 9; - optional string wx_nofity_host = 10; - optional string wx_link_title = 11; - optional string wx_link_description = 12; optional string wx_merchant_public_key_id = 13; } @@ -110,6 +103,13 @@ message Wxconfig optional string zoneid = 5; optional string offerid = 6; optional string notifyurl = 7; + optional string wx_notify_token = 8; + optional string wx_notify_encoding_aes_key = 9; + optional string wx_msg_notify_token = 10; + optional string wx_msg_notify_encoding_aes_key = 11; + optional string wx_pay_notify_host = 12; + optional string wx_pay_link_title = 13; + optional string wx_pay_link_description = 14; } message LoginRedis diff --git a/server/payserver/router/mainservice/mainservice.go b/server/payserver/router/mainservice/mainservice.go index 1ed7567..0f98710 100644 --- a/server/payserver/router/mainservice/mainservice.go +++ b/server/payserver/router/mainservice/mainservice.go @@ -11,16 +11,16 @@ func (this *MainServiceRouter) InitRouter() { api := v1.ApiGroupApp.MainServiceApiGroup f5.GetApp().GetGinEngine().GET("/api/service/refresh", api.RefreshToken) - f5.GetApp().GetGinEngine().GET("/wx/tnotify", + f5.GetApp().GetGinEngine().GET("/wx/purnotify/:gameid", api.WxTNotify) - f5.GetApp().GetGinEngine().POST("/wx/tnotify", + f5.GetApp().GetGinEngine().POST("/wx/purnotify/:gameid", api.WxNotifyPurchase) - f5.GetApp().GetGinEngine().GET("/wx/msgnotify", + f5.GetApp().GetGinEngine().GET("/wx/msgnotify/:gameid", api.WxMsgTNotify) - f5.GetApp().GetGinEngine().POST("/wx/msgnotify", + f5.GetApp().GetGinEngine().POST("/wx/msgnotify/:gameid", api.WxMsgNotify) f5.GetApp().GetGinEngine().GET("/wx/clicknotify", api.WxClickNotify) - f5.GetApp().GetGinEngine().POST("/wx/paynotify", + f5.GetApp().GetGinEngine().POST("/wx/paynotify/:gameid", api.WxPayNotify) } diff --git a/server/payserver/service/wxpay.go b/server/payserver/service/wxpay.go index f6a07e5..a84f668 100644 --- a/server/payserver/service/wxpay.go +++ b/server/payserver/service/wxpay.go @@ -166,7 +166,7 @@ func (wp *wxpay) freshAccessToken(gameid int64) (token string) { "appid": cfg.GetAppid(), "secret": cfg.GetAppsecret(), } - urls := mt.Table.Config.GetWxUrl() + urls := mt.Table.Config.GetWxApiHosts() queryuri := "/cgi-bin/token" for _, wxhost := range urls { url := "https://" + wxhost + queryuri @@ -293,7 +293,7 @@ func (wp *wxpay) QueryBalance(openid string, gameid int64, userip string, sessio json.Unmarshal(data, ¶ms) sendRequest := false - urls := mt.Table.Config.GetWxUrl() + urls := mt.Table.Config.GetWxApiHosts() for _, wxhost := range urls { url := "https://" + wxhost + queryuri f5.GetHttpCliMgr().SendGoStylePost( @@ -374,7 +374,7 @@ func (wp *wxpay) QueryPay(openid string, gameid int64, userip string, sessionkey json.Unmarshal(data, ¶ms) sendRequest := false - urls := mt.Table.Config.GetWxUrl() + urls := mt.Table.Config.GetWxApiHosts() for _, wxhost := range urls { url := "https://" + wxhost + queryuri f5.GetHttpCliMgr().SendGoStylePost( @@ -450,7 +450,7 @@ func (wp *wxpay) QueryPurchase(openid string, gameid int64, userip string, sessi json.Unmarshal(data, ¶ms) sendRequest := false - urls := mt.Table.Config.GetWxUrl() + urls := mt.Table.Config.GetWxApiHosts() for _, wxhost := range urls { url := "https://" + wxhost + queryuri f5.GetHttpCliMgr().SendGoStylePost( diff --git a/server/payserver/service/wxpay_prepare.go b/server/payserver/service/wxpay_prepare.go index d058707..b739708 100644 --- a/server/payserver/service/wxpay_prepare.go +++ b/server/payserver/service/wxpay_prepare.go @@ -77,8 +77,8 @@ func (wp *wxpay) checkGameMediaId() { if info == nil { info = &mediaidInfo{} } - - if q5.GetDaySeconds(info.time, 8) == q5.GetDaySeconds(nowtime, 8) && len(info.mediaId) != 0 { + + if q5.GetDaySeconds(info.time, 8) == q5.GetDaySeconds(nowtime, 8) && len(info.mediaId) > 0 { return true } @@ -112,7 +112,7 @@ func (wp *wxpay) checkGameMediaId() { writer.Close() desurl := "https://api.weixin.qq.com/cgi-bin/media/upload" - urls := mt.Table.Config.GetWxUrl() + urls := mt.Table.Config.GetWxApiHosts() if len(urls) > 0 { desurl = fmt.Sprintf("https://%s/cgi-bin/media/upload", urls[0]) } @@ -162,7 +162,7 @@ func (wp *wxpay) GenThumburl(gameid int64) (thumburl string) { token := wp.getAccessToken(gameid) pmediaid, ok := wp.mediaInfo.Load(gameid) if ok { - urls := mt.Table.Config.GetWxUrl() + urls := mt.Table.Config.GetWxApiHosts() if len(urls) > 0 { thumburl = fmt.Sprintf("https://%s/cgi-bin/media/get?access_token=%s&type=image&media_id=%s", urls[0], token, *pmediaid) } @@ -175,7 +175,7 @@ func (wp *wxpay) GenThumburl(gameid int64) (thumburl string) { func (wp *wxpay) GenSendWxMsgUrl(gameid int64) (msgurl string) { token := wp.getAccessToken(gameid) - urls := mt.Table.Config.GetWxUrl() + urls := mt.Table.Config.GetWxApiHosts() if len(urls) > 0 { msgurl = fmt.Sprintf("https://%s/cgi-bin/message/custom/send?access_token=%s", urls[0], token) } @@ -204,7 +204,7 @@ func (wp *wxpay) GetPrepayInfoStr(openid string, gameid int64, userip string, or Description: core.String(info.Name), OutTradeNo: core.String(orderid), Attach: core.String(userip), - NotifyUrl: core.String(mt.Table.Config.GetWxNofityHost() + "/wx/paynotify"), + NotifyUrl: core.String(fmt.Sprintf("https://%s/wx/paynotify/%d", cfg.GetWxPayNotifyHost(), gameid)), Amount: &jsapi.Amount{ Total: core.Int64(info.Price), },