Browse Source

fix:模板消息

Roc 1 year ago
parent
commit
5e6ce766b4

+ 8 - 6
controllers/business_trip/business_apply.go

@@ -221,12 +221,13 @@ func (this *BusinessTrip) ApplyAdd() {
 		first := "您好,有新的申请待处理"
 		keyword1 := sysUser.RealName
 		keyword2 := "--" //sysUser.Mobile
-		keyword3 := time.Now().Format(utils.FormatDateTime)
+		//keyword3 := time.Now().Format(utils.FormatDateTime)
+		keyword3 := req.ArriveDate + "至" + req.ReturnDate
 		var keyword4 string
 		if req.PeerPeopleId != "" {
-			keyword4 = req.ArriveDate + "至" + req.ReturnDate + "," + req.Transportation + "前往" + req.Province + req.City + "," + "同行人" + req.PeerPeopleName
+			keyword4 = req.Transportation + "前往" + req.Province + req.City + "," + "同行人" + req.PeerPeopleName
 		} else {
-			keyword4 = req.ArriveDate + "至" + req.ReturnDate + "," + req.Transportation + "前往" + req.Province + req.City
+			keyword4 = req.Transportation + "前往" + req.Province + req.City
 		}
 		remark := "请尽快完成审批"
 		go services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, approveItem.Mobile)
@@ -465,12 +466,13 @@ func (this *BusinessTrip) ApplyEdit() {
 		first := "您好,有新的申请待处理"
 		keyword1 := sysUser.RealName
 		keyword2 := "--" //sysUser.Mobile
-		keyword3 := time.Now().Format(utils.FormatDateTime)
+		//keyword3 := time.Now().Format(utils.FormatDateTime)
+		keyword3 := req.ArriveDate + "至" + req.ReturnDate
 		var keyword4 string
 		if req.PeerPeopleId != "" {
-			keyword4 = req.ArriveDate + "至" + req.ReturnDate + "," + req.Transportation + "前往" + req.Province + req.City + "," + "同行人" + req.PeerPeopleName
+			keyword4 = req.Transportation + "前往" + req.Province + req.City + "," + "同行人" + req.PeerPeopleName
 		} else {
-			keyword4 = req.ArriveDate + "至" + req.ReturnDate + "," + req.Transportation + "前往" + req.Province + req.City
+			keyword4 = req.Transportation + "前往" + req.Province + req.City
 		}
 		remark := "请尽快完成审批"
 		go services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, approveItem.Mobile)

+ 1 - 0
controllers/business_trip/business_approve.go

@@ -160,6 +160,7 @@ func (this *BusinessTrip) ApplyApprove() {
 		var remark string
 		if status == "已驳回" {
 			remark = req.RefuseReason
+			keyword2 = status + `(` + req.RefuseReason + `)`
 		}
 		go services.SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppPath, applyItem.Mobile)
 	}

+ 24 - 19
controllers/roadshow/calendar.go

@@ -218,7 +218,7 @@ func (this *CalendarController) Add() {
 
 		//模板消息通知
 		{
-			go func(researcherId,tmpRsCalendarId,tmpRsCalendarResearcherId int) {
+			go func(researcherId, tmpRsCalendarId, tmpRsCalendarResearcherId int) {
 				var wxAppPath string
 				sysAdmin, _ := admin.GetAdminWxById(researcherId)
 				if sysAdmin != nil {
@@ -227,14 +227,15 @@ func (this *CalendarController) Add() {
 						first := "您收到一个新的【" + req.ActivityType + "】申请,请及时处理"
 						keyword1 := sysUser.RealName
 						keyword2 := "--"
-						keyword3 := time.Now().Format(utils.FormatDateTime)
+						//keyword3 := time.Now().Format(utils.FormatDateTime)
 						startDateSub := v.StartDate[5:]
 						startDateSub = strings.Replace(startDateSub, "-", ".", -1)
+						keyword3 := startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5]
 						var keyword4 string
 						if req.ActivityType == "路演" {
-							keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.CompanyName + "(" + req.RoadshowType + req.ActivityType + ")"
+							keyword4 = req.CompanyName + "(" + req.RoadshowType + req.ActivityType + ")"
 						} else {
-							keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.Theme + "(" + req.RoadshowType + req.ActivityType + ")"
+							keyword4 = req.Theme + "(" + req.RoadshowType + req.ActivityType + ")"
 						}
 						remark := "请尽快完成审批"
 						//wxAppPath := "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(int(rsCalendarId)) + "&RsCalendarResearcherId=" + strconv.Itoa(int(rsCalendarResearcherId))
@@ -246,14 +247,14 @@ func (this *CalendarController) Add() {
 						first := sysUser.RealName + "为你添加了一场【" + req.ActivityType + "】"
 						startDate := researcher.StartDate[5:]
 						startDate = strings.Replace(startDate, "-", ".", -1)
-						keyword1 := "会议时间:" + startDate + "(" + researcher.StartWeek + ")" + " " + researcher.StartTime[:5] + "-" + researcher.EndTime[:5]
-						keyword2 := "--"
+						keyword1 := startDate + "(" + researcher.StartWeek + ")" + " " + researcher.StartTime[:5] + "-" + researcher.EndTime[:5]
+						keyword2 := sysUser.RealName + "为你添加了【" + req.ActivityType + "】"
 						if sysAdmin.OpenId != "" {
 							go services.SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, "", wxAppPath, sysAdmin.Mobile)
 						}
 					}
 				}
-			}(v.ResearcherId,int(rsCalendarId),int(rsCalendarResearcherId))
+			}(v.ResearcherId, int(rsCalendarId), int(rsCalendarResearcherId))
 		}
 	}
 	this.OkDetailed(nil, "保存成功")
