This commit is contained in:
yangduo 2025-03-27 13:50:28 +08:00
parent 04521ba59a
commit 064f6c306c
9 changed files with 168 additions and 168 deletions

View File

@ -1,15 +1,8 @@
{ {
"gameapi_url": "https://game2006api-test.kingsome.cn", "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_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_notify_token": "dV93f4FwSGMwkYcvsRHD8egdW5egPMhF",
"wx_notify_encoding_aes_key": "t7zDjlqSow7OY4s61q8wp4EabjWnUtTSi5w0KM48O1K",
"wx_merchant_id": "1509252791", "wx_merchant_id": "1509252791",
"wx_certificate_sn": "3490963E4E2767E6D8EC99CFE406A2CBEB3CD195", "wx_certificate_sn": "3490963E4E2767E6D8EC99CFE406A2CBEB3CD195",
"wx_merchant_api_key": "fgRnUvC5Zu04ir9HQPHWesrsh49ZnfpC", "wx_merchant_api_key": "fgRnUvC5Zu04ir9HQPHWesrsh49ZnfpC",
"wx_merchant_public_key_id": "PUB_KEY_ID_0115092527912025021200388000001392", "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": "完成支付后返回游戏查看"
} }

View File

@ -14,6 +14,13 @@
"appsecret": "148509437b331acd15580b279e8511af", "appsecret": "148509437b331acd15580b279e8511af",
"zoneid": "1", "zoneid": "1",
"offerid": "1450318181", "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": "完成支付后返回游戏查看"
} }
] ]

View File

