This commit is contained in:
yangduo 2025-01-13 15:16:41 +08:00
parent 65a495ab98
commit a75cb37f77
2 changed files with 23 additions and 23 deletions

View File

@ -74,29 +74,29 @@ func (this *MainServiceApi) WxTNotify(c *gin.Context) {
func (this *MainServiceApi) WxNotifyPurchase(c *gin.Context) {
f5.GetSysLog().Debug("wx notify purchase:%s", c.Request.URL.RawQuery)
signature := c.Query("signature")
timestamp := c.Query("timestamp")
nonce := c.Query("nonce")
// signature := c.Query("signature")
// timestamp := c.Query("timestamp")
// nonce := c.Query("nonce")
if len(signature) > 0 || len(timestamp) > 0 || len(nonce) > 0 {
strs := []string{mt.Table.Config.GetWxNotifyToken(), timestamp, nonce}
sort.Strings(strs)
sb := strings.Builder{}
sb.WriteString(strs[0])
sb.WriteString(strs[1])
sb.WriteString(strs[2])
m := sha1.New()
io.WriteString(m, sb.String())
sign := string(hex.EncodeToString(m.Sum(nil)))
// if len(signature) > 0 || len(timestamp) > 0 || len(nonce) > 0 {
// strs := []string{mt.Table.Config.GetWxNotifyToken(), timestamp, nonce}
// sort.Strings(strs)
// sb := strings.Builder{}
// sb.WriteString(strs[0])
// sb.WriteString(strs[1])
// sb.WriteString(strs[2])
// m := sha1.New()
// io.WriteString(m, sb.String())
// sign := string(hex.EncodeToString(m.Sum(nil)))
f5.GetSysLog().Debug("wx sign:%s, %s", sign, signature)
if sign != signature {
c.String(200, "wrong")
return
}
c.String(200, c.Query("echostr"))
return
}
// f5.GetSysLog().Debug("wx sign:%s, %s", sign, signature)
// if sign != signature {
// c.String(200, "wrong")
// return
// }
// c.String(200, c.Query("echostr"))
// return
// }
rspObj := struct {
ErrorCode int32 `json:"ErrCode"`

View File

@ -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().POST("/wx/tnotify",
api.WxNotifyPurchase)
}