@@ -1399,20 +1400,21 @@ func (this *CalendarController) Edit() {
 
 			if req.EditType == 2 {
 				//模板消息通知
-				go func(researcherId,tmpRsCalendarId,tmpRsCalendarResearcherId int) {
+				go func(researcherId, tmpRsCalendarId, tmpRsCalendarResearcherId int) {
 					sysAdmin, _ := admin.GetAdminById(researcherId)
 					if sysAdmin != nil && req.ActivityType != "内部会议" && req.ActivityType != "报告电话会" {
 						first := "您收到一个新的【" + req.ActivityType + "】申请,请及时处理"
 						keyword1 := sysUser.RealName
 						keyword2 := "--"
-						keyword3 := time.Now().Format(utils.FormatDateTime)
+						//keyword3 := time.Now().Format(utils.FormatDateTime)
 						startDateSub := v.StartDate[5:]
 						startDateSub = strings.Replace(startDateSub, "-", ".", -1)
+						keyword3 := startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5]
 						var keyword4 string
 						if req.ActivityType == "路演" {
-							keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.CompanyName + "(" + req.RoadshowType + req.ActivityType + ")"
+							keyword4 = req.CompanyName + "(" + req.RoadshowType + req.ActivityType + ")"
 						} else {
-							keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.Theme + "(" + req.RoadshowType + req.ActivityType + ")"
+							keyword4 = req.Theme + "(" + req.RoadshowType + req.ActivityType + ")"
 						}
 						remark := "请尽快完成审批"
 						wxAppPath := "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(req.RsCalendarId) + "&RsCalendarResearcherId=" + strconv.Itoa(tmpRsCalendarResearcherId)
@@ -1420,7 +1422,7 @@ func (this *CalendarController) Edit() {
 							services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, sysAdmin.Mobile)
 						}
 					}
-				}(v.ResearcherId,req.RsCalendarId,rsCalendarResearcherItem.RsCalendarResearcherId)
+				}(v.ResearcherId, req.RsCalendarId, rsCalendarResearcherItem.RsCalendarResearcherId)
 			}
 		}
 	} else {
@@ -1477,7 +1479,7 @@ func (this *CalendarController) Edit() {
 			researcher.RsCalendarResearcherId = int(rsCalendarResearcherId)
 			go rs.CalendarToSH(calendar, *researcher)
 
-			go func(researcherId,tmpRsCalendarId,tmpRsCalendarResearcherId int) {
+			go func(researcherId, tmpRsCalendarId, tmpRsCalendarResearcherId int) {
 				sysAdmin, _ := admin.GetAdminById(researcherId)
 				if sysAdmin != nil && req.ActivityType != "内部会议" && req.ActivityType != "报告电话会" {
 					first := "您收到一个新的【" + req.ActivityType + "】申请,请及时处理"
@@ -1486,11 +1488,12 @@ func (this *CalendarController) Edit() {
 					keyword3 := time.Now().Format(utils.FormatDateTime)
 					startDateSub := v.StartDate[5:]
 					startDateSub = strings.Replace(startDateSub, "-", ".", -1)
+					//keyword3 := startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5]
 					var keyword4 string
 					if req.ActivityType == "路演" {
-						keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.CompanyName + "(" + req.RoadshowType + req.ActivityType + ")"
+						keyword4 = req.CompanyName + "(" + req.RoadshowType + req.ActivityType + ")"
 					} else {
-						keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.Theme + "(" + req.RoadshowType + req.ActivityType + ")"
+						keyword4 = req.Theme + "(" + req.RoadshowType + req.ActivityType + ")"
 					}
 					remark := "请尽快完成审批"
 					wxAppPath := "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(tmpRsCalendarId) + "&RsCalendarResearcherId=" + strconv.Itoa(tmpRsCalendarResearcherId)
@@ -1499,7 +1502,7 @@ func (this *CalendarController) Edit() {
 					}
 				}
 
-			}(v.ResearcherId,req.RsCalendarId,int(rsCalendarResearcherId))
+			}(v.ResearcherId, req.RsCalendarId, int(rsCalendarResearcherId))
 		}
 	}
 	this.OkDetailed(nil, "保存成功")
@@ -1717,7 +1720,7 @@ func (this *CalendarController) Delete() {
 		//模板消息通知
 		{
 			if rsCalendarItem != nil && rsCalendarResearcherItem != nil {
-				go func(tmpRsCalendarItem roadshow.RsCalendar,tmpRsCalendarResearcherItem roadshow.RsCalendarResearcher) {
+				go func(tmpRsCalendarItem roadshow.RsCalendar, tmpRsCalendarResearcherItem roadshow.RsCalendarResearcher) {
 					sysAdmin, _ := admin.GetAdminById(tmpRsCalendarResearcherItem.ResearcherId)
 					var first string
 					var wxAppPath string
@@ -1727,6 +1730,7 @@ func (this *CalendarController) Delete() {
 
 					first = "【" + sysUser.RealName + "】删除了你的【" + tmpRsCalendarItem.ActivityType + "】安排"
 
+					keyword2 := "【" + sysUser.RealName + "】已删除(" + req.DeleteReason + ")"
 					var keyword1 string
 					if tmpRsCalendarItem.ActivityType == "路演" {
 						keyword1 = tmpRsCalendarItem.CompanyName + "," + tmpRsCalendarItem.RoadshowType + tmpRsCalendarItem.ActivityType
@@ -1736,14 +1740,15 @@ func (this *CalendarController) Delete() {
 						startDate := tmpRsCalendarResearcherItem.StartDate[5:]
 						startDate = strings.Replace(startDate, "-", ".", -1)
 						keyword1 = "会议时间:" + startDate + "(" + tmpRsCalendarResearcherItem.StartWeek + ")" + " " + tmpRsCalendarResearcherItem.StartTime[:5] + "-" + tmpRsCalendarResearcherItem.EndTime[:5]
+						keyword2 = "【" + sysUser.RealName + "】已删除" + "【" + tmpRsCalendarItem.ActivityType + ")"
 					}
-					keyword2 := "已删除"
+					//keyword2 := "已删除"
 					remark := req.DeleteReason
 
 					if sysAdmin.OpenId != "" {
 						go services.SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppPath, sysAdmin.Mobile)
 					}
-				}(*rsCalendarItem,*rsCalendarResearcherItem)
+				}(*rsCalendarItem, *rsCalendarResearcherItem)
 			}
 		}
 	}

+ 7 - 8
services/wechat_send_msg.go

@@ -2,6 +2,7 @@ package services
 
 import (
 	"encoding/json"
+	"errors"
 	"fmt"
 	"hongze/hongze_mobile_admin/models"
 	"hongze/hongze_mobile_admin/models/tables/admin"
@@ -11,8 +12,8 @@ import (
 	"net/http"
 	"strings"
 	"time"
-	"errors"
 )
+
 type SendWxTemplate struct {
 	WxAppId        string   `description:"公众号appId"`
 	First          string   `description:"模板消息first字段"`
@@ -113,7 +114,6 @@ func SendCompanyApplyWxTemplateMsg(mobile, redirectUrl, wxAppPath string, wxMsgM
 		//}
 		//sendTemplateMsg(sendUrl, sendMap, openIdList, mobile, utils.TEMPLATE_MSG_APPLY)
 
-
 		openIdArr := make([]string, len(openIdList))
 		for i, v := range openIdList {
 			openIdArr[i] = v.OpenId
@@ -390,7 +390,8 @@ func SendSealFinishedWxTemplateMsg(mobile string, companyName string, sealId int
 		//sendData := make(map[string]interface{})
 		first := "您的用印申请已签回,可前往提交转正/续约申请"
 		keyword1 := companyName
-		keyword2 := "已签回"
+		//keyword2 := "已签回"
+		keyword2 := "用印申请已签回,可前往提交转正/续约申请"
 		remark := "点击查看用印详情"
 		//
 		//sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
@@ -443,7 +444,7 @@ func SendYbQuestionDistributeWxMsg(questionId, adminId int, openid, questionTitl
 	}()
 	openIdList := make([]*admin.OpenIdList, 0)
 	openIdList = append(openIdList, &admin.OpenIdList{
-		OpenId: openid,
+		OpenId:  openid,
 		AdminId: adminId,
 	})
 
@@ -492,8 +493,7 @@ func SendYbQuestionDistributeWxMsg(questionId, adminId int, openid, questionTitl
 	return
 }
 
-
-//推送模板消息
+// 推送模板消息
 func SendTemplateMsg(sendInfo *SendWxTemplate) (err error) {
 	postData, err := json.Marshal(sendInfo)
 	if err != nil {
@@ -532,7 +532,6 @@ func SendTemplateMsg(sendInfo *SendWxTemplate) (err error) {
 	return
 }
 
-
 // SendWxMsgWithRaiSell 权益销售客户申请转正后,消息群发给所有销售
 func SendWxMsgWithRaiSell(first, keyword1, keyword2, keyword3, keyword4 string, openIdList []*models.OpenIdList) (err error) {
 	var msg string
@@ -564,4 +563,4 @@ func SendWxMsgWithRaiSell(first, keyword1, keyword2, keyword3, keyword4 string,
 	fmt.Println(sendInfo)
 	err = SendTemplateMsg(sendInfo)
 	return
-}
+}