zhangchuanxing 3 månader sedan
förälder
incheckning
26e359ccef
1 ändrade filer med 18 tillägg och 8 borttagningar
  1. 18 8
      controllers/wechat.go

+ 18 - 8
controllers/wechat.go

@@ -413,18 +413,28 @@ func (this *WechatController) UserInfo() {
 func (this *WechatCommonController) Notify() {
 	//echostr := this.GetString("echostr")
 	method := this.Ctx.Input.Method()
+	//添加请求日志记录
+	itemApiLog := new(models.CygxThreeApiLog)
+	itemApiLog.CreateTime = time.Now()
+	itemApiLog.Source = 1
+	itemApiLog.Url = this.Ctx.Input.URI()
+	itemApiLog.Body = ""
 	if method == "POST" {
 		body := this.Ctx.Input.RequestBody
 		utils.FileLog.Info("wechat notify:" + string(body))
-
-		//添加请求日志记录
-		itemApiLog := new(models.CygxThreeApiLog)
-		itemApiLog.CreateTime = time.Now()
-		itemApiLog.Source = 1
-		itemApiLog.Url = this.Ctx.Input.URI()
-		itemApiLog.Body = ""
 		itemApiLog.Result = string(body)
-		go models.AddCygxThreeApiLog(itemApiLog)
+	}
+
+	go models.AddCygxThreeApiLog(itemApiLog)
+	if method == "POST" {
+		body := this.Ctx.Input.RequestBody
+		utils.FileLog.Info("wechat notify:" + string(body))
+		fmt.Println(string(body))
+		if string(body) == "" {
+			this.Ctx.WriteString("hongze")
+			return
+		}
+
 		item := new(models.Notify)
 		err := xml.Unmarshal(body, &item)
 		if err != nil {