Browse Source

update

master
DengBiao 1 year ago
parent
commit
d1ae89b8ff
1 changed files with 47 additions and 45 deletions
  1. +47
    -45
      app/hdl/hdl_wx.go

+ 47
- 45
app/hdl/hdl_wx.go View File

@@ -5,12 +5,14 @@ import (
"applet/app/db/model"
"applet/app/enum"
"applet/app/md"
"applet/app/svc"
"applet/app/utils"
"encoding/json"
"encoding/xml"
"errors"
"fmt"
"log"
"strings"
"time"

"github.com/gin-gonic/gin"
@@ -97,51 +99,51 @@ func WXMsgReceive(c *gin.Context) {
}
utils.FilePutContents("WXMsgReceive", utils.SerializeStr(msg))
log.Printf("[消息接收] - 收到消息, 消息类型为: %s", msg.MsgType)
//if msg.MsgType == "event" {
// //事件类型消息
// eventMsg := msg
// log.Printf("[事件类型]-收到消息, 事件类型为: %s, 事件KEY值为: %s\n, 二维码的ticket值为: %s\n", eventMsg.Event, eventMsg.EventKey, eventMsg.Ticket)
// if eventMsg.Event == "subscribe" {
// //用户未关注时,进行关注后的事件推送
// err := DealCallBack(eventMsg.FromUserName, eventMsg.EventKey)
// if err != nil {
// WXMsgReply(c, eventMsg.ToUserName, eventMsg.FromUserName, err.Error())
// }
// }
// if eventMsg.Event == "SCAN" {
// //用户已关注时的事件推送
// err := DealCallBack(eventMsg.FromUserName, eventMsg.EventKey)
// if err != nil {
// WXMsgReply(c, eventMsg.ToUserName, eventMsg.FromUserName, err.Error())
// }
// }
// if eventMsg.Event == "CLICK" { //公众号点击
// if strings.Contains(strings.ToLower(eventMsg.EventKey), "official_account_custom_reply") {
// id := strings.ReplaceAll(strings.ToLower(eventMsg.EventKey), "official_account_custom_reply_", "")
// var mod model.SysModule
// db.Db.Where("mod_id=?", id).Get(&mod)
// fmt.Println(mod)
// if mod.Data == "" {
// fmt.Println(333)
//
// return
// }
// var data []md.ReplyContent
// json.Unmarshal([]byte(mod.Data), &data)
// for _, v := range data {
// if v.MsgType == "text" {
// fmt.Println(1111)
//
// svc.WXMsgTextReply(c, msg.ToUserName, msg.FromUserName, v.Text.Content)
// }
// if v.MsgType == "image" {
// fmt.Println(22222)
// svc.WXMsgImageReply(c, msg.ToUserName, msg.FromUserName, v.Image.MediaId)
// }
// }
// }
// }
//}
if msg.MsgType == "event" {
//事件类型消息
eventMsg := msg
log.Printf("[事件类型]-收到消息, 事件类型为: %s, 事件KEY值为: %s\n, 二维码的ticket值为: %s\n", eventMsg.Event, eventMsg.EventKey, eventMsg.Ticket)
if eventMsg.Event == "subscribe" {
//用户未关注时,进行关注后的事件推送
err := DealCallBack(eventMsg.FromUserName, eventMsg.EventKey)
if err != nil {
WXMsgReply(c, eventMsg.ToUserName, eventMsg.FromUserName, err.Error())
}
}
if eventMsg.Event == "SCAN" {
//用户已关注时的事件推送
err := DealCallBack(eventMsg.FromUserName, eventMsg.EventKey)
if err != nil {
WXMsgReply(c, eventMsg.ToUserName, eventMsg.FromUserName, err.Error())
}
}
if eventMsg.Event == "CLICK" { //公众号点击
if strings.Contains(strings.ToLower(eventMsg.EventKey), "official_account_custom_reply") {
id := strings.ReplaceAll(strings.ToLower(eventMsg.EventKey), "official_account_custom_reply_", "")
var mod model.SysModule
db.Db.Where("mod_id=?", id).Get(&mod)
fmt.Println(mod)
if mod.Data == "" {
fmt.Println(333)
return
}
var data []md.ReplyContent
json.Unmarshal([]byte(mod.Data), &data)
for _, v := range data {
if v.MsgType == "text" {
fmt.Println(1111)
svc.WXMsgTextReply(c, msg.ToUserName, msg.FromUserName, v.Text.Content)
}
if v.MsgType == "image" {
fmt.Println(22222)
svc.WXMsgImageReply(c, msg.ToUserName, msg.FromUserName, v.Image.MediaId)
}
}
}
}
}
if msg.MsgType == "text" {
//文本类型消息
textMsg := msg


Loading…
Cancel
Save