Эх сурвалжийг харах

fix:修复路演时,匿名函数导致的变量值被篡改后用户模板消息发送失败的bug

Roc 2 жил өмнө
parent
commit
5bafccc405

+ 26 - 26
controllers/roadshow/calendar.go

@@ -218,12 +218,12 @@ func (this *CalendarController) Add() {
 
 		//模板消息通知
 		{
-			go func() {
+			go func(researcherId,tmpRsCalendarId,tmpRsCalendarResearcherId int) {
 				var wxAppPath string
-				sysAdmin, _ := admin.GetAdminWxById(v.ResearcherId)
+				sysAdmin, _ := admin.GetAdminWxById(researcherId)
 				if sysAdmin != nil {
 					if req.ActivityType == "路演" || req.ActivityType == "公开会议" {
-						wxAppPath = "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(int(rsCalendarId)) + "&RsCalendarResearcherId=" + strconv.Itoa(int(rsCalendarResearcherId))
+						wxAppPath = "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(tmpRsCalendarId) + "&RsCalendarResearcherId=" + strconv.Itoa(tmpRsCalendarResearcherId)
 						first := "您收到一个新的【" + req.ActivityType + "】申请,请及时处理"
 						keyword1 := sysUser.RealName
 						keyword2 := "--"
@@ -253,7 +253,7 @@ func (this *CalendarController) Add() {
 						}
 					}
 				}
-			}()
+			}(v.ResearcherId,int(rsCalendarId),int(rsCalendarResearcherId))
 		}
 	}
 	this.OkDetailed(nil, "保存成功")
@@ -1399,8 +1399,8 @@ func (this *CalendarController) Edit() {
 
 			if req.EditType == 2 {
 				//模板消息通知
-				go func() {
-					sysAdmin, _ := admin.GetAdminById(v.ResearcherId)
+				go func(researcherId,tmpRsCalendarId,tmpRsCalendarResearcherId int) {
+					sysAdmin, _ := admin.GetAdminById(researcherId)
 					if sysAdmin != nil && req.ActivityType != "内部会议" && req.ActivityType != "报告电话会" {
 						first := "您收到一个新的【" + req.ActivityType + "】申请,请及时处理"
 						keyword1 := sysUser.RealName
@@ -1415,12 +1415,12 @@ func (this *CalendarController) Edit() {
 							keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.Theme + "(" + req.RoadshowType + req.ActivityType + ")"
 						}
 						remark := "请尽快完成审批"
-						wxAppPath := "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(req.RsCalendarId) + "&RsCalendarResearcherId=" + strconv.Itoa(rsCalendarResearcherItem.RsCalendarResearcherId)
+						wxAppPath := "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(req.RsCalendarId) + "&RsCalendarResearcherId=" + strconv.Itoa(tmpRsCalendarResearcherId)
 						if sysAdmin.OpenId != "" {
 							services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, sysAdmin.Mobile)
 						}
 					}
-				}()
+				}(v.ResearcherId,req.RsCalendarId,rsCalendarResearcherItem.RsCalendarResearcherId)
 			}
 		}
 	} else {
@@ -1477,8 +1477,8 @@ func (this *CalendarController) Edit() {
 			researcher.RsCalendarResearcherId = int(rsCalendarResearcherId)
 			go rs.CalendarToSH(calendar, *researcher)
 
-			go func() {
-				sysAdmin, _ := admin.GetAdminById(v.ResearcherId)
+			go func(researcherId,tmpRsCalendarId,tmpRsCalendarResearcherId int) {
+				sysAdmin, _ := admin.GetAdminById(researcherId)
 				if sysAdmin != nil && req.ActivityType != "内部会议" && req.ActivityType != "报告电话会" {
 					first := "您收到一个新的【" + req.ActivityType + "】申请,请及时处理"
 					keyword1 := sysUser.RealName
@@ -1493,13 +1493,13 @@ func (this *CalendarController) Edit() {
 						keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.Theme + "(" + req.RoadshowType + req.ActivityType + ")"
 					}
 					remark := "请尽快完成审批"
-					wxAppPath := "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(req.RsCalendarId) + "&RsCalendarResearcherId=" + strconv.Itoa(int(rsCalendarResearcherId))
+					wxAppPath := "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(tmpRsCalendarId) + "&RsCalendarResearcherId=" + strconv.Itoa(tmpRsCalendarResearcherId)
 					if sysAdmin.OpenId != "" {
 						services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, sysAdmin.Mobile)
 					}
 				}
 
-			}()
+			}(v.ResearcherId,req.RsCalendarId,int(rsCalendarResearcherId))
 		}
 	}
 	this.OkDetailed(nil, "保存成功")