@ -47,13 +47,20 @@ func (this *MainServiceApi) RefreshToken(c *gin.Context) {
} }
func (this *MainServiceApi) WxTNotify(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") signature := c.Query("signature")
timestamp := c.Query("timestamp") timestamp := c.Query("timestamp")
nonce := c.Query("nonce") nonce := c.Query("nonce")
echostr := c.Query("echostr") 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) sort.Strings(strs)
sb := strings.Builder{} sb := strings.Builder{}
sb.WriteString(strs[0]) sb.WriteString(strs[0])
@ -63,17 +70,18 @@ func (this *MainServiceApi) WxTNotify(c *gin.Context) {
io.WriteString(m, sb.String()) io.WriteString(m, sb.String())
sign := string(hex.EncodeToString(m.Sum(nil))) 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 { if sign != signature {
c.String(200, "wrong") c.String(200, "wrong")
return return
} }
c.String(200, echostr) c.String(200, echostr)
} }
func (this *MainServiceApi) WxNotifyPurchase(c *gin.Context) { 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") timestamp := c.Query("timestamp")
nonce := c.Query("nonce") nonce := c.Query("nonce")
@ -86,6 +94,13 @@ func (this *MainServiceApi) WxNotifyPurchase(c *gin.Context) {
ErrMsg: "internal error", 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") msg_signature := c.Query("msg_signature")
if msg_signature != "" { if msg_signature != "" {
postObj := struct { postObj := struct {
@ -100,7 +115,7 @@ func (this *MainServiceApi) WxNotifyPurchase(c *gin.Context) {
return 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 { if len(smsg) == 0 || len(appid) == 0 {
f5.GetSysLog().Debug("decrypt data error") f5.GetSysLog().Debug("decrypt data error")
c.JSON(200, rspObj) c.JSON(200, rspObj)
@ -215,6 +230,10 @@ func (this *MainServiceApi) WxNotifyPurchase(c *gin.Context) {
} }
orderModel.GameId = int32(gameid) orderModel.GameId = int32(gameid)
orderModel.Status = 1
rspObj.ErrorCode = 0
rspObj.ErrMsg = "Success"
f5.GetSysLog().Debug("notify url:%s, %s", appid, notifyurl) f5.GetSysLog().Debug("notify url:%s, %s", appid, notifyurl)
nowtimestr := q5.SafeToString(f5.GetApp().GetRealSeconds()) nowtimestr := q5.SafeToString(f5.GetApp().GetRealSeconds())
@ -253,24 +272,30 @@ func (this *MainServiceApi) WxNotifyPurchase(c *gin.Context) {
if gamerspObj.ErrCode == 0 { if gamerspObj.ErrCode == 0 {
orderModel.Status = 2 orderModel.Status = 2
orderModel.UpdateFields([]string{"status"})
rspObj.ErrorCode = 0
rspObj.ErrMsg = "Success"
} }
}) })
orderModel.UpdateFields([]string{"status", "gameid"})
} }
c.JSON(200, rspObj) c.JSON(200, rspObj)
} }
func (this *MainServiceApi) WxMsgTNotify(c *gin.Context) { 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") signature := c.Query("signature")
timestamp := c.Query("timestamp") timestamp := c.Query("timestamp")
nonce := c.Query("nonce") nonce := c.Query("nonce")
echostr := c.Query("echostr") 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) sort.Strings(strs)
sb := strings.Builder{} sb := strings.Builder{}
sb.WriteString(strs[0]) sb.WriteString(strs[0])
@ -290,7 +315,7 @@ func (this *MainServiceApi) WxMsgTNotify(c *gin.Context) {
} }
func (this *MainServiceApi) WxMsgNotify(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") timestamp := c.Query("timestamp")
nonce := c.Query("nonce") nonce := c.Query("nonce")
@ -303,6 +328,13 @@ func (this *MainServiceApi) WxMsgNotify(c *gin.Context) {
ErrMsg: "internal error", 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") msg_signature := c.Query("msg_signature")
if msg_signature != "" { if msg_signature != "" {
postObj := struct { postObj := struct {
@ -316,7 +348,7 @@ func (this *MainServiceApi) WxMsgNotify(c *gin.Context) {
return 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 { if len(smsg) == 0 || len(appid) == 0 {
f5.GetSysLog().Debug("decrypt msg data error") f5.GetSysLog().Debug("decrypt msg data error")
c.JSON(200, rspObj) 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)) itemname, _ := service.Wxpay.GetGoodsName(int64(orderModel.GameId), int64(orderModel.ItemId))
// 发给客服系统的clicklink // 发给客服系统的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 { req := struct {
ToUser string `json:"touser"` ToUser string `json:"touser"`
MsgType string `json:"msgtype"` MsgType string `json:"msgtype"`
@ -379,8 +411,8 @@ func (this *MainServiceApi) WxMsgNotify(c *gin.Context) {
Url string `json:"url"` Url string `json:"url"`
Thumb_url string `json:"thumb_url"` Thumb_url string `json:"thumb_url"`
}{ }{
Title: fmt.Sprintf(mt.Table.Config.GetWxLinkTitle(), itemname), Title: fmt.Sprintf(cfg.GetWxPayLinkTitle(), itemname),
Description: mt.Table.Config.GetWxLinkDescription(), Description: cfg.GetWxPayLinkDescription(),
Url: clickurl, Url: clickurl,
Thumb_url: thumburl, Thumb_url: thumburl,
}, },
@ -650,22 +682,20 @@ func (this *MainServiceApi) WxPayNotify(c *gin.Context) {
return return
} }
gameid := int64(0) gameid := q5.SafeToInt64(c.Param("gameid"))
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
})
if gameid == 0 { if gameid == 0 {
c.JSON(501, failrspobj) c.JSON(501, failrspobj)
return 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) orderModel := new(model.InAppOrder)
if err, found := orderModel.FindByOrderId(resObj.OrderId); err != nil || !found { if err, found := orderModel.FindByOrderId(resObj.OrderId); err != nil || !found {
c.JSON(501, failrspobj) c.JSON(501, failrspobj)
@ -698,6 +728,8 @@ func (this *MainServiceApi) WxPayNotify(c *gin.Context) {
f5.GetSysLog().Debug("notify url:%d, %s", gameid, notifyurl) f5.GetSysLog().Debug("notify url:%d, %s", gameid, notifyurl)
fields := []string{"status", "sp_orderid"} fields := []string{"status", "sp_orderid"}
orderModel.Status = 1
orderModel.SpOrderId = resObj.TransId
if len(notifyurl) > 0 { if len(notifyurl) > 0 {
goodsidstr := q5.SafeToString(orderModel.ItemId) goodsidstr := q5.SafeToString(orderModel.ItemId)
totalamountstr := q5.SafeToString(resObj.Amount.Total) totalamountstr := q5.SafeToString(resObj.Amount.Total)
@ -738,17 +770,13 @@ func (this *MainServiceApi) WxPayNotify(c *gin.Context) {
if gamerspObj.ErrCode == 0 { if gamerspObj.ErrCode == 0 {
orderModel.Status = 2 orderModel.Status = 2
} else {
orderModel.Status = 1
} }
}) })
} else { } else {
orderModel.Status = 1
count, _ := service.Wxpay.GetGoodsCount(gameid, int64(orderModel.ItemId)) count, _ := service.Wxpay.GetGoodsCount(gameid, int64(orderModel.ItemId))
orderModel.SpAmount = int32(count) orderModel.SpAmount = int32(count)
fields = append(fields, "sp_amount") fields = append(fields, "sp_amount")
} }
orderModel.SpOrderId = resObj.TransId
orderModel.UpdateFields(fields) orderModel.UpdateFields(fields)
c.String(200, "") c.String(200, "")

View File

@ -19,16 +19,8 @@ func (ct *ConfigTable) GetGameApiUrl() string {
return ct.selfConf.GetGameapiUrl() return ct.selfConf.GetGameapiUrl()
} }
func (ct *ConfigTable) GetWxUrl() []string { func (ct *ConfigTable) GetWxApiHosts() []string {
return strings.Split(ct.selfConf.GetWxUrl(), "|") return strings.Split(ct.selfConf.GetWxApiHosts(), "|")
}
func (ct *ConfigTable) GetWxNotifyToken() string {
return ct.selfConf.GetWxNotifyToken()
}
func (ct *ConfigTable) GetWxNotifyEncodingAesKey() string {
return ct.selfConf.GetWxNotifyEncodingAesKey()
} }
func (ct *ConfigTable) GetWxMerchantId() string { func (ct *ConfigTable) GetWxMerchantId() string {
@ -43,26 +35,6 @@ func (ct *ConfigTable) GetWxMerchantApiKey() string {
return ct.selfConf.GetWxMerchantApiKey() 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 { func (ct *ConfigTable) GetWxMerchantPublicKeyId() string {
return ct.selfConf.GetWxMerchantPublicKeyId() return ct.selfConf.GetWxMerchantPublicKeyId()
} }

View File

@ -67,17 +67,10 @@ type ConfDb struct {
type Config struct { type Config struct {
gameapi_url string gameapi_url string
wx_url string wx_api_hosts string
wx_notify_token string
wx_notify_encoding_aes_key string
wx_merchant_id string wx_merchant_id string
wx_certificate_sn string wx_certificate_sn string
wx_merchant_api_key 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 wx_merchant_public_key_id string
_flags1_ uint64 _flags1_ uint64
@ -131,6 +124,13 @@ type Wxconfig struct {
zoneid string zoneid string
offerid string offerid string
notifyurl 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 _flags1_ uint64
_flags2_ uint64 _flags2_ uint64
@ -404,30 +404,14 @@ func (this *Config) HasGameapiUrl() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0 return (this._flags1_ & (uint64(1) << 1)) > 0
} }
func (this *Config) GetWxUrl() string { func (this *Config) GetWxApiHosts() string {
return this.wx_url return this.wx_api_hosts
} }
func (this *Config) HasWxUrl() bool { func (this *Config) HasWxApiHosts() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0 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 { func (this *Config) GetWxMerchantId() string {
return this.wx_merchant_id return this.wx_merchant_id
} }
@ -452,46 +436,6 @@ func (this *Config) HasWxMerchantApiKey() bool {
return (this._flags1_ & (uint64(1) << 7)) > 0 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 { func (this *Config) GetWxMerchantPublicKeyId() string {
return this.wx_merchant_public_key_id return this.wx_merchant_public_key_id
} }
@ -676,6 +620,62 @@ func (this *Wxconfig) HasNotifyurl() bool {
return (this._flags1_ & (uint64(1) << 7)) > 0 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 { func (this *LoginRedis) GetHost() string {
return this.host return this.host
} }
@ -773,17 +773,10 @@ func (this *ConfDb) LoadFromKv(kv map[string]interface{}) {
func (this *Config) 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.gameapi_url, "gameapi_url", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.wx_url, "wx_url", &this._flags1_, 2, kv) f5.ReadMetaTableField(&this.wx_api_hosts, "wx_api_hosts", &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_merchant_id, "wx_merchant_id", &this._flags1_, 5, 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_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_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) 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.zoneid, "zoneid", &this._flags1_, 5, kv)
f5.ReadMetaTableField(&this.offerid, "offerid", &this._flags1_, 6, kv) f5.ReadMetaTableField(&this.offerid, "offerid", &this._flags1_, 6, kv)
f5.ReadMetaTableField(&this.notifyurl, "notifyurl", &this._flags1_, 7, 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{}) { func (this *LoginRedis) LoadFromKv(kv map[string]interface{}) {

View File

@ -56,17 +56,10 @@ message ConfDb
message Config message Config
{ {
optional string gameapi_url = 1; optional string gameapi_url = 1;
optional string wx_url = 2; optional string wx_api_hosts = 2;
optional string wx_notify_token = 3;
optional string wx_notify_encoding_aes_key = 4;
optional string wx_merchant_id = 5; optional string wx_merchant_id = 5;
optional string wx_certificate_sn = 6; optional string wx_certificate_sn = 6;
optional string wx_merchant_api_key = 7; 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; optional string wx_merchant_public_key_id = 13;
} }
@ -110,6 +103,13 @@ message Wxconfig
optional string zoneid = 5; optional string zoneid = 5;
optional string offerid = 6; optional string offerid = 6;
optional string notifyurl = 7; 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 message LoginRedis

View File

@ -11,16 +11,16 @@ func (this *MainServiceRouter) InitRouter() {
api := v1.ApiGroupApp.MainServiceApiGroup api := v1.ApiGroupApp.MainServiceApiGroup
f5.GetApp().GetGinEngine().GET("/api/service/refresh", f5.GetApp().GetGinEngine().GET("/api/service/refresh",
api.RefreshToken) api.RefreshToken)
f5.GetApp().GetGinEngine().GET("/wx/tnotify", f5.GetApp().GetGinEngine().GET("/wx/purnotify/:gameid",
api.WxTNotify) api.WxTNotify)
f5.GetApp().GetGinEngine().POST("/wx/tnotify", f5.GetApp().GetGinEngine().POST("/wx/purnotify/:gameid",
api.WxNotifyPurchase) api.WxNotifyPurchase)
f5.GetApp().GetGinEngine().GET("/wx/msgnotify", f5.GetApp().GetGinEngine().GET("/wx/msgnotify/:gameid",
api.WxMsgTNotify) api.WxMsgTNotify)
f5.GetApp().GetGinEngine().POST("/wx/msgnotify", f5.GetApp().GetGinEngine().POST("/wx/msgnotify/:gameid",
api.WxMsgNotify) api.WxMsgNotify)
f5.GetApp().GetGinEngine().GET("/wx/clicknotify", f5.GetApp().GetGinEngine().GET("/wx/clicknotify",
api.WxClickNotify) api.WxClickNotify)
f5.GetApp().GetGinEngine().POST("/wx/paynotify", f5.GetApp().GetGinEngine().POST("/wx/paynotify/:gameid",
api.WxPayNotify) api.WxPayNotify)
} }

View File

@ -166,7 +166,7 @@ func (wp *wxpay) freshAccessToken(gameid int64) (token string) {
"appid": cfg.GetAppid(), "appid": cfg.GetAppid(),
"secret": cfg.GetAppsecret(), "secret": cfg.GetAppsecret(),
} }
urls := mt.Table.Config.GetWxUrl() urls := mt.Table.Config.GetWxApiHosts()
queryuri := "/cgi-bin/token" queryuri := "/cgi-bin/token"
for _, wxhost := range urls { for _, wxhost := range urls {
url := "https://" + wxhost + queryuri url := "https://" + wxhost + queryuri
@ -293,7 +293,7 @@ func (wp *wxpay) QueryBalance(openid string, gameid int64, userip string, sessio
json.Unmarshal(data, &params) json.Unmarshal(data, &params)
sendRequest := false sendRequest := false
urls := mt.Table.Config.GetWxUrl() urls := mt.Table.Config.GetWxApiHosts()
for _, wxhost := range urls { for _, wxhost := range urls {
url := "https://" + wxhost + queryuri url := "https://" + wxhost + queryuri
f5.GetHttpCliMgr().SendGoStylePost( f5.GetHttpCliMgr().SendGoStylePost(
@ -374,7 +374,7 @@ func (wp *wxpay) QueryPay(openid string, gameid int64, userip string, sessionkey
json.Unmarshal(data, &params) json.Unmarshal(data, &params)
sendRequest := false sendRequest := false
urls := mt.Table.Config.GetWxUrl() urls := mt.Table.Config.GetWxApiHosts()
for _, wxhost := range urls { for _, wxhost := range urls {
url := "https://" + wxhost + queryuri url := "https://" + wxhost + queryuri
f5.GetHttpCliMgr().SendGoStylePost( f5.GetHttpCliMgr().SendGoStylePost(
@ -450,7 +450,7 @@ func (wp *wxpay) QueryPurchase(openid string, gameid int64, userip string, sessi
json.Unmarshal(data, &params) json.Unmarshal(data, &params)
sendRequest := false sendRequest := false
urls := mt.Table.Config.GetWxUrl() urls := mt.Table.Config.GetWxApiHosts()
for _, wxhost := range urls { for _, wxhost := range urls {
url := "https://" + wxhost + queryuri url := "https://" + wxhost + queryuri
f5.GetHttpCliMgr().SendGoStylePost( f5.GetHttpCliMgr().SendGoStylePost(

View File

@ -78,7 +78,7 @@ func (wp *wxpay) checkGameMediaId() {
info = &mediaidInfo{} 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 return true
} }
@ -112,7 +112,7 @@ func (wp *wxpay) checkGameMediaId() {
writer.Close() writer.Close()
desurl := "https://api.weixin.qq.com/cgi-bin/media/upload" desurl := "https://api.weixin.qq.com/cgi-bin/media/upload"
urls := mt.Table.Config.GetWxUrl() urls := mt.Table.Config.GetWxApiHosts()
if len(urls) > 0 { if len(urls) > 0 {
desurl = fmt.Sprintf("https://%s/cgi-bin/media/upload", 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) token := wp.getAccessToken(gameid)
pmediaid, ok := wp.mediaInfo.Load(gameid) pmediaid, ok := wp.mediaInfo.Load(gameid)
if ok { if ok {
urls := mt.Table.Config.GetWxUrl() urls := mt.Table.Config.GetWxApiHosts()
if len(urls) > 0 { 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) 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) { func (wp *wxpay) GenSendWxMsgUrl(gameid int64) (msgurl string) {
token := wp.getAccessToken(gameid) token := wp.getAccessToken(gameid)
urls := mt.Table.Config.GetWxUrl() urls := mt.Table.Config.GetWxApiHosts()
if len(urls) > 0 { if len(urls) > 0 {
msgurl = fmt.Sprintf("https://%s/cgi-bin/message/custom/send?access_token=%s", urls[0], token) 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), Description: core.String(info.Name),
OutTradeNo: core.String(orderid), OutTradeNo: core.String(orderid),
Attach: core.String(userip), 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{ Amount: &jsapi.Amount{
Total: core.Int64(info.Price), Total: core.Int64(info.Price),
}, },