|
@@ -941,577 +941,587 @@ func getTitle(activityType, roadshowType, activityCategory, roadshowPlatform, pr
|
|
|
return title
|
|
|
}
|
|
|
|
|
|
-//// @Title 编辑路演活动接口
|
|
|
-//// @Description编辑路演活动接口
|
|
|
-//// @Param request body roadshow.EditActivityReq true "type json string"
|
|
|
-//// @Success Ret=200 保存成功
|
|
|
-//// @router /edit [post]
|
|
|
-//func (this *CalendarController) Edit() {
|
|
|
-// sysUser := this.AdminWx
|
|
|
-// if sysUser == nil {
|
|
|
-// this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// deleteCache := true
|
|
|
-// cacheKey := "CACHE_RS_ACTIVITY_WX_EDIT_" + strconv.Itoa(sysUser.AdminId)
|
|
|
-// defer func() {
|
|
|
-// if deleteCache {
|
|
|
-// utils.Rc.Delete(cacheKey)
|
|
|
-// }
|
|
|
-// }()
|
|
|
-// if !utils.Rc.SetNX(cacheKey, 1, 5*time.Second) {
|
|
|
-// deleteCache = false
|
|
|
-// this.FailWithMessage("系统处理中,请稍后重试!", "系统处理中,请稍后重试!" + sysUser.RealName + ";data:" + string(this.Ctx.Input.RequestBody))
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// var req roadshow.EditActivityReq
|
|
|
-// err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
-// if err != nil {
|
|
|
-// this.FailWithMessage("参数解析异常", "参数解析失败,Err:" + err.Error())
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// if req.RsCalendarId <= 0 {
|
|
|
-// this.FailWithMessage("参数错误", "参数错误,RsCalendarId<=0")
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// if req.RsCalendarResearcherId <= 0 {
|
|
|
-// this.FailWithMessage("参数错误", "参数错误,RsCalendarResearcherId<=0")
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// if req.ActivityType == "" {
|
|
|
-// this.FailWithMessage("请选择活动类型", "请选择活动类型")
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// if len(req.ResearcherList) <= 0 {
|
|
|
-// this.FailWithMessage("请选择研究员!", "请选择研究员!")
|
|
|
-// return
|
|
|
-// }
|
|
|
-// researcherMap := make(map[int]string)
|
|
|
-// var checkIsAdd []string
|
|
|
-// for _, v := range req.ResearcherList {
|
|
|
-// if v.ResearcherId <= 0 {
|
|
|
-// this.FailWithMessage("请选择研究员!", "请选择研究员!")
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if v.ResearcherName == "" {
|
|
|
-// this.FailWithMessage("请选择研究员!", "请选择研究员!")
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if v.StartDate == "" {
|
|
|
-// this.FailWithMessage("请选择开始日期!", "请选择开始日期!")
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if v.EndDate == "" {
|
|
|
-// this.FailWithMessage("请选择结束日期!", "请选择结束日期!")
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if v.StartTime == "" {
|
|
|
-// this.FailWithMessage("请选择开始时间!", "请选择开始时间!")
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if v.EndTime == "" {
|
|
|
-// this.FailWithMessage("请选择结束时间!", "请选择结束时间!")
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if v.StartWeek == "" {
|
|
|
-// this.FailWithMessage("请选择周!", "请选择周!")
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// if v.EndWeek == "" {
|
|
|
-// this.FailWithMessage("请选择周!", "请选择周!")
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// if realName, ok := researcherMap[v.ResearcherId]; ok {
|
|
|
-// br.Msg = "研究员:" + realName + " 被重复选择"
|
|
|
-// return
|
|
|
-// }
|
|
|
-// researcherMap[v.ResearcherId] = v.ResearcherName
|
|
|
-//
|
|
|
-// startDateTime := v.StartDate + " " + v.StartTime
|
|
|
-// endDateTime := v.EndDate + " " + v.EndTime
|
|
|
-//
|
|
|
-// startP, _ := time.ParseInLocation(utils.FormatDateTime, startDateTime, time.Local)
|
|
|
-// endP, _ := time.ParseInLocation(utils.FormatDateTime, endDateTime, time.Local)
|
|
|
-//
|
|
|
-// if startP.Before(time.Now()) || startP.Equal(time.Now()) {
|
|
|
-// br.Msg = "活动开始时间不能小于当前时间!"
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// if endP.Before(time.Now()) || endP.Equal(time.Now()) {
|
|
|
-// br.Msg = "活动结束时间不能小于当前时间!"
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// if startP.After(endP) || startP.Equal(endP) {
|
|
|
-// br.Msg = "活动开始时间应小于结束时间!"
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// /*
|
|
|
-// 时间冲突时,提示:xxx时间已被占用
|
|
|
-// 当有任意一个研究员时间有冲突时,所有申请订单都不发送。
|
|
|
-// */
|
|
|
-//
|
|
|
-// rsCalendarResearcherItem, err := roadshow.GetRsCalendarResearcherByRsCalendarIdAndResearcherId(req.RsCalendarId, v.ResearcherId)
|
|
|
-// var isAdd bool
|
|
|
-// if err != nil {
|
|
|
-// if err.Error() == utils.ErrNoRow() {
|
|
|
-// isAdd = true
|
|
|
-// } else {
|
|
|
-// br.Msg = "获取数据失败!"
|
|
|
-// br.ErrMsg = "获取数据失败!GetRsCalendarResearcherByRsCalendarIdAndResearcherId:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// }
|
|
|
-// var rsCalendarResearcherId int
|
|
|
-// if rsCalendarResearcherItem == nil {
|
|
|
-// isAdd = true
|
|
|
-// } else {
|
|
|
-// rsCalendarResearcherId = rsCalendarResearcherItem.RsCalendarResearcherId
|
|
|
-// }
|
|
|
-//
|
|
|
-// //同步上海数据
|
|
|
-// researcherInfo, err := system.GetSysAdminById(v.ResearcherId)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "研究员异常"
|
|
|
-// return
|
|
|
-// }
|
|
|
-// _ = roadshowService.SyncCalendarFromShanghai(researcherInfo.Mobile, v.StartDate, v.EndDate)
|
|
|
-//
|
|
|
-// //校验事项时间冲突
|
|
|
-// {
|
|
|
-// if isAdd || (rsCalendarResearcherItem != nil && (rsCalendarResearcherItem.StartDate != v.StartDate ||
|
|
|
-// rsCalendarResearcherItem.StartTime != v.StartTime ||
|
|
|
-// rsCalendarResearcherItem.EndDate != v.EndDate ||
|
|
|
-// rsCalendarResearcherItem.EndTime != v.EndTime)) {
|
|
|
-//
|
|
|
-// matterCount, err := roadshowService.CheckMatters(startDateTime, endDateTime, v.ResearcherId, 0)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "时间冲突检测失败!"
|
|
|
-// br.ErrMsg = "时间冲突检测失败-CheckMattersCount!Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if matterCount > 0 {
|
|
|
-// checkIsAdd = append(checkIsAdd, v.ResearcherName)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// //校验活动时间冲突
|
|
|
-// {
|
|
|
-// if isAdd || (rsCalendarResearcherItem != nil && (rsCalendarResearcherItem.StartDate != v.StartDate ||
|
|
|
-// rsCalendarResearcherItem.StartTime != v.StartTime ||
|
|
|
-// rsCalendarResearcherItem.EndDate != v.EndDate ||
|
|
|
-// rsCalendarResearcherItem.EndTime != v.EndTime)) {
|
|
|
-//
|
|
|
-// calendarCount, err := roadshowService.CheckCalendar(startDateTime, endDateTime, "1,2", v.ResearcherId, rsCalendarResearcherId)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "时间冲突检测失败!"
|
|
|
-// br.ErrMsg = "时间冲突检测失败-CheckCalendarResearcherCount!Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if calendarCount > 0 {
|
|
|
-// checkIsAdd = append(checkIsAdd, v.ResearcherName)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// if len(checkIsAdd) > 0 {
|
|
|
-// br.Msg = strings.Join(checkIsAdd, ",") + "时间已被占用!"
|
|
|
-// br.ErrMsg = "时间冲突检测失败-CheckMattersCount!"
|
|
|
-// br.IsSendEmail = false
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// rsCalendarItem, err := roadshow.GetRsCalendarById(req.RsCalendarId)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "获取数据失败!"
|
|
|
-// br.ErrMsg = "获取数据失败!GetRsCalendarById:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// if rsCalendarItem == nil {
|
|
|
-// br.Msg = "保存失败!"
|
|
|
-// br.ErrMsg = "获取数据失败!GetRsCalendarById:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// calendarWhereParams := make(map[string]interface{})
|
|
|
-// calendarUpdateParams := make(map[string]interface{})
|
|
|
-//
|
|
|
-// calendarWhereParams["rs_calendar_id"] = req.RsCalendarId
|
|
|
-//
|
|
|
-// if req.ActivityType != "" {
|
|
|
-// calendarUpdateParams["activity_type"] = req.ActivityType
|
|
|
-// }
|
|
|
-//
|
|
|
-// if req.RoadshowType != "" {
|
|
|
-// calendarUpdateParams["roadshow_type"] = req.RoadshowType
|
|
|
-// }
|
|
|
-//
|
|
|
-// if req.RoadshowPlatform != "" {
|
|
|
-// calendarUpdateParams["roadshow_platform"] = req.RoadshowPlatform
|
|
|
-// }
|
|
|
-//
|
|
|
-// if req.CompanyId > 0 {
|
|
|
-// calendarUpdateParams["company_id"] = req.CompanyId
|
|
|
-// }
|
|
|
-//
|
|
|
-// if req.CompanyName != "" {
|
|
|
-// calendarUpdateParams["company_name"] = req.CompanyName
|
|
|
-// }
|
|
|
-//
|
|
|
-// if req.ActivityCategory != "" {
|
|
|
-// calendarUpdateParams["activity_category"] = req.ActivityCategory
|
|
|
-// }
|
|
|
-//
|
|
|
-// if req.Theme != "" {
|
|
|
-// calendarUpdateParams["theme"] = req.Theme
|
|
|
-// }
|
|
|
-//
|
|
|
-// if req.CooperationName != "" {
|
|
|
-// calendarUpdateParams["cooperation_name"] = req.CooperationName
|
|
|
-// }
|
|
|
-//
|
|
|
-// if req.Province != "" {
|
|
|
-// calendarUpdateParams["province"] = req.Province
|
|
|
-// }
|
|
|
-//
|
|
|
-// if req.City != "" {
|
|
|
-// calendarUpdateParams["city"] = req.City
|
|
|
-// }
|
|
|
-//
|
|
|
-// calendarUpdateParams["modify_time"] = time.Now()
|
|
|
-// calendarUpdateParams["title"] = getTitle(req.ActivityType, req.RoadshowType, req.ActivityCategory, req.RoadshowPlatform, req.Province, req.City)
|
|
|
-// err = roadshow.UpdateRsCalendar(calendarWhereParams, calendarUpdateParams)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "保存失败!"
|
|
|
-// br.ErrMsg = "保存失败!UpdateRsCalendar:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// //newResearcherMap := make(map[int]string)
|
|
|
-// go roadshowService.UpdateSHCalendar(req)
|
|
|
-//
|
|
|
-// existList, err := roadshow.GetRsCalendarResearcherByCalendarId(req.RsCalendarId)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "保存失败!"
|
|
|
-// br.ErrMsg = "保存失败!GetRsCalendarResearcherByCalendarId:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// existResearcherMap := make(map[int]string)
|
|
|
-// for _, ev := range existList {
|
|
|
-// existResearcherMap[ev.ResearcherId] = ev.ResearcherName
|
|
|
-// }
|
|
|
-//
|
|
|
-// if rsCalendarItem.ActivityType == "路演" || rsCalendarItem.ActivityType == "公开会议" {
|
|
|
-// for k, v := range req.ResearcherList {
|
|
|
-// rsCalendarResearcherItem, err := roadshow.GetRsCalendarResearcherById(req.RsCalendarResearcherId)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "获取数据失败!"
|
|
|
-// br.ErrMsg = "获取数据失败!GetRsCalendarResearcherById:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// calendarResearcherWhereParams := make(map[string]interface{})
|
|
|
-// calendarResearcherUpdateParams := make(map[string]interface{})
|
|
|
-//
|
|
|
-// calendarResearcherWhereParams["rs_calendar_researcher_id"] = req.RsCalendarResearcherId
|
|
|
-//
|
|
|
-// calendarResearcherUpdateParams["researcher_id"] = v.ResearcherId
|
|
|
-// calendarResearcherUpdateParams["researcher_name"] = v.ResearcherName
|
|
|
-//
|
|
|
-// if rsCalendarResearcherItem.Status == 3 || rsCalendarResearcherItem.Status == 5 {
|
|
|
-// calendarResearcherUpdateParams["status"] = 1
|
|
|
-// }
|
|
|
-// calendarResearcherUpdateParams["start_date"] = v.StartDate
|
|
|
-// calendarResearcherUpdateParams["end_date"] = v.EndDate
|
|
|
-// calendarResearcherUpdateParams["start_time"] = v.StartTime
|
|
|
-// calendarResearcherUpdateParams["end_time"] = v.EndTime
|
|
|
-// calendarResearcherUpdateParams["start_week"] = v.StartWeek
|
|
|
-// calendarResearcherUpdateParams["end_week"] = v.EndWeek
|
|
|
-// calendarResearcherUpdateParams["refuse_reason"] = ""
|
|
|
-// calendarResearcherUpdateParams["refuse_time"] = nil
|
|
|
-// calendarResearcherUpdateParams["delete_reason"] = ""
|
|
|
-// calendarResearcherUpdateParams["approve_time"] = nil
|
|
|
-// calendarResearcherUpdateParams["researcher_sort"] = k + 1
|
|
|
-// calendarResearcherUpdateParams["modify_time"] = time.Now()
|
|
|
-// calendarResearcherUpdateParams["create_time"] = time.Now()
|
|
|
-//
|
|
|
-// err = roadshow.UpdateCalendarResearcher(calendarResearcherWhereParams, calendarResearcherUpdateParams)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "保存失败!"
|
|
|
-// br.ErrMsg = "保存失败!UpdateCalendarResearcher:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if req.EditType == 2 {
|
|
|
-// //模板消息通知
|
|
|
-// go func() {
|
|
|
-// sysAdmin, _ := system.GetSysAdminById(v.ResearcherId)
|
|
|
-// if sysAdmin != nil && req.ActivityType != "内部会议" && req.ActivityType != "报告电话会" {
|
|
|
-// first := "您收到一个新的【" + req.ActivityType + "】申请,请及时处理"
|
|
|
-// keyword1 := sysUser.RealName
|
|
|
-// keyword2 := "--"
|
|
|
-// keyword3 := time.Now().Format(utils.FormatDateTime)
|
|
|
-// startDateSub := v.StartDate[5:]
|
|
|
-// startDateSub = strings.Replace(startDateSub, "-", ".", -1)
|
|
|
-// var keyword4 string
|
|
|
-// if req.ActivityType == "路演" {
|
|
|
-// keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.CompanyName + "(" + req.RoadshowType + req.ActivityType + ")"
|
|
|
-// } else {
|
|
|
-// 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)
|
|
|
-// openIdList, _ := models.GetAdminOpenIdByMobile(sysAdmin.Mobile)
|
|
|
-// if len(openIdList) > 0 {
|
|
|
-// services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, openIdList)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }()
|
|
|
-// }
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// err = roadshow.DeleteRsCalendarResearcher(req.RsCalendarId)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "保存失败!"
|
|
|
-// br.ErrMsg = "保存失败!DeleteRsCalendarResearcher:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// for k, v := range req.ResearcherList {
|
|
|
-// researcher := new(roadshow.RsCalendarResearcher)
|
|
|
-// researcher.RsCalendarId = req.RsCalendarId
|
|
|
-// researcher.ResearcherId = v.ResearcherId
|
|
|
-// researcher.ResearcherName = v.ResearcherName
|
|
|
-// researcher.StartDate = v.StartDate
|
|
|
-// researcher.EndDate = v.EndDate
|
|
|
-// researcher.StartTime = v.StartTime
|
|
|
-// researcher.EndTime = v.EndTime
|
|
|
-// researcher.StartWeek = v.StartWeek
|
|
|
-// researcher.EndWeek = v.EndWeek
|
|
|
-// researcher.CreateTime = time.Now()
|
|
|
-// researcher.ModifyTime = time.Now()
|
|
|
-// researcher.ResearcherSort = k + 1
|
|
|
-// if req.ActivityType == "路演" || req.ActivityType == "公开会议" {
|
|
|
-// researcher.Status = 1
|
|
|
-// } else {
|
|
|
-// researcher.Status = 2
|
|
|
-// }
|
|
|
-// rsCalendarResearcherId, err := roadshow.AddRsCalendarResearcher(researcher)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "保存失败!"
|
|
|
-// br.ErrMsg = "保存日历活动-研究员信息失败!Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// go func() {
|
|
|
-// sysAdmin, _ := system.GetSysAdminById(v.ResearcherId)
|
|
|
-// if sysAdmin != nil && req.ActivityType != "内部会议" && req.ActivityType != "报告电话会" {
|
|
|
-// first := "您收到一个新的【" + req.ActivityType + "】申请,请及时处理"
|
|
|
-// keyword1 := sysUser.RealName
|
|
|
-// keyword2 := "--"
|
|
|
-// keyword3 := time.Now().Format(utils.FormatDateTime)
|
|
|
-// startDateSub := v.StartDate[5:]
|
|
|
-// startDateSub = strings.Replace(startDateSub, "-", ".", -1)
|
|
|
-// var keyword4 string
|
|
|
-// if req.ActivityType == "路演" {
|
|
|
-// keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.CompanyName + "(" + req.RoadshowType + req.ActivityType + ")"
|
|
|
-// } else {
|
|
|
-// 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))
|
|
|
-// openIdList, _ := models.GetAdminOpenIdByMobile(sysAdmin.Mobile)
|
|
|
-// if len(openIdList) > 0 {
|
|
|
-// services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, openIdList)
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// }()
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// //for k, v := range req.ResearcherList {
|
|
|
-// // rsCalendarResearcherItem, err := roadshow.GetRsCalendarResearcherById(req.RsCalendarResearcherId)
|
|
|
-// // var isAdd bool
|
|
|
-// // if err != nil {
|
|
|
-// // if err.Error() == utils.ErrNoRow() {
|
|
|
-// // isAdd = true
|
|
|
-// // } else {
|
|
|
-// // br.Msg = "获取数据失败!"
|
|
|
-// // br.ErrMsg = "获取数据失败!GetRsCalendarResearcherById:" + err.Error()
|
|
|
-// // return
|
|
|
-// // }
|
|
|
-// // }
|
|
|
-// // if rsCalendarResearcherItem == nil {
|
|
|
-// // isAdd = true
|
|
|
-// // }
|
|
|
-// // if _, ok := existResearcherMap[v.ResearcherId]; !ok {
|
|
|
-// // isAdd = true
|
|
|
-// // }
|
|
|
-// // fmt.Println("isAdd:", isAdd)
|
|
|
-// // if isAdd {
|
|
|
-// // exist, err := roadshow.GetRsCalendarResearcherExist(req.RsCalendarResearcherId, req.RsCalendarId, v.ResearcherId)
|
|
|
-// // if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
-// // br.Msg = "保存失败!"
|
|
|
-// // br.ErrMsg = "保存失败!GetRsCalendarResearcherExist:" + err.Error()
|
|
|
-// // return
|
|
|
-// // }
|
|
|
-// // if exist > 0 {
|
|
|
-// // br.Msg = "研究员 " + v.ResearcherName + " 已存在相同活动"
|
|
|
-// // br.ErrMsg = "研究员 " + v.ResearcherName + " 已存在相同活动"
|
|
|
-// // return
|
|
|
-// // }
|
|
|
-// // researcher := new(roadshow.RsCalendarResearcher)
|
|
|
-// // researcher.RsCalendarId = req.RsCalendarId
|
|
|
-// // researcher.ResearcherId = v.ResearcherId
|
|
|
-// // researcher.ResearcherName = v.ResearcherName
|
|
|
-// // researcher.StartDate = v.StartDate
|
|
|
-// // researcher.EndDate = v.EndDate
|
|
|
-// // researcher.StartTime = v.StartTime
|
|
|
-// // researcher.EndTime = v.EndTime
|
|
|
-// // researcher.StartWeek = v.StartWeek
|
|
|
-// // researcher.EndWeek = v.EndWeek
|
|
|
-// // researcher.CreateTime = time.Now()
|
|
|
-// // researcher.ModifyTime = time.Now()
|
|
|
-// // researcher.ResearcherSort = k + 1
|
|
|
-// // if req.ActivityType == "路演" || req.ActivityType == "公开会议" {
|
|
|
-// // researcher.Status = 1
|
|
|
-// // } else {
|
|
|
-// // researcher.Status = 2
|
|
|
-// // }
|
|
|
-// // rsCalendarResearcherId, err := roadshow.AddRsCalendarResearcher(researcher)
|
|
|
-// // if err != nil {
|
|
|
-// // br.Msg = "保存失败!"
|
|
|
-// // br.ErrMsg = "保存日历活动-研究员信息失败!Err:" + err.Error()
|
|
|
-// // return
|
|
|
-// // }
|
|
|
-// //
|
|
|
-// // //模板消息通知
|
|
|
-// // {
|
|
|
-// // sysAdmin, _ := system.GetSysAdminById(v.ResearcherId)
|
|
|
-// // if sysAdmin != nil && req.ActivityType != "内部会议" && req.ActivityType != "报告电话会" {
|
|
|
-// // first := "您收到一个新的【" + req.ActivityType + "】申请,请及时处理"
|
|
|
-// // keyword1 := sysUser.RealName
|
|
|
-// // keyword2 := "--"
|
|
|
-// // keyword3 := time.Now().Format(utils.FormatDateTime)
|
|
|
-// // startDateSub := v.StartDate[5:]
|
|
|
-// // startDateSub = strings.Replace(startDateSub, "-", ".", -1)
|
|
|
-// // var keyword4 string
|
|
|
-// // if req.ActivityType == "路演" {
|
|
|
-// // keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.CompanyName + "(" + req.RoadshowType + req.ActivityType + ")"
|
|
|
-// // } else {
|
|
|
-// // 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))
|
|
|
-// // openIdList, _ := models.GetOpenIdListByMobile(sysAdmin.Mobile)
|
|
|
-// // if len(openIdList) > 0 {
|
|
|
-// // go services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, openIdList)
|
|
|
-// // }
|
|
|
-// // }
|
|
|
-// // }
|
|
|
-// // } else {
|
|
|
-// // calendarResearcherWhereParams := make(map[string]interface{})
|
|
|
-// // calendarResearcherUpdateParams := make(map[string]interface{})
|
|
|
-// //
|
|
|
-// // calendarResearcherWhereParams["rs_calendar_researcher_id"] = req.RsCalendarResearcherId
|
|
|
-// //
|
|
|
-// // exist, err := roadshow.GetRsCalendarResearcherExist(req.RsCalendarResearcherId, req.RsCalendarId, v.ResearcherId)
|
|
|
-// // if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
-// // br.Msg = "保存失败!"
|
|
|
-// // br.ErrMsg = "保存失败!GetRsCalendarResearcherExist:" + err.Error()
|
|
|
-// // return
|
|
|
-// // }
|
|
|
-// // if exist > 0 {
|
|
|
-// // br.Msg = "研究员 " + v.ResearcherName + " 已存在相同活动"
|
|
|
-// // br.ErrMsg = "研究员 " + v.ResearcherName + " 已存在相同活动"
|
|
|
-// // return
|
|
|
-// // }
|
|
|
-// //
|
|
|
-// // calendarResearcherUpdateParams["researcher_id"] = v.ResearcherId
|
|
|
-// // calendarResearcherUpdateParams["researcher_name"] = v.ResearcherName
|
|
|
-// //
|
|
|
-// // if rsCalendarResearcherItem.Status == 3 || rsCalendarResearcherItem.Status == 5 {
|
|
|
-// // calendarResearcherUpdateParams["status"] = 1
|
|
|
-// // }
|
|
|
-// // calendarResearcherUpdateParams["start_date"] = v.StartDate
|
|
|
-// // calendarResearcherUpdateParams["end_date"] = v.EndDate
|
|
|
-// // calendarResearcherUpdateParams["start_time"] = v.StartTime
|
|
|
-// // calendarResearcherUpdateParams["end_time"] = v.EndTime
|
|
|
-// // calendarResearcherUpdateParams["start_week"] = v.StartWeek
|
|
|
-// // calendarResearcherUpdateParams["end_week"] = v.EndWeek
|
|
|
-// // calendarResearcherUpdateParams["refuse_reason"] = ""
|
|
|
-// // calendarResearcherUpdateParams["refuse_time"] = nil
|
|
|
-// // calendarResearcherUpdateParams["delete_reason"] = ""
|
|
|
-// // calendarResearcherUpdateParams["approve_time"] = nil
|
|
|
-// // calendarResearcherUpdateParams["researcher_sort"] = k + 1
|
|
|
-// // calendarResearcherUpdateParams["modify_time"] = time.Now()
|
|
|
-// // calendarResearcherUpdateParams["create_time"] = time.Now()
|
|
|
-// //
|
|
|
-// // err = roadshow.UpdateCalendarResearcher(calendarResearcherWhereParams, calendarResearcherUpdateParams)
|
|
|
-// // if err != nil {
|
|
|
-// // br.Msg = "保存失败!"
|
|
|
-// // br.ErrMsg = "保存失败!UpdateCalendarResearcher:" + err.Error()
|
|
|
-// // return
|
|
|
-// // }
|
|
|
-// // if req.EditType == 2 {
|
|
|
-// // //模板消息通知
|
|
|
-// // {
|
|
|
-// // sysAdmin, _ := system.GetSysAdminById(v.ResearcherId)
|
|
|
-// // if sysAdmin != nil && req.ActivityType != "内部会议" && req.ActivityType != "报告电话会" {
|
|
|
-// // first := "您收到一个新的【" + req.ActivityType + "】申请,请及时处理"
|
|
|
-// // keyword1 := sysUser.RealName
|
|
|
-// // keyword2 := "--"
|
|
|
-// // keyword3 := time.Now().Format(utils.FormatDateTime)
|
|
|
-// // startDateSub := v.StartDate[5:]
|
|
|
-// // startDateSub = strings.Replace(startDateSub, "-", ".", -1)
|
|
|
-// // var keyword4 string
|
|
|
-// // if req.ActivityType == "路演" {
|
|
|
-// // keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.CompanyName + "(" + req.RoadshowType + req.ActivityType + ")"
|
|
|
-// // } else {
|
|
|
-// // 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)
|
|
|
-// // openIdList, _ := models.GetOpenIdListByMobile(sysAdmin.Mobile)
|
|
|
-// // if len(openIdList) > 0 {
|
|
|
-// // go services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, openIdList)
|
|
|
-// // }
|
|
|
-// // }
|
|
|
-// // }
|
|
|
-// // }
|
|
|
-// //
|
|
|
-// // }
|
|
|
-// // newResearcherMap[v.ResearcherId] = v.ResearcherName
|
|
|
-// //}
|
|
|
-// //处理删除情况
|
|
|
-// //{
|
|
|
-// // if req.EditType == 1 {
|
|
|
-// // researchList, err := roadshow.GetRsCalendarResearcherListByRsCalendarId(req.RsCalendarId)
|
|
|
-// // if err != nil {
|
|
|
-// // br.Msg = "保存失败!"
|
|
|
-// // br.ErrMsg = "保存失败!UpdateCalendarResearcher:" + err.Error()
|
|
|
-// // return
|
|
|
-// // }
|
|
|
-// // for _, ev := range researchList {
|
|
|
-// // if _, ok := newResearcherMap[ev.ResearcherId]; !ok {
|
|
|
-// // roadshow.DeleteCalendar(req.RsCalendarId, ev.RsCalendarResearcherId)
|
|
|
-// // }
|
|
|
-// // }
|
|
|
-// // }
|
|
|
-// //}
|
|
|
-// br.Ret = 200
|
|
|
-// br.Success = true
|
|
|
-// br.Msg = "保存成功"
|
|
|
-// br.IsAddLog = true
|
|
|
-//}
|
|
|
+// @Title 编辑路演活动接口
|
|
|
+// @Description编辑路演活动接口
|
|
|
+// @Param request body roadshow.EditActivityReq true "type json string"
|
|
|
+// @Success Ret=200 保存成功
|
|
|
+// @router /edit [post]
|
|
|
+func (this *CalendarController) Edit() {
|
|
|
+ sysUser := this.AdminWx
|
|
|
+ if sysUser == nil {
|
|
|
+ this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ deleteCache := true
|
|
|
+ cacheKey := "CACHE_RS_ACTIVITY_WX_EDIT_" + strconv.Itoa(sysUser.AdminId)
|
|
|
+ defer func() {
|
|
|
+ if deleteCache {
|
|
|
+ utils.Rc.Delete(cacheKey)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ if !utils.Rc.SetNX(cacheKey, 1, 5*time.Second) {
|
|
|
+ deleteCache = false
|
|
|
+ this.FailWithMessage("系统处理中,请稍后重试!", "系统处理中,请稍后重试!"+sysUser.RealName+";data:"+string(this.Ctx.Input.RequestBody))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var req roadshow.EditActivityReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("参数解析异常", "参数解析失败,Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.RsCalendarId <= 0 {
|
|
|
+ this.FailWithMessage("参数错误", "参数错误,RsCalendarId<=0")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.RsCalendarResearcherId <= 0 {
|
|
|
+ this.FailWithMessage("参数错误", "参数错误,RsCalendarResearcherId<=0")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.ActivityType == "" {
|
|
|
+ this.FailWithMessage("请选择活动类型", "请选择活动类型")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(req.ResearcherList) <= 0 {
|
|
|
+ this.FailWithMessage("请选择研究员!", "请选择研究员!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ researcherMap := make(map[int]string)
|
|
|
+ var checkIsAdd []string
|
|
|
+ for _, v := range req.ResearcherList {
|
|
|
+ if v.ResearcherId <= 0 {
|
|
|
+ this.FailWithMessage("请选择研究员!", "请选择研究员!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if v.ResearcherName == "" {
|
|
|
+ this.FailWithMessage("请选择研究员!", "请选择研究员!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if v.StartDate == "" {
|
|
|
+ this.FailWithMessage("请选择开始日期!", "请选择开始日期!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if v.EndDate == "" {
|
|
|
+ this.FailWithMessage("请选择结束日期!", "请选择结束日期!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if v.StartTime == "" {
|
|
|
+ this.FailWithMessage("请选择开始时间!", "请选择开始时间!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if v.EndTime == "" {
|
|
|
+ this.FailWithMessage("请选择结束时间!", "请选择结束时间!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if v.StartWeek == "" {
|
|
|
+ this.FailWithMessage("请选择周!", "请选择周!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if v.EndWeek == "" {
|
|
|
+ this.FailWithMessage("请选择周!", "请选择周!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if realName, ok := researcherMap[v.ResearcherId]; ok {
|
|
|
+ this.FailWithMessage("研究员:"+realName+" 被重复选择", "研究员:"+realName+" 被重复选择")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ researcherMap[v.ResearcherId] = v.ResearcherName
|
|
|
+
|
|
|
+ startDateTime := v.StartDate + " " + v.StartTime
|
|
|
+ endDateTime := v.EndDate + " " + v.EndTime
|
|
|
+
|
|
|
+ startP, _ := time.ParseInLocation(utils.FormatDateTime, startDateTime, time.Local)
|
|
|
+ endP, _ := time.ParseInLocation(utils.FormatDateTime, endDateTime, time.Local)
|
|
|
+
|
|
|
+ if startP.Before(time.Now()) || startP.Equal(time.Now()) {
|
|
|
+ this.FailWithMessage("活动开始时间不能小于当前时间!", "活动开始时间不能小于当前时间!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if endP.Before(time.Now()) || endP.Equal(time.Now()) {
|
|
|
+ this.FailWithMessage("活动结束时间不能小于当前时间!", "活动结束时间不能小于当前时间!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if startP.After(endP) || startP.Equal(endP) {
|
|
|
+ this.FailWithMessage("活动开始时间应小于结束时间!", "活动开始时间应小于结束时间!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ 时间冲突时,提示:xxx时间已被占用
|
|
|
+ 当有任意一个研究员时间有冲突时,所有申请订单都不发送。
|
|
|
+ */
|
|
|
+
|
|
|
+ rsCalendarResearcherItem, err := roadshow.GetRsCalendarResearcherByRsCalendarIdAndResearcherId(req.RsCalendarId, v.ResearcherId)
|
|
|
+ var isAdd bool
|
|
|
+ if err != nil {
|
|
|
+ if err.Error() == utils.ErrNoRow() {
|
|
|
+ isAdd = true
|
|
|
+ } else {
|
|
|
+ this.FailWithMessage("获取数据失败!", "获取数据失败!GetRsCalendarResearcherByRsCalendarIdAndResearcherId:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var rsCalendarResearcherId int
|
|
|
+ if rsCalendarResearcherItem == nil {
|
|
|
+ isAdd = true
|
|
|
+ } else {
|
|
|
+ rsCalendarResearcherId = rsCalendarResearcherItem.RsCalendarResearcherId
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步上海数据
|
|
|
+ researcherInfo, err := admin.GetAdminById(v.ResearcherId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("研究员异常!", "研究员异常")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ _ = roadshowService.SyncCalendarFromShanghai(researcherInfo.Mobile, v.StartDate, v.EndDate)
|
|
|
+
|
|
|
+ //校验事项时间冲突
|
|
|
+ {
|
|
|
+ if isAdd || (rsCalendarResearcherItem != nil && (rsCalendarResearcherItem.StartDate != v.StartDate ||
|
|
|
+ rsCalendarResearcherItem.StartTime != v.StartTime ||
|
|
|
+ rsCalendarResearcherItem.EndDate != v.EndDate ||
|
|
|
+ rsCalendarResearcherItem.EndTime != v.EndTime)) {
|
|
|
+
|
|
|
+ matterCount, err := roadshowService.CheckMatters(startDateTime, endDateTime, v.ResearcherId, 0)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("时间冲突检测失败!", "时间冲突检测失败-CheckMattersCount!Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if matterCount > 0 {
|
|
|
+ checkIsAdd = append(checkIsAdd, v.ResearcherName)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验活动时间冲突
|
|
|
+ {
|
|
|
+ if isAdd || (rsCalendarResearcherItem != nil && (rsCalendarResearcherItem.StartDate != v.StartDate ||
|
|
|
+ rsCalendarResearcherItem.StartTime != v.StartTime ||
|
|
|
+ rsCalendarResearcherItem.EndDate != v.EndDate ||
|
|
|
+ rsCalendarResearcherItem.EndTime != v.EndTime)) {
|
|
|
+
|
|
|
+ calendarCount, err := roadshowService.CheckCalendar(startDateTime, endDateTime, "1,2", v.ResearcherId, rsCalendarResearcherId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("时间冲突检测失败!", "时间冲突检测失败-CheckCalendarResearcherCount!Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if calendarCount > 0 {
|
|
|
+ checkIsAdd = append(checkIsAdd, v.ResearcherName)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(checkIsAdd) > 0 {
|
|
|
+ this.FailWithMessage(strings.Join(checkIsAdd, ",")+"时间已被占用!", "时间冲突检测失败-CheckMattersCount!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ rsCalendarItem, err := roadshow.GetRsCalendarById(req.RsCalendarId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败!", "获取数据失败!GetRsCalendarById:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if rsCalendarItem == nil {
|
|
|
+ this.FailWithMessage("保存失败!", "获取数据失败!GetRsCalendarById:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ calendarWhereParams := make(map[string]interface{})
|
|
|
+ calendarUpdateParams := make(map[string]interface{})
|
|
|
+
|
|
|
+ calendarWhereParams["rs_calendar_id"] = req.RsCalendarId
|
|
|
+
|
|
|
+ if req.ActivityType != "" {
|
|
|
+ calendarUpdateParams["activity_type"] = req.ActivityType
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.RoadshowType != "" {
|
|
|
+ calendarUpdateParams["roadshow_type"] = req.RoadshowType
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.RoadshowPlatform != "" {
|
|
|
+ calendarUpdateParams["roadshow_platform"] = req.RoadshowPlatform
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.CompanyId > 0 {
|
|
|
+ calendarUpdateParams["company_id"] = req.CompanyId
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.CompanyName != "" {
|
|
|
+ calendarUpdateParams["company_name"] = req.CompanyName
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.ActivityCategory != "" {
|
|
|
+ calendarUpdateParams["activity_category"] = req.ActivityCategory
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.Theme != "" {
|
|
|
+ calendarUpdateParams["theme"] = req.Theme
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.CooperationName != "" {
|
|
|
+ calendarUpdateParams["cooperation_name"] = req.CooperationName
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.Province != "" {
|
|
|
+ calendarUpdateParams["province"] = req.Province
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.City != "" {
|
|
|
+ calendarUpdateParams["city"] = req.City
|
|
|
+ }
|
|
|
+
|
|
|
+ calendarUpdateParams["modify_time"] = time.Now()
|
|
|
+ calendarUpdateParams["title"] = getTitle(req.ActivityType, req.RoadshowType, req.ActivityCategory, req.RoadshowPlatform, req.Province, req.City)
|
|
|
+ err = roadshow.UpdateRsCalendar(calendarWhereParams, calendarUpdateParams)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("保存失败!", "保存失败!UpdateRsCalendar:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //newResearcherMap := make(map[int]string)
|
|
|
+ go roadshowService.UpdateSHCalendar(req)
|
|
|
+
|
|
|
+ existList, err := roadshow.GetRsCalendarResearcherByCalendarId(req.RsCalendarId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("保存失败!", "保存失败!GetRsCalendarResearcherByCalendarId:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ existResearcherMap := make(map[int]string)
|
|
|
+ for _, ev := range existList {
|
|
|
+ existResearcherMap[ev.ResearcherId] = ev.ResearcherName
|
|
|
+ }
|
|
|
+
|
|
|
+ if rsCalendarItem.ActivityType == "路演" || rsCalendarItem.ActivityType == "公开会议" {
|
|
|
+ for k, v := range req.ResearcherList {
|
|
|
+ rsCalendarResearcherItem, err := roadshow.GetRsCalendarResearcherById(req.RsCalendarResearcherId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败!", "获取数据失败!GetRsCalendarResearcherById:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ calendarResearcherWhereParams := make(map[string]interface{})
|
|
|
+ calendarResearcherUpdateParams := make(map[string]interface{})
|
|
|
+
|
|
|
+ calendarResearcherWhereParams["rs_calendar_researcher_id"] = req.RsCalendarResearcherId
|
|
|
+
|
|
|
+ calendarResearcherUpdateParams["researcher_id"] = v.ResearcherId
|
|
|
+ calendarResearcherUpdateParams["researcher_name"] = v.ResearcherName
|
|
|
+
|
|
|
+ if rsCalendarResearcherItem.Status == 3 || rsCalendarResearcherItem.Status == 5 {
|
|
|
+ calendarResearcherUpdateParams["status"] = 1
|
|
|
+ }
|
|
|
+ calendarResearcherUpdateParams["start_date"] = v.StartDate
|
|
|
+ calendarResearcherUpdateParams["end_date"] = v.EndDate
|
|
|
+ calendarResearcherUpdateParams["start_time"] = v.StartTime
|
|
|
+ calendarResearcherUpdateParams["end_time"] = v.EndTime
|
|
|
+ calendarResearcherUpdateParams["start_week"] = v.StartWeek
|
|
|
+ calendarResearcherUpdateParams["end_week"] = v.EndWeek
|
|
|
+ calendarResearcherUpdateParams["refuse_reason"] = ""
|
|
|
+ calendarResearcherUpdateParams["refuse_time"] = nil
|
|
|
+ calendarResearcherUpdateParams["delete_reason"] = ""
|
|
|
+ calendarResearcherUpdateParams["approve_time"] = nil
|
|
|
+ calendarResearcherUpdateParams["researcher_sort"] = k + 1
|
|
|
+ calendarResearcherUpdateParams["modify_time"] = time.Now()
|
|
|
+ calendarResearcherUpdateParams["create_time"] = time.Now()
|
|
|
+
|
|
|
+ err = roadshow.UpdateCalendarResearcher(calendarResearcherWhereParams, calendarResearcherUpdateParams)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("保存失败!", "保存失败!UpdateCalendarResearcher:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if req.EditType == 2 {
|
|
|
+ //模板消息通知
|
|
|
+ go func() {
|
|
|
+ sysAdmin, _ := admin.GetAdminById(v.ResearcherId)
|
|
|
+ if sysAdmin != nil && req.ActivityType != "内部会议" && req.ActivityType != "报告电话会" {
|
|
|
+ first := "您收到一个新的【" + req.ActivityType + "】申请,请及时处理"
|
|
|
+ keyword1 := sysUser.RealName
|
|
|
+ keyword2 := "--"
|
|
|
+ keyword3 := time.Now().Format(utils.FormatDateTime)
|
|
|
+ startDateSub := v.StartDate[5:]
|
|
|
+ startDateSub = strings.Replace(startDateSub, "-", ".", -1)
|
|
|
+ var keyword4 string
|
|
|
+ if req.ActivityType == "路演" {
|
|
|
+ keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.CompanyName + "(" + req.RoadshowType + req.ActivityType + ")"
|
|
|
+ } else {
|
|
|
+ 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)
|
|
|
+ openIdList, _ := models.GetAdminOpenIdByMobile(sysAdmin.Mobile)
|
|
|
+ if len(openIdList) > 0 {
|
|
|
+ services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, sysAdmin.Mobile)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ err = roadshow.DeleteRsCalendarResearcher(req.RsCalendarId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("保存失败!", "保存失败!DeleteRsCalendarResearcher:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for k, v := range req.ResearcherList {
|
|
|
+ researcher := new(roadshow.RsCalendarResearcher)
|
|
|
+ researcher.RsCalendarId = req.RsCalendarId
|
|
|
+ researcher.ResearcherId = v.ResearcherId
|
|
|
+ researcher.ResearcherName = v.ResearcherName
|
|
|
+ researcher.StartDate = v.StartDate
|
|
|
+ researcher.EndDate = v.EndDate
|
|
|
+ researcher.StartTime = v.StartTime
|
|
|
+ researcher.EndTime = v.EndTime
|
|
|
+ researcher.StartWeek = v.StartWeek
|
|
|
+ researcher.EndWeek = v.EndWeek
|
|
|
+ researcher.CreateTime = time.Now()
|
|
|
+ researcher.ModifyTime = time.Now()
|
|
|
+ researcher.ResearcherSort = k + 1
|
|
|
+ if req.ActivityType == "路演" || req.ActivityType == "公开会议" {
|
|
|
+ researcher.Status = 1
|
|
|
+ } else {
|
|
|
+ researcher.Status = 2
|
|
|
+ }
|
|
|
+ rsCalendarResearcherId, err := roadshow.AddRsCalendarResearcher(researcher)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("保存失败!", "保存日历活动-研究员信息失败!Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ go func() {
|
|
|
+ sysAdmin, _ := admin.GetAdminById(v.ResearcherId)
|
|
|
+ if sysAdmin != nil && req.ActivityType != "内部会议" && req.ActivityType != "报告电话会" {
|
|
|
+ first := "您收到一个新的【" + req.ActivityType + "】申请,请及时处理"
|
|
|
+ keyword1 := sysUser.RealName
|
|
|
+ keyword2 := "--"
|
|
|
+ keyword3 := time.Now().Format(utils.FormatDateTime)
|
|
|
+ startDateSub := v.StartDate[5:]
|
|
|
+ startDateSub = strings.Replace(startDateSub, "-", ".", -1)
|
|
|
+ var keyword4 string
|
|
|
+ if req.ActivityType == "路演" {
|
|
|
+ keyword4 = startDateSub + "(" + v.StartWeek + ")" + " " + v.StartTime[:5] + "~" + v.EndTime[:5] + " ," + req.CompanyName + "(" + req.RoadshowType + req.ActivityType + ")"
|
|
|
+ } else {
|
|
|
+ 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))
|
|
|
+ openIdList, _ := models.GetAdminOpenIdByMobile(sysAdmin.Mobile)
|
|
|
+ if len(openIdList) > 0 {
|
|
|
+ services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, sysAdmin.Mobile)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.OkDetailed(nil, "保存成功")
|
|
|
+}
|
|
|
+
|
|
|
+// ResearcherList
|
|
|
+// @Title 研究员列表
|
|
|
+// @Description 研究员列表接口
|
|
|
+// @Success 200 {object} roadshow.ResearcherGroup
|
|
|
+// @router /researcher/list [get]
|
|
|
+func (this *CalendarController) ResearcherList() {
|
|
|
+ sysUser := this.AdminWx
|
|
|
+ if sysUser == nil {
|
|
|
+ this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ group, err := roadshow.GetResearcherGroup()
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取信息失败!", "获取分组信息失败!Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ researcherList, err := roadshow.GetResearcher()
|
|
|
+ groupMap := make(map[int][]*roadshow.Researcher)
|
|
|
+ for _, v := range researcherList {
|
|
|
+ if v.RoleTypeCode == "ficc_admin" {
|
|
|
+ findItems := groupMap[1]
|
|
|
+ findItems = append(findItems, v)
|
|
|
+ groupMap[1] = findItems
|
|
|
+ } else {
|
|
|
+ if findItems, ok := groupMap[v.GroupId]; ok {
|
|
|
+ findItems = append(findItems, v)
|
|
|
+ groupMap[v.GroupId] = findItems
|
|
|
+ } else {
|
|
|
+ findItems = append(findItems, v)
|
|
|
+ groupMap[v.GroupId] = findItems
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, v := range group {
|
|
|
+ v.ResearcherList = groupMap[v.GroupId]
|
|
|
+ }
|
|
|
+ this.OkDetailed(group, "获取成功")
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 撤回路演活动接口
|
|
|
+// @Description 撤回路演活动接口
|
|
|
+// @Param request body roadshow.AcceptReq true "type json string"
|
|
|
+// @Success Ret=200 保存成功
|
|
|
+// @router /back [post]
|
|
|
+func (this *CalendarController) Back() {
|
|
|
+ sysUser := this.AdminWx
|
|
|
+ if sysUser == nil {
|
|
|
+ this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var req roadshow.AcceptReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("参数解析异常", "参数解析失败,Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.RsCalendarId <= 0 || req.RsCalendarResearcherId <= 0 {
|
|
|
+ this.FailWithMessage("参数错误", "参数错误!RsCalendarId:"+strconv.Itoa(req.RsCalendarId)+";RsCalendarResearcherId:"+strconv.Itoa(req.RsCalendarResearcherId))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ _, err = roadshow.GetRsCalendarById(req.RsCalendarId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败", "获取数据失败!GetRsCalendarById:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ rsCalendarResearcher, err := roadshow.GetRsCalendarResearcherById(req.RsCalendarResearcherId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败", "获取数据失败!GetRsCalendarResearcherById:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if rsCalendarResearcher.Status == 2 {
|
|
|
+ this.FailWithMessage("已接受,不可进行撤回操作!", "已接受,不可进行撤回操作!")
|
|
|
+ return
|
|
|
+ } else if rsCalendarResearcher.Status == 3 {
|
|
|
+ this.FailWithMessage("已拒绝,不可进行撤回操作!", "已拒绝,不可进行撤回操作!")
|
|
|
+ return
|
|
|
+ } else if rsCalendarResearcher.Status == 4 {
|
|
|
+ this.FailWithMessage("已删除,不可进行撤回操作!", "已删除,不可进行撤回操作!")
|
|
|
+ return
|
|
|
+ } else if rsCalendarResearcher.Status == 5 {
|
|
|
+ this.FailWithMessage("已撤回,不可进行重复操作!", "已撤回,不可进行重复操作!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ whereParams := make(map[string]interface{})
|
|
|
+ updateParams := make(map[string]interface{})
|
|
|
+
|
|
|
+ whereParams["rs_calendar_researcher_id"] = req.RsCalendarResearcherId
|
|
|
+ whereParams["rs_calendar_id"] = req.RsCalendarId
|
|
|
+
|
|
|
+ updateParams["status"] = 5
|
|
|
+ updateParams["modify_time"] = time.Now()
|
|
|
+
|
|
|
+ err = roadshow.UpdateCalendarResearcher(whereParams, updateParams)
|
|
|
+
|
|
|
+ //撤回后,需要删除该日程
|
|
|
+ go roadshowService.DeleteSHCalendar(req.RsCalendarResearcherId)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("保存失败", "保存失败!UpdateCalendarResearcher:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.OkDetailed(nil, "撤回成功")
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 删除路演活动接口
|
|
|
+// @Description 删除路演活动接口
|
|
|
+// @Param request body roadshow.DeleteReq true "type json string"
|
|
|
+// @Success Ret=200 保存成功
|
|
|
+// @router /delete [post]
|
|
|
+func (this *CalendarController) Delete() {
|
|
|
+ sysUser := this.AdminWx
|
|
|
+ if sysUser == nil {
|
|
|
+ this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var req roadshow.DeleteReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.RsCalendarId <= 0 || req.RsCalendarResearcherId <= 0 {
|
|
|
+ this.FailWithMessage("参数错误!", "参数错误!RsCalendarId:"+strconv.Itoa(req.RsCalendarId)+";RsCalendarResearcherId:"+strconv.Itoa(req.RsCalendarResearcherId))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ rsCalendarItem, err := roadshow.GetRsCalendarById(req.RsCalendarId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败!", "获取数据失败!GetRsCalendarById:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ rsCalendarResearcherItem, err := roadshow.GetRsCalendarResearcherById(req.RsCalendarResearcherId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败!", "获取数据失败!GetRsCalendarResearcherById:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if rsCalendarItem.ActivityType == "报告电话会" || rsCalendarItem.ActivityType == "内部会议" {
|
|
|
+ err = roadshow.DeleteCalendar(req.RsCalendarId, req.RsCalendarResearcherId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("删除失败!", "删除失败!DeleteCalendar:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ whereParams := make(map[string]interface{})
|
|
|
+ updateParams := make(map[string]interface{})
|
|
|
+
|
|
|
+ whereParams["rs_calendar_researcher_id"] = req.RsCalendarResearcherId
|
|
|
+ whereParams["rs_calendar_id"] = req.RsCalendarId
|
|
|
+
|
|
|
+ updateParams["status"] = 4
|
|
|
+ updateParams["delete_reason"] = req.DeleteReason
|
|
|
+ updateParams["modify_time"] = time.Now()
|
|
|
+ updateParams["delete_time"] = time.Now()
|
|
|
+
|
|
|
+ err = roadshow.UpdateCalendarResearcher(whereParams, updateParams)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("删除失败!", "删除失败!UpdateCalendarResearcher:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //`status` int(11) DEFAULT '0' COMMENT '1:待接受,2:已接受,3:已拒绝,4:已删除,5:已撤回,6:已结束',
|
|
|
+ //待接受、已接受的情况,需要同步删除上海那边的日程
|
|
|
+ if rsCalendarResearcherItem.Status == 1 || rsCalendarResearcherItem.Status == 2 {
|
|
|
+ go roadshowService.DeleteSHCalendar(rsCalendarResearcherItem.RsCalendarResearcherId)
|
|
|
+ }
|
|
|
+ //模板消息通知
|
|
|
+ {
|
|
|
+ go func() {
|
|
|
+ if rsCalendarItem != nil && rsCalendarResearcherItem != nil {
|
|
|
+ sysAdmin, _ := admin.GetAdminById(rsCalendarResearcherItem.ResearcherId)
|
|
|
+ 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)
|
|
|
+ openIdList, _ := models.GetAdminOpenIdByMobile(sysAdmin.Mobile)
|
|
|
+ if len(openIdList) > 0 {
|
|
|
+ services.SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppPath, sysAdmin.Mobile)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ }
|
|
|
+ this.OkDetailed(nil, "删除成功")
|
|
|
+}
|