瀏覽代碼

fix:由于测试环境小程序没有发布,模板消息设置了小程序跳转地址,会导致模板消息发送失败

Roc 3 年之前
父節點
當前提交
f204abc2a3
共有 2 個文件被更改,包括 7 次插入3 次删除
  1. 4 0
      services/activity.go
  2. 3 3
      services/wx_template_msg.go

+ 4 - 0
services/activity.go

@@ -123,6 +123,10 @@ func sendWxMsg(activityInfo *yb.Activity, remindType string) (err error) {
 	}
 	//小程序跳转地址
 	wxAppPath := `pages-activity/detail?id=` + fmt.Sprint(activityInfo.ActivityId)
+	//由于测试环境小程序没有发布,模板消息设置了小程序跳转地址,会导致模板消息发送失败
+	if utils.RunMode == `debug` {
+		wxAppPath = ``
+	}
 	err = SendWxMsgWithActivityAppointmentRemind(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, openidList)
 	return
 }

+ 3 - 3
services/wx_template_msg.go

@@ -59,7 +59,7 @@ func WxSendTemplateMsg(sendUrl string, sendMap map[string]interface{}, items []*
 			fmt.Println("SendTemplateMsgOne Marshal Err:", err.Error())
 			return err
 		}
-		utils.FileLog.Info("One SendData:%s", string(data))
+		utils.FileLog.Info(fmt.Sprintf("One SendData:%s", string(data)))
 		err = SendTemplateMsg(sendUrl, data)
 		if err != nil {
 			fmt.Println("send err:", err.Error())
@@ -78,7 +78,7 @@ func SendTemplateMsg(sendUrl string, data []byte) (err error) {
 	defer resp.Body.Close()
 
 	body, _ := ioutil.ReadAll(resp.Body)
-	utils.FileLog.Info("SendResult:%s", string(body))
+	utils.FileLog.Info(fmt.Sprintf("SendResult:%s", string(body)))
 	var templateResponse models.SendTemplateResponse
 	err = json.Unmarshal(body, &templateResponse)
 	if err != nil {
@@ -127,7 +127,7 @@ func SendWxMsgWithActivityAppointmentRemind(first, keyword1, keyword2, keyword3,
 	defer func() {
 		if err != nil {
 			go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
-			utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
+			utils.FileLog.Info(fmt.Sprintf("发送模版消息失败,Err:%s", err.Error()))
 		}
 	}()
 	utils.FileLog.Info("%s", "services SendMsg")