@@ -1716,26 +1716,26 @@ func (this *CalendarController) Delete() {
 
 		//模板消息通知
 		{
-			go func() {
-				if rsCalendarItem != nil && rsCalendarResearcherItem != nil {
-					sysAdmin, _ := admin.GetAdminById(rsCalendarResearcherItem.ResearcherId)
+			if rsCalendarItem != nil && rsCalendarResearcherItem != nil {
+				go func(tmpRsCalendarItem roadshow.RsCalendar,tmpRsCalendarResearcherItem roadshow.RsCalendarResearcher) {
+					sysAdmin, _ := admin.GetAdminById(tmpRsCalendarResearcherItem.ResearcherId)
 					var first string
 					var wxAppPath string
-					if rsCalendarItem.ActivityType == "路演" || rsCalendarItem.ActivityType == "公开会议" {
-						wxAppPath = "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(rsCalendarItem.RsCalendarId) + "&RsCalendarResearcherId=" + strconv.Itoa(rsCalendarResearcherItem.RsCalendarResearcherId)
+					if tmpRsCalendarItem.ActivityType == "路演" || tmpRsCalendarItem.ActivityType == "公开会议" {
+						wxAppPath = "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(tmpRsCalendarItem.RsCalendarId) + "&RsCalendarResearcherId=" + strconv.Itoa(tmpRsCalendarResearcherItem.RsCalendarResearcherId)
 					}
 
-					first = "【" + sysUser.RealName + "】删除了你的【" + rsCalendarItem.ActivityType + "】安排"
+					first = "【" + sysUser.RealName + "】删除了你的【" + tmpRsCalendarItem.ActivityType + "】安排"
 
 					var keyword1 string
-					if rsCalendarItem.ActivityType == "路演" {
-						keyword1 = rsCalendarItem.CompanyName + "," + rsCalendarItem.RoadshowType + rsCalendarItem.ActivityType
-					} else if rsCalendarItem.ActivityType == "公开会议" {
-						keyword1 = rsCalendarItem.Theme + "," + rsCalendarItem.RoadshowType + rsCalendarItem.ActivityType
+					if tmpRsCalendarItem.ActivityType == "路演" {
+						keyword1 = tmpRsCalendarItem.CompanyName + "," + tmpRsCalendarItem.RoadshowType + tmpRsCalendarItem.ActivityType
+					} else if tmpRsCalendarItem.ActivityType == "公开会议" {
+						keyword1 = tmpRsCalendarItem.Theme + "," + tmpRsCalendarItem.RoadshowType + tmpRsCalendarItem.ActivityType
 					} else {
-						startDate := rsCalendarResearcherItem.StartDate[5:]
+						startDate := tmpRsCalendarResearcherItem.StartDate[5:]
 						startDate = strings.Replace(startDate, "-", ".", -1)
-						keyword1 = "会议时间:" + startDate + "(" + rsCalendarResearcherItem.StartWeek + ")" + " " + rsCalendarResearcherItem.StartTime[:5] + "-" + rsCalendarResearcherItem.EndTime[:5]
+						keyword1 = "会议时间:" + startDate + "(" + tmpRsCalendarResearcherItem.StartWeek + ")" + " " + tmpRsCalendarResearcherItem.StartTime[:5] + "-" + tmpRsCalendarResearcherItem.EndTime[:5]
 					}
 					keyword2 := "已删除"
 					remark := req.DeleteReason
@@ -1743,8 +1743,8 @@ func (this *CalendarController) Delete() {
 					if sysAdmin.OpenId != "" {
 						go services.SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppPath, sysAdmin.Mobile)
 					}
-				}
-			}()
+				}(*rsCalendarItem,*rsCalendarResearcherItem)
+			}
 		}
 	}