Roc 2 年之前
父節點
當前提交
3c9d1126ea
共有 3 個文件被更改,包括 52 次插入28 次删除
  1. 33 23
      controllers/roadshow/calendar.go
  2. 16 5
      models/roadshow/calendar.go
  3. 3 0
      services/rs/calendar.go

+ 33 - 23
controllers/roadshow/calendar.go

@@ -1577,7 +1577,7 @@ func (this *CalendarController) Delete() {
 		return
 	}
 
-	rsCalendarResearcherItem, err := roadshow.GetRsCalendarResearcherById(req.RsCalendarResearcherId)
+	rsCalendarResearcherItemList, err := roadshow.GetRsCalendarResearcherListById(req.RsCalendarResearcherId)
 	if err != nil {
 		this.FailWithMessage("获取数据失败!", "获取数据失败!GetRsCalendarResearcherById:"+err.Error())
 		return
@@ -1590,6 +1590,13 @@ func (this *CalendarController) Delete() {
 			return
 		}
 	} else {
+		//只获取一条路演数据
+		rsCalendarResearcherItemList, err = roadshow.GetRsCalendarResearcherListByCalendarResearcherId(req.RsCalendarResearcherId)
+		if err != nil {
+			this.FailWithMessage("获取数据失败!", "获取数据失败!GetRsCalendarResearcherById:"+err.Error())
+			return
+		}
+
 		if req.DeleteReason == "" {
 			this.FailWithMessage("删除失败,请输入删除理由!", "删除失败!请输入删除理由")
 			return
@@ -1612,31 +1619,34 @@ func (this *CalendarController) Delete() {
 		}
 	}
 	//`status` int(11) DEFAULT '0' COMMENT '1:待接受,2:已接受,3:已拒绝,4:已删除,5:已撤回,6:已结束',
-	//待接受、已接受的情况,需要同步删除上海那边的日程
-	if rsCalendarResearcherItem.Status == 1 || rsCalendarResearcherItem.Status == 2 {
-		go rs.DeleteSHCalendar(rsCalendarResearcherItem.RsCalendarResearcherId)
-	}
-	//模板消息通知
-	{
-		go func() {
-			if rsCalendarItem != nil && rsCalendarResearcherItem != nil {
-				sysAdmin, _ := admin.GetAdminById(rsCalendarResearcherItem.ResearcherId)
-				if sysAdmin != nil && sysAdmin.Mobile != "" {
-					first := "【" + sysUser.RealName + "】删除了你的【路演】安排"
-					var keyword1 string
-					if rsCalendarItem.ActivityType == "路演" {
-						keyword1 = rsCalendarItem.CompanyName + "," + rsCalendarItem.RoadshowType + rsCalendarItem.ActivityType
-					} else {
-						keyword1 = rsCalendarItem.Theme + "," + rsCalendarItem.RoadshowType + rsCalendarItem.ActivityType
+	for _, rsCalendarResearcherItem := range rsCalendarResearcherItemList {
+		//待接受、已接受的情况,需要同步删除上海那边的日程
+		if rsCalendarResearcherItem.Status == 1 || rsCalendarResearcherItem.Status == 2 {
+			go rs.DeleteSHCalendar(rsCalendarResearcherItem.RsCalendarResearcherId)
+		}
+		//模板消息通知
+		{
+			go func() {
+				if rsCalendarItem != nil && rsCalendarResearcherItem != nil {
+					sysAdmin, _ := admin.GetAdminById(rsCalendarResearcherItem.ResearcherId)
+					if sysAdmin != nil && sysAdmin.Mobile != "" {
+						first := "【" + sysUser.RealName + "】删除了你的【路演】安排"
+						var keyword1 string
+						if rsCalendarItem.ActivityType == "路演" {
+							keyword1 = rsCalendarItem.CompanyName + "," + rsCalendarItem.RoadshowType + rsCalendarItem.ActivityType
+						} else {
+							keyword1 = rsCalendarItem.Theme + "," + rsCalendarItem.RoadshowType + rsCalendarItem.ActivityType
+						}
+						keyword2 := "已删除"
+						remark := req.DeleteReason
+						wxAppPath := "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(rsCalendarItem.RsCalendarId) + "&RsCalendarResearcherId=" + strconv.Itoa(rsCalendarResearcherItem.RsCalendarResearcherId)
+						go services.SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppPath, sysAdmin.Mobile)
 					}
-					keyword2 := "已删除"
-					remark := req.DeleteReason
-					wxAppPath := "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(rsCalendarItem.RsCalendarId) + "&RsCalendarResearcherId=" + strconv.Itoa(rsCalendarResearcherItem.RsCalendarResearcherId)
-					go services.SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppPath, sysAdmin.Mobile)
 				}
-			}
-		}()
+			}()
+		}
 	}
+
 	this.OkDetailed(nil, "删除成功")
 }
 

+ 16 - 5
models/roadshow/calendar.go

@@ -94,6 +94,20 @@ func GetRsCalendarResearcherById(rsCalendarResearcherId int) (item *RsCalendarRe
 	return
 }
 
+func GetRsCalendarResearcherListById(rsCalendarId int) (item []*RsCalendarResearcher, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_id=? `
+	_, err = o.Raw(sql, rsCalendarId).QueryRows(&item)
+	return
+}
+
+func GetRsCalendarResearcherListByCalendarResearcherId(rsCalendarResearcherId int) (item []*RsCalendarResearcher, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_researcher_id=? `
+	_, err = o.Raw(sql, rsCalendarResearcherId).QueryRows(&item)
+	return
+}
+
 type Researcher struct {
 	AdminId      int    `description:"研究员id"`
 	RealName     string `description:"研究员名称"`
@@ -119,7 +133,7 @@ type CalendarListView struct {
 	CompanyName            string `description:"客户名称"`
 	CompanyStatus          string `description:"客户状态"`
 	RsCalendarResearcherId int    `description:"活动研究员id"`
-	ResearcherId           string    `description:"研究员id"`
+	ResearcherId           string `description:"研究员id"`
 	ResearcherName         string `description:"研究员名称"`
 	StartDate              string `description:"开始日期"`
 	EndDate                string `description:"结束日期"`
@@ -471,7 +485,6 @@ func GetResearcher() (list []*Researcher, err error) {
 	return
 }
 
-
 // 删除
 func DeleteCalendar(rsCalendarId, rsCalendarResearcherId int) (err error) {
 	o := orm.NewOrm()
@@ -548,7 +561,6 @@ func GetRsMattersList(startDate, endDate string, researcherId int) (list []*RsMa
 	return
 }
 
-
 func GetCalendarTypeList(condition string, pars []interface{}, startSize, pageSize int) (list []*CalendarListView, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT a.rs_calendar_id,a.activity_type,a.roadshow_type,a.activity_category,a.roadshow_platform,b.create_time,
@@ -570,7 +582,6 @@ func GetCalendarTypeList(condition string, pars []interface{}, startSize, pageSi
 	return
 }
 
-
 func GetCalendarTypeListCount(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT COUNT(1) AS count FROM(SELECT COUNT(1) AS count
@@ -583,4 +594,4 @@ func GetCalendarTypeListCount(condition string, pars []interface{}) (count int,
 	sql += ` GROUP BY a.rs_calendar_id ) AS t `
 	err = o.Raw(sql, pars).QueryRow(&count)
 	return
-}
+}

+ 3 - 0
services/rs/calendar.go

@@ -369,6 +369,7 @@ func CalendarToSH(rsCalendar roadshow.RsCalendar, researcher roadshow.RsCalendar
 	updateParams := make(map[string]interface{})
 	whereParams["rs_calendar_researcher_id"] = researcher.RsCalendarResearcherId
 	updateParams["is_synced"] = 1
+	updateParams["modify_time"] = time.Now()
 	err = roadshow.UpdateCalendarResearcher(whereParams, updateParams)
 	if err != nil {
 		utils.FileLog.Info("UpdateCalendarResearcher err: " + err.Error())
@@ -474,6 +475,7 @@ func UpdateSHCalendar(rsCalendarId, rsCalendarResearcherId int, activityType, ro
 	updateParams := make(map[string]interface{})
 	whereParams["rs_calendar_researcher_id"] = rsCalendarResearcherId
 	updateParams["is_synced"] = 1
+	updateParams["modify_time"] = time.Now()
 	err = roadshow.UpdateCalendarResearcher(whereParams, updateParams)
 	if err != nil {
 		errMsg += fmt.Sprint("UpdateCalendarResearcher:", relationItem.ThirdCalendarId, ";err:"+err.Error(), ";")
@@ -865,6 +867,7 @@ func SyncCalendarFromShanghai(userPhone, startDate, endDate string) (err error)
 			updateParams := make(map[string]interface{})
 			whereParams["rs_calendar_researcher_id"] = deleteRsCalendarResearcher.RsCalendarResearcherId
 			updateParams["status"] = 4
+			updateParams["modify_time"] = time.Now()
 			tmpErr := roadshow.UpdateCalendarResearcher(whereParams, updateParams)
 			if tmpErr != nil {
 				err = tmpErr