1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882 |
- package roadshow
- import (
- "encoding/json"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_mobile_admin/controllers"
- "hongze/hongze_mobile_admin/models"
- "hongze/hongze_mobile_admin/models/roadshow"
- "hongze/hongze_mobile_admin/models/tables/admin"
- "hongze/hongze_mobile_admin/services"
- "hongze/hongze_mobile_admin/services/rs"
- "hongze/hongze_mobile_admin/utils"
- "strconv"
- "strings"
- "time"
- )
- //日历
- type CalendarController struct {
- controllers.BaseAuth
- }
- // @Title 新增路演活动接口
- // @Description 新增路演活动接口
- // @Param request body rs.AddActivityReq true "type json string"
- // @Success Ret=200 保存成功
- // @router /add [post]
- func (this *CalendarController) Add() {
- sysUser := this.AdminWx
- if sysUser == nil {
- this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
- return
- }
- deleteCache := true
- cacheKey := "CACHE_RS_ACTIVITY_WX_ADD_" + 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.AddActivityReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- this.FailWithMessage("参数解析异常", "参数解析失败,Err:"+err.Error())
- return
- }
- if len(req.ResearcherList) <= 0 {
- this.FailWithMessage("请选择研究员!", "请选择研究员!")
- return
- }
- researcherMap := make(map[int]string)
- var checkIsAdd []string
- //var tipMsg 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
- }
- 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
- }
- if realName, ok := researcherMap[v.ResearcherId]; ok {
- this.FailWithMessage("研究员:"+realName+" 被重复选择", "研究员:"+realName+" 被重复选择")
- return
- }
- researcherMap[v.ResearcherId] = v.ResearcherName
- //同步上海数据
- researcherInfo, err := admin.GetAdminWxById(v.ResearcherId)
- if err != nil {
- this.FailWithMessage("研究员异常", "获取研究员异常,Err:"+err.Error())
- return
- }
- _ = rs.SyncCalendarFromShanghai(researcherInfo.Mobile, v.StartDate, v.EndDate)
- //校验事项时间冲突
- {
- matterCount, err := rs.CheckMatters(startDateTime, endDateTime, v.ResearcherId, 0)
- if err != nil {
- this.FailWithMessage("时间冲突检测失败!", "时间冲突检测失败-CheckMattersCount!Err:"+err.Error())
- return
- }
- if matterCount > 0 {
- checkIsAdd = append(checkIsAdd, v.ResearcherName)
- }
- }
- //校验活动时间冲突
- {
- calendarCount, err := rs.CheckCalendar(startDateTime, endDateTime, "1,2", v.ResearcherId, 0)
- if err != nil {
- this.FailWithMessage("时间冲突检测失败!", "时间冲突检测失败-CheckCalendar!Err:"+err.Error())
- return
- }
- if calendarCount > 0 {
- checkIsAdd = append(checkIsAdd, v.ResearcherName)
- }
- }
- }
- if len(checkIsAdd) > 0 {
- this.FailWithMessage(strings.Join(checkIsAdd, ",")+" 时间已被占用!", "时间冲突检测失败-CheckMattersCount!")
- return
- }
- rsCalendar := new(roadshow.RsCalendar)
- rsCalendar.SysUserId = sysUser.AdminId
- rsCalendar.SysUserRealName = sysUser.RealName
- rsCalendar.ActivityType = req.ActivityType
- rsCalendar.RoadshowType = req.RoadshowType
- rsCalendar.RoadshowPlatform = req.RoadshowPlatform
- rsCalendar.CompanyId = req.CompanyId
- rsCalendar.CompanyName = req.CompanyName
- rsCalendar.Province = req.Province
- rsCalendar.ProvinceCode = req.ProvinceCode
- rsCalendar.City = req.City
- rsCalendar.CityCode = req.CityCode
- rsCalendar.Theme = req.Theme
- rsCalendar.CooperationName = req.CooperationName
- rsCalendar.CreateTime = time.Now()
- rsCalendar.ModifyTime = time.Now()
- rsCalendar.ActivityCategory = req.ActivityCategory
- rsCalendar.Source = 0
- rsCalendar.Title = getTitle(req.ActivityType, req.RoadshowType, req.ActivityCategory, req.RoadshowPlatform, req.Province, req.City)
- rsCalendarId, err := roadshow.AddRsCalendar(rsCalendar)
- if err != nil {
- this.FailWithMessage("保存失败", "保存日历活动信息失败!Err:"+err.Error())
- return
- }
- //if researcherId != 99 {
- for k, v := range req.ResearcherList {
- researcher := new(roadshow.RsCalendarResearcher)
- researcher.RsCalendarId = int(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
- }
- rsCalendar.RsCalendarId = int(rsCalendarId)
- researcher.RsCalendarResearcherId = int(rsCalendarResearcherId)
- go rs.CalendarToSH(*rsCalendar, *researcher)
- //模板消息通知
- {
- go func() {
- var wxAppPath string
- sysAdmin, _ := admin.GetAdminWxById(v.ResearcherId)
- if sysAdmin != nil {
- if req.ActivityType == "路演" || req.ActivityType == "公开会议" {
- wxAppPath = "pages-approve/activity/detail?RsCalendarId=" + strconv.Itoa(int(rsCalendarId)) + "&RsCalendarResearcherId=" + strconv.Itoa(int(rsCalendarResearcherId))
- 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(int(rsCalendarId)) + "&RsCalendarResearcherId=" + strconv.Itoa(int(rsCalendarResearcherId))
- if sysAdmin.OpenId != "" {
- go services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, sysAdmin.Mobile)
- }
- } else {
- wxAppPath = ""
- 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 := "--"
- if sysAdmin.OpenId != "" {
- go services.SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, "", wxAppPath, sysAdmin.Mobile)
- }
- }
- }
- }()
- }
- }
- this.OkDetailed(nil, "保存成功")
- }
- // CalendarList
- // @Title 我的日历列表
- // @Description 我的日历列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param Status query int true "1:待接受,2:包含,已接受,已拒绝,已删除,已撤回,已结束"
- // @Success 200 {object} rs.CalendarListResp
- // @router /calendar/list [get]
- func (this *CalendarController) CalendarList() {
- adminItem := this.AdminWx
- status, _ := this.GetInt("Status")
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- var total int
- page := paging.GetPaging(currentIndex, pageSize, total)
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize10
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- roleTypeCode := adminItem.RoleTypeCode
- //销售
- if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER ||
- roleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER ||
- roleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP ||
- roleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
- condition += ` AND a.sys_user_id=?`
- pars = append(pars, adminItem.AdminId)
- }
- if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_RESEARCHR ||
- roleTypeCode == utils.ROLE_TYPE_CODE_RESEARCHR ||
- roleTypeCode == utils.ROLE_TYPE_CODE_RAI_RESEARCHR ||
- roleTypeCode == utils.ROLE_TYPE_CODE_FICC_DEPARTMENT ||
- roleTypeCode == utils.ROLE_TYPE_CODE_RAI_DEPARTMENT ||
- roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN ||
- roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
- condition += ` AND b.researcher_id=?`
- pars = append(pars, adminItem.AdminId)
- }
- if roleTypeCode == utils.ROLE_TYPE_CODE_ADMIN {
- condition += ` AND a.sys_user_id=?`
- pars = append(pars, adminItem.AdminId)
- }
- condition += ` AND a.activity_type IN('路演','公开会议') `
- if status == 1 {
- condition += ` AND b.status=?`
- pars = append(pars, 1)
- } else {
- condition += ` AND b.status IN(2,3,4,5,6)`
- }
- resp := new(roadshow.CalendarListResp)
- total, err := roadshow.GetCalendarListCount(condition, pars)
- if err != nil && err.Error() != utils.ErrNoRow() {
- this.FailWithMessage("获取信息失败!", "获取数据总数失败,GetCalendarListCount,Err:"+err.Error())
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- dataList, err := roadshow.GetCalendarList(condition, pars, status, startSize, pageSize)
- if err != nil {
- this.FailWithMessage("获取信息失败!", "获取数据失败,GetCalendarList,Err:"+err.Error())
- return
- }
- resp.Paging = page
- resp.List = dataList
- this.OkDetailed(resp, "获取成功")
- }
- // CalendarList
- // @Title 内部会议和报告电话会日历列表
- // @Description 内部会议和报告电话会日历列表
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param CalendarType query int true "1:内部会议,2:报告电话会"
- // @Success 200 {object} rs.CalendarListResp
- // @router /calendar/type/list [get]
- func (this *CalendarController) CalendarTypeList() {
- adminItem := this.AdminWx
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- calendarType, _ := this.GetInt("CalendarType")
- var total int
- page := paging.GetPaging(currentIndex, pageSize, total)
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize10
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- if calendarType == 1 {
- condition += ` AND a.activity_type='内部会议' `
- condition += ` AND a.sys_user_id=?`
- pars = append(pars, adminItem.AdminId)
- }
- if calendarType == 2 {
- condition += ` AND a.activity_type='报告电话会' `
- }
- resp := new(roadshow.CalendarListResp)
- total, err := roadshow.GetCalendarTypeListCount(condition, pars)
- if err != nil && err.Error() != utils.ErrNoRow() {
- this.FailWithMessage("获取信息失败!", "获取数据总数失败,GetCalendarTypeListCount,Err:"+err.Error())
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- dataList, err := roadshow.GetCalendarTypeList(condition, pars, startSize, pageSize)
- if err != nil {
- this.FailWithMessage("获取信息失败!", "获取数据失败,GetCalendarTypeList,Err:"+err.Error())
- return
- }
- resp.Paging = page
- resp.List = dataList
- this.OkDetailed(resp, "获取成功")
- }
- // Accept
- // @Description 接受路演活动接口
- // @Param request body rs.AcceptReq true "type json string"
- // @Success Ret=200 保存成功
- // @router /accept [post]
- func (this *CalendarController) Accept() {
- //adminItem:=this.AdminWx
- 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 或 RsCalendarResearcherId 小于等于0:")
- return
- }
- rsCalendar, err := roadshow.GetRsCalendarById(req.RsCalendarId)
- if err != nil {
- this.FailWithMessage("获取数据失败!", "GetRsCalendarById Err:"+err.Error())
- return
- }
- rsCalendarResearcher, err := roadshow.GetRsCalendarResearcherById(req.RsCalendarResearcherId)
- if err != nil {
- this.FailWithMessage("获取数据失败!", "GetRsCalendarResearcherById Err:"+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"] = 2
- updateParams["modify_time"] = time.Now()
- updateParams["approve_time"] = time.Now()
- err = roadshow.UpdateCalendarResearcher(whereParams, updateParams)
- if err != nil {
- this.FailWithMessage("获取数据失败!", "UpdateCalendarResearcher Err:"+err.Error())
- return
- }
- //模板消息通知
- {
- if rsCalendar != nil {
- sysAdmin, _ := admin.GetAdminById(rsCalendar.SysUserId)
- first := "【" + this.AdminWx.RealName + "】接受了你的【" + rsCalendar.ActivityType + "】申请"
- var keyword1 string
- if rsCalendar.ActivityType == "路演" {
- keyword1 = rsCalendar.CompanyName + "," + rsCalendar.RoadshowType + rsCalendar.ActivityType
- } else {
- keyword1 = rsCalendar.Theme + "," + rsCalendar.RoadshowType + rsCalendar.ActivityType
- }
- keyword2 := "已接受"
- remark := ""
- if sysAdmin.Mobile != "" {
- go services.SendWxMsgWithRoadshowDetailResult(first, keyword1, keyword2, remark, sysAdmin.Mobile, "", "")
- }
- }
- }
- this.OkDetailed(nil, "保存成功")
- }
- // @Title 拒绝路演活动接口
- // @Description 拒绝路演活动接口
- // @Param request body rs.RefuseReq true "type json string"
- // @Success Ret=200 保存成功
- // @router /refuse [post]
- func (this *CalendarController) Refuse() {
- //adminItem:=this.AdminWx
- var req roadshow.RefuseReq
- 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
- }
- rsCalendar, err := roadshow.GetRsCalendarById(req.RsCalendarId)
- if err != nil {
- this.FailWithMessage("获取数据失败!", "GetRsCalendarById,Err:"+err.Error())
- return
- }
- rsCalendarResearcher, err := roadshow.GetRsCalendarResearcherById(req.RsCalendarResearcherId)
- if err != nil {
- this.FailWithMessage("获取数据失败!", "GetRsCalendarResearcherById,Err:"+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"] = 3
- updateParams["refuse_reason"] = req.RefuseReason
- updateParams["refuse_time"] = time.Now()
- updateParams["modify_time"] = time.Now()
- err = roadshow.UpdateCalendarResearcher(whereParams, updateParams)
- if err != nil {
- this.FailWithMessage("保存失败", "保存失败!UpdateCalendarResearcher:"+err.Error())
- return
- }
- // 拒绝后需要删除上海的日程
- go rs.DeleteSHCalendar(req.RsCalendarResearcherId)
- //模板消息通知
- {
- if rsCalendar != nil {
- sysAdmin, _ := admin.GetAdminById(rsCalendar.SysUserId)
- first := "【" + this.AdminWx.RealName + "】拒绝了你的【" + rsCalendar.ActivityType + "】申请"
- var keyword1 string
- if rsCalendar.ActivityType == "路演" {
- keyword1 = rsCalendar.CompanyName + "," + rsCalendar.RoadshowType + rsCalendar.ActivityType
- } else {
- keyword1 = rsCalendar.Theme + "," + rsCalendar.RoadshowType + rsCalendar.ActivityType
- }
- keyword2 := "已拒绝"
- remark := req.RefuseReason
- if sysAdmin.Mobile != "" {
- go services.SendWxMsgWithRoadshowDetailResult(first, keyword1, keyword2, remark, sysAdmin.Mobile, "", "")
- }
- }
- }
- this.OkDetailed(nil, "保存成功")
- }
- // @Title 日历详情
- // @Description 日历详情接口
- // @Param RsCalendarId query int true "路演活动id"
- // @Param RsCalendarResearcherId query int true "活动研究员id"
- // @Success 200 {object} rs.CalendarDetailResp
- // @router /calendar/detail [get]
- func (this *CalendarController) CalendarDetail() {
- //adminItem:=this.AdminWx
- //roleTypeCode := adminItem.RoleTypeCode
- rsCalendarId, _ := this.GetInt("RsCalendarId")
- rsCalendarResearcherId, _ := this.GetInt("RsCalendarResearcherId")
- if rsCalendarId <= 0 || rsCalendarResearcherId <= 0 {
- this.FailWithMessage("参数错误", "rsCalendarId 或 rsCalendarResearcherId")
- return
- }
- calendarItem, err := roadshow.GetRsCalendarById(rsCalendarId)
- if err != nil {
- this.FailWithMessage("获取数据失败", "获取数据失败!GetRsCalendarById:"+err.Error())
- return
- }
- rsCalendarResearcherItem, err := roadshow.GetRsCalendarResearcherById(rsCalendarResearcherId)
- if err != nil {
- this.FailWithMessage("获取数据失败", "获取数据失败!GetRsCalendarResearcherById:"+err.Error())
- return
- }
- companyDetailView := new(roadshow.CompanyDetailView)
- if calendarItem != nil && calendarItem.CompanyId > 0 {
- companyId := calendarItem.CompanyId
- companyProductItem, err := models.GetCompanyProductByCompanyIdAndProductId(companyId, 1)
- if err != nil {
- this.FailWithMessage("获取数据失败", "获取数据失败!GetRsCalendarResearcherById:"+err.Error())
- return
- }
- permissionList, err := models.GetCompanyProductReportPermissionList(companyId, 1)
- if err != nil {
- this.FailWithMessage("搜索客户权限失败", "搜索客户权限失败!GetRsCalendarResearcherById:"+err.Error())
- return
- }
- var permissionArr []string
- for _, v := range permissionList {
- permissionArr = append(permissionArr, v.PermissionName)
- }
- readNum := companyProductItem.ViewTotal
- companyDetailView.CompanyId = companyProductItem.CompanyId
- companyDetailView.CompanyName = companyProductItem.CompanyName
- companyDetailView.Status = companyProductItem.Status
- companyDetailView.IndustryId = companyProductItem.IndustryId
- companyDetailView.IndustryName = companyProductItem.IndustryName
- companyDetailView.PermissionName = strings.Join(permissionArr, "/")
- companyDetailView.ReportReadTotal = readNum //ficc报告-累计阅读次数
- }
- resp := new(roadshow.CalendarDetailResp)
- resp.RsCalendarItem = calendarItem
- resp.RsCalendarResearcherItem = rsCalendarResearcherItem
- resp.CompanyDetail = companyDetailView
- this.OkDetailed(resp, "获取成功")
- }
- // @Title 事项列表
- // @Description 事项列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} rs.MattersListResp
- // @router /matters/list [get]
- func (this *CalendarController) MattersList() {
- sysUser := this.AdminWx
- if sysUser == nil {
- this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- var total int
- page := paging.GetPaging(currentIndex, pageSize, total)
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize10
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- condition += ` AND a.sys_user_id=?`
- pars = append(pars, sysUser.AdminId)
- resp := new(roadshow.MattersListResp)
- total, err := roadshow.GetMattersListCount(condition, pars)
- if err != nil && err.Error() != utils.ErrNoRow() {
- this.FailWithMessage("获取事项信息失败", "获取事项信息失败,GetMattersListCount,Err:"+err.Error())
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- dataList, err := roadshow.GetMattersList(condition, pars, startSize, pageSize)
- if err != nil {
- this.FailWithMessage("获取事项信息失败", "获取事项信息失败,GetMattersList,Err:"+err.Error())
- return
- }
- resp.Paging = page
- resp.List = dataList
- this.OkDetailed(resp, "获取成功")
- }
- // @Title 新增事项接口
- // @Description 新增事项接口
- // @Param request body rs.AddMattersReq true "type json string"
- // @Success Ret=200 保存成功
- // @router /matters/add [post]
- func (this *CalendarController) MattersAdd() {
- sysUser := this.AdminWx
- if sysUser == nil {
- this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
- return
- }
- deleteCache := true
- cacheKey := "CACHE_RS_MATTERS_ADD_" + strconv.Itoa(sysUser.AdminId)
- defer func() {
- if deleteCache {
- utils.Rc.Delete(cacheKey)
- }
- }()
- if !utils.Rc.SetNX(cacheKey, 1, 30*time.Second) {
- deleteCache = false
- this.FailWithMessage("系统处理中,请稍后重试!", "系统处理中,请稍后重试!"+sysUser.RealName+";data:"+string(this.Ctx.Input.RequestBody))
- return
- }
- var req roadshow.AddMattersReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- this.FailWithMessage("参数解析异常", "参数解析失败,Err:"+err.Error())
- return
- }
- if req.StartDate == "" {
- this.FailWithMessage("请选择开始日期!", "请选择开始日期!")
- return
- }
- if req.EndDate == "" {
- this.FailWithMessage("请选择结束日期!", "请选择结束日期!")
- return
- }
- if req.StartTime == "" {
- this.FailWithMessage("请选择开始时间!", "请选择开始时间!")
- return
- }
- if req.EndTime == "" {
- this.FailWithMessage("请选择结束时间!", "请选择结束时间!")
- return
- }
- if req.StartWeek == "" {
- this.FailWithMessage("请选择周!", "请选择周!")
- return
- }
- if req.EndWeek == "" {
- this.FailWithMessage("请选择周!", "请选择周!")
- return
- }
- if req.MatterContent == "" {
- this.FailWithMessage("请选择研究员!", "请选择研究员!")
- return
- }
- startDateTime := req.StartDate + " " + req.StartTime
- endDateTime := req.EndDate + " " + req.EndTime
- //校验事项时间冲突
- {
- matterCount, err := rs.CheckMatters(startDateTime, endDateTime, sysUser.AdminId, 0)
- if err != nil {
- this.FailWithMessage("时间冲突检测失败!", "时间冲突检测失败-CheckMattersCount!Err:"+err.Error())
- return
- }
- if matterCount > 0 {
- this.FailWithMessage("当前时间已被占用!", "时间冲突检测失败-CheckMattersCount!")
- return
- }
- }
- //校验活动时间冲突--待接受
- {
- calendarCount, err := rs.CheckCalendar(startDateTime, endDateTime, "1", sysUser.AdminId, 0)
- if err != nil {
- this.FailWithMessage("时间冲突检测失败!", "时间冲突检测失败-CheckCalendarResearcherCount!Err:"+err.Error())
- return
- }
- if calendarCount > 0 {
- this.FailWithMessage("当前时间与待处理的申请有冲突,请与相关销售沟通!", "时间冲突检测失败-CheckCalendarResearcherCount!")
- return
- }
- }
- //校验活动时间冲突--已接受
- {
- calendarCount, err := rs.CheckCalendar(startDateTime, endDateTime, "2", sysUser.AdminId, 0)
- if err != nil {
- this.FailWithMessage("时间冲突检测失败!", "时间冲突检测失败-CheckCalendarResearcherCount!Err:"+err.Error())
- return
- }
- if calendarCount > 0 {
- this.FailWithMessage("当前时间已被占用!", "时间冲突检测失败-CheckCalendarResearcherCount!")
- return
- }
- }
- 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
- }
- item := new(roadshow.RsMatters)
- item.SysUserId = sysUser.AdminId
- item.SysUserRealName = sysUser.RealName
- item.StartDate = req.StartDate
- item.EndDate = req.EndDate
- item.StartTime = req.StartTime
- item.EndTime = req.EndTime
- item.StartWeek = req.StartWeek
- item.EndWeek = req.EndWeek
- item.MatterContent = req.MatterContent
- item.Status = 1
- item.CreateTime = time.Now()
- item.ModifyTime = time.Now()
- id, err := roadshow.AddRsMatters(item)
- if err != nil {
- this.FailWithMessage("保存失败!", "保存失败,AddRsMatters Err:"+err.Error())
- return
- }
- item.RsMattersId = int(id)
- go rs.MatterToSH(*item)
- this.OkDetailed(nil, "保存成功")
- }
- // @Title 修改事项接口
- // @Description 修改事项接口
- // @Param request body rs.UpdateMattersReq true "type json string"
- // @Success Ret=200 保存成功
- // @router /matters/update [post]
- func (this *CalendarController) MattersUpdate() {
- sysUser := this.AdminWx
- if sysUser == nil {
- this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
- return
- }
- deleteCache := true
- cacheKey := "CACHE_RS_MATTERS_UPDATE_" + strconv.Itoa(sysUser.AdminId)
- defer func() {
- if deleteCache {
- utils.Rc.Delete(cacheKey)
- }
- }()
- if !utils.Rc.SetNX(cacheKey, 1, 30*time.Second) {
- deleteCache = false
- this.FailWithMessage("系统处理中,请稍后重试!", "系统处理中,请稍后重试!")
- return
- }
- var req roadshow.UpdateMattersReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- this.FailWithMessage("参数解析失败!", "参数解析失败,Err:"+err.Error())
- return
- }
- updateParams := make(map[string]interface{})
- if req.RsMattersId <= 0 {
- this.FailWithMessage("参数错误!", "参数错误")
- return
- }
- if req.StartDate == "" {
- this.FailWithMessage("请选择开始日期!", "请选择开始日期")
- return
- } else {
- updateParams["start_date"] = req.StartDate
- }
- if req.EndDate == "" {
- this.FailWithMessage("请选择结束日期!", "请选择结束日期")
- return
- } else {
- updateParams["end_date"] = req.EndDate
- }
- if req.StartTime == "" {
- this.FailWithMessage("请选择开始时间!", "请选择开始时间")
- return
- } else {
- updateParams["start_time"] = req.StartTime
- }
- if req.EndTime == "" {
- this.FailWithMessage("请选择结束时间!", "请选择结束时间")
- return
- } else {
- updateParams["end_time"] = req.EndTime
- }
- if req.StartWeek == "" {
- this.FailWithMessage("请选择周!", "请选择周")
- return
- } else {
- updateParams["start_week"] = req.StartWeek
- }
- if req.EndWeek == "" {
- this.FailWithMessage("请选择周!", "请选择周")
- return
- } else {
- updateParams["end_week"] = req.EndWeek
- }
- if req.MatterContent == "" {
- this.FailWithMessage("请选择研究员!", "请选择研究员")
- return
- } else {
- updateParams["matter_content"] = req.MatterContent
- }
- startDateTime := req.StartDate + " " + req.StartTime
- endDateTime := req.EndDate + " " + req.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
- }
- matterItem, err := roadshow.GetMattersById(req.RsMattersId)
- if err != nil {
- this.FailWithMessage("保存失败!", "保存失败,GetMattersById,Err:"+err.Error())
- return
- }
- //校验事项时间冲突
- {
- if matterItem != nil && (matterItem.StartDate != req.StartDate ||
- matterItem.StartTime != req.StartTime ||
- matterItem.EndDate != req.EndDate ||
- matterItem.EndTime != req.EndTime) {
- matterCount, err := rs.CheckMatters(startDateTime, endDateTime, sysUser.AdminId, matterItem.RsMattersId)
- if err != nil {
- this.FailWithMessage("时间冲突检测失败!", "时间冲突检测失败-CheckMattersCount!Err:"+err.Error())
- return
- }
- if matterCount > 0 {
- this.FailWithMessage("时间冲突,已存在时间段内的事项!", "时间冲突检测失败-CheckMattersCount!")
- return
- }
- }
- }
- //校验活动时间冲突--待接受
- {
- calendarCount, err := rs.CheckCalendar(startDateTime, endDateTime, "1", sysUser.AdminId, 0)
- if err != nil {
- this.FailWithMessage("时间冲突检测失败!", "时间冲突检测失败-CheckCalendarResearcherCount!Err:"+err.Error())
- return
- }
- if calendarCount > 0 {
- this.FailWithMessage("当前时间与待处理的申请有冲突,请与相关销售沟通!", "时间冲突检测失败-CheckCalendarResearcherCount!")
- return
- }
- }
- //校验活动时间冲突--待接受
- {
- calendarCount, err := rs.CheckCalendar(startDateTime, endDateTime, "2", sysUser.AdminId, 0)
- if err != nil {
- this.FailWithMessage("时间冲突检测失败!", "时间冲突检测失败-CheckCalendarResearcherCount!Err:"+err.Error())
- return
- }
- if calendarCount > 0 {
- this.FailWithMessage("时间冲突,已存在时间段内的活动!", "时间冲突检测失败-CheckCalendarResearcherCount!")
- return
- }
- }
- whereParams := make(map[string]interface{})
- whereParams["rs_matters_id"] = req.RsMattersId
- updateParams["modify_time"] = time.Now()
- err = roadshow.UpdateRsMatters(whereParams, updateParams)
- if err != nil {
- this.FailWithMessage("保存失败!", "保存失败!UpdateRsMatters:"+err.Error())
- return
- }
- go rs.UpdateSHCalendarByMatter(req)
- this.OkDetailed(nil, "保存成功")
- }
- // @Title 删除事项接口
- // @Description 删除事项接口
- // @Param request body rs.DeleteMattersReq true "type json string"
- // @Success Ret=200 保存成功
- // @router /matters/delete [post]
- func (this *CalendarController) MattersDelete() {
- sysUser := this.AdminWx
- if sysUser == nil {
- this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
- return
- }
- var req roadshow.DeleteMattersReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- this.FailWithMessage("参数解析失败", "参数解析失败,Err:"+err.Error())
- return
- }
- if req.RsMattersId <= 0 {
- this.FailWithMessage("参数错误", "参数错误")
- return
- }
- err = roadshow.DeleteRsMatters(req.RsMattersId)
- if err != nil {
- this.FailWithMessage("保存失败", "保存失败!DeleteRsMatters:"+err.Error())
- return
- }
- go rs.DeleteSHMatter(req.RsMattersId)
- this.OkDetailed(nil, "删除成功")
- }
- func getTitle(activityType, roadshowType, activityCategory, roadshowPlatform, province, city string) string {
- var title string
- switch activityType {
- case "内部会议":
- title = "内部会议"
- case "公开会议", "路演":
- if roadshowType == "线上" {
- title = roadshowType + activityType + roadshowPlatform
- } else {
- title = roadshowType + activityType + province + city
- }
- case "报告电话会":
- title = activityCategory + "电话会"
- }
- return title
- }
- // @Title 编辑路演活动接口
- // @Description编辑路演活动接口
- // @Param request body rs.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_EDIT_" + strconv.Itoa(sysUser.AdminId)
- defer func() {
- if deleteCache {
- utils.Rc.Delete(cacheKey)
- }
- }()
- if !utils.Rc.SetNX(cacheKey, 1, 3*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("研究员异常!", "研究员异常,Err:"+err.Error())
- return
- }
- _ = rs.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 := rs.CheckMatters(startDateTime, endDateTime, v.ResearcherId, 0)
- if err != nil {
- this.FailWithMessage("时间冲突检测失败!", "时间冲突检测失败-CheckMattersCount!Err:"+err.Error())
- return
- }
- if matterCount > 0 {
- checkIsAdd = append(checkIsAdd, v.ResearcherName)
- }
- }
- }
- calendarCount, err := rs.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
- }
- 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 == "公开会议" {
- // 更新研究员信息
- //go roadshowService.UpdateSHCalendar(req.RsCalendarId, req.RsCalendarResearcherId, req.ActivityType, req.RoadshowType, req.ActivityCategory, req.RoadshowPlatform, req.Province, req.City, req.ResearcherList)
- 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
- }
- //上海新增(因为在驳回的时候,就把上海该时间段的日程给删除了,所以修改的时候,需要重新调用新增接口)
- calendar := roadshow.RsCalendar{
- RsCalendarId: req.RsCalendarId,
- SysUserId: sysUser.AdminId,
- Title: getTitle(req.ActivityType, req.RoadshowType, req.ActivityCategory, req.RoadshowPlatform, req.Province, req.City),
- }
- researcher := *rsCalendarResearcherItem
- researcher.StartDate = v.StartDate
- researcher.EndDate = v.EndDate
- researcher.StartTime = v.StartTime
- researcher.EndTime = v.EndTime
- researcher.StartWeek = v.StartWeek
- researcher.EndWeek = v.EndWeek
- go rs.CalendarToSH(calendar, researcher)
- 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)
- if sysAdmin.OpenId != "" {
- services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, sysAdmin.Mobile)
- }
- }
- }()
- }
- }
- } else {
- //先获取到所有的研究员日历表id
- researchers, err := roadshow.GetRsCalendarResearcherByCalendarId(req.RsCalendarId)
- if err != nil {
- utils.FileLog.Info("GetRsCalendarResearcherByCalendarId err: ", err)
- fmt.Println(err)
- this.FailWithMessage("保存失败!", "获取数据失败,GetRsCalendarResearcherByCalendarId:"+err.Error())
- return
- }
- //先删后增
- err = roadshow.DeleteRsCalendarResearcher(req.RsCalendarId)
- if err != nil {
- this.FailWithMessage("保存失败!", "保存失败!DeleteRsCalendarResearcher:"+err.Error())
- return
- }
- //删除上海
- for _, researcher := range researchers {
- rs.DeleteSHCalendar(researcher.RsCalendarResearcherId)
- }
- 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
- }
- //上海新增
- calendar := roadshow.RsCalendar{
- RsCalendarId: req.RsCalendarId,
- SysUserId: sysUser.AdminId,
- Title: getTitle(req.ActivityType, req.RoadshowType, req.ActivityCategory, req.RoadshowPlatform, req.Province, req.City),
- }
- researcher.RsCalendarResearcherId = int(rsCalendarResearcherId)
- go rs.CalendarToSH(calendar, *researcher)
- 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))
- if sysAdmin.OpenId != "" {
- services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, sysAdmin.Mobile)
- }
- }
- }()
- }
- }
- this.OkDetailed(nil, "保存成功")
- }
- // ResearcherList
- // @Title 研究员列表
- // @Description 研究员列表接口
- // @Success 200 {object} rs.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 rs.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 rs.DeleteSHCalendar(req.RsCalendarResearcherId)
- if err != nil {
- this.FailWithMessage("保存失败", "保存失败!UpdateCalendarResearcher:"+err.Error())
- return
- }
- this.OkDetailed(nil, "撤回成功")
- }
- // @Title 删除路演活动接口
- // @Description 删除路演活动接口
- // @Param request body rs.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
- }
- rsCalendarResearcherItemList, err := roadshow.GetRsCalendarResearcherListById(req.RsCalendarId)
- 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 {
- //只获取一条路演数据
- rsCalendarResearcherItemList, err = roadshow.GetRsCalendarResearcherListByCalendarResearcherId(req.RsCalendarResearcherId)
- if err != nil {
- this.FailWithMessage("获取数据失败!", "获取数据失败!GetRsCalendarResearcherById:"+err.Error())
- return
- }
- if req.DeleteReason == "" {
- 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"] = 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:已结束',
- 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
- // var wxAppPath string
- // if rsCalendarItem.ActivityType == "路演" || rsCalendarItem.ActivityType == "公开会议" {
- // 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)
- // }
- // }
- // }()
- //}
- //模板消息通知
- {
- go func() {
- if rsCalendarItem != nil && rsCalendarResearcherItem != nil {
- sysAdmin, _ := admin.GetAdminById(rsCalendarResearcherItem.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)
- }
- first = "【" + sysUser.RealName + "】删除了你的【" + rsCalendarItem.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
- } else {
- startDate := rsCalendarResearcherItem.StartDate[5:]
- startDate = strings.Replace(startDate, "-", ".", -1)
- keyword1 = "会议时间:" + startDate + "(" + rsCalendarResearcherItem.StartWeek + ")" + " " + rsCalendarResearcherItem.StartTime[:5] + "-" + rsCalendarResearcherItem.EndTime[:5]
- }
- keyword2 := "已删除"
- remark := req.DeleteReason
- if sysAdmin.OpenId != "" {
- go services.SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppPath, sysAdmin.Mobile)
- }
- }
- }()
- }
- }
- this.OkDetailed(nil, "删除成功")
- }
- // ResearcherList
- // @Title 获取报告电话会类型
- // @Description 获取报告电话会类型接口
- // @Success 200 {object} rs.ResearcherGroup
- // @router /activity/type/list [get]
- func (this *CalendarController) ActivityTypeList() {
- sysUser := this.AdminWx
- if sysUser == nil {
- this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
- return
- }
- // 获取所有的分类
- list, err := rs.GetAllActivityType()
- if err != nil {
- this.FailWithMessage("获取活动类型列表失败", "获取活动类型列表失败,Err:"+err.Error())
- return
- }
- this.OkDetailed(list, "获取成功")
- }
- // @Title 路演-研究员日历详情
- // @Description 路演-研究员日历详情接口
- // @Param StartDate query string true "开始日期"
- // @Param EndDate query string true "结束日期日期"
- // @Param ResearcherId query int true "研究员id"
- // @Success 200 {object} roadshow.CalendarDetailResp
- // @router /researcher/calendar/detail [get]
- func (this *CalendarController) ResearcherCalendarDetail() {
- sysUser := this.AdminWx
- if sysUser == nil {
- this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
- return
- }
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- researcherId, _ := this.GetInt("ResearcherId")
- if startDate == "" || endDate == "" {
- this.FailWithMessage("参数错误!", "参数错误 StartDate"+startDate+" EndDate:"+endDate)
- return
- }
- var condition string
- var pars []interface{}
- if researcherId <= 0 {
- calendarList := make([]*roadshow.CalendarListView, 0)
- matterList := make([]*roadshow.RsMatters, 0)
- resp := new(roadshow.CalendarPanelDetailResp)
- resp.CalendarList = calendarList
- resp.RsMattersList = matterList
- this.OkDetailed(resp, "删除成功")
- return
- } else {
- condition += ` AND b.researcher_id =? `
- pars = append(pars, researcherId)
- }
- //同步上海数据
- researcherInfo, err := admin.GetAdminById(researcherId)
- if err != nil {
- this.FailWithMessage("研究员异常!", "研究员异常"+err.Error())
- return
- }
- go rs.SyncCalendarFromShanghai(researcherInfo.Mobile, startDate, endDate)
- condition += ` AND b.start_date>=?`
- pars = append(pars, startDate)
- condition += ` AND b.end_date<=?`
- pars = append(pars, endDate)
- condition += ` AND b.status IN(2) `
- //pars = append(pars, 2)
- calendarList, err := roadshow.GetCalendarDetailList(condition, pars)
- if err != nil {
- this.FailWithMessage("获取数据失败!", "获取数据失败,GetCalendarDetailList Err:"+err.Error())
- return
- }
- matterList, err := roadshow.GetRsMattersList(startDate, endDate, researcherId)
- if err != nil {
- this.FailWithMessage("获取数据失败!", "获取数据失败,GetRsMattersList Err:"+err.Error())
- return
- }
- if calendarList == nil {
- calendarList = make([]*roadshow.CalendarListView, 0)
- }
- if matterList == nil {
- matterList = make([]*roadshow.RsMatters, 0)
- }
- resp := new(roadshow.CalendarPanelDetailResp)
- resp.CalendarList = calendarList
- resp.RsMattersList = matterList
- this.OkDetailed(resp, "删除成功")
- }
- // @Title 路演-我的日历详情
- // @Description 路演-我的日历详情接口
- // @Param StartDate query string true "开始日期"
- // @Param EndDate query string true "结束日期日期"
- // @Success 200 {object} roadshow.CalendarDetailResp
- // @router /my/calendar/detail [get]
- func (this *CalendarController) MyCalendarDetail() {
- sysUser := this.AdminWx
- if sysUser == nil {
- this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
- return
- }
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- if startDate == "" || endDate == "" {
- this.FailWithMessage("参数错误!", "参数错误 StartDate:"+startDate+" EndDate:"+endDate)
- return
- }
- var condition string
- var pars []interface{}
- roleTypeCode := sysUser.RoleTypeCode
- //销售
- if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER ||
- roleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER ||
- roleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP ||
- roleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
- condition += ` AND a.sys_user_id=?`
- pars = append(pars, sysUser.AdminId)
- condition += ` AND a.activity_type IN('路演','公开会议') `
- }
- //研究员
- if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_RESEARCHR ||
- roleTypeCode == utils.ROLE_TYPE_CODE_RESEARCHR ||
- roleTypeCode == utils.ROLE_TYPE_CODE_RAI_RESEARCHR ||
- roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN ||
- roleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER {
- condition += ` AND b.researcher_id=?`
- pars = append(pars, sysUser.AdminId)
- //同步上海数据
- researcherInfo, err := admin.GetAdminById(sysUser.AdminId)
- if err != nil {
- this.FailWithMessage("研究员异常!", "研究员异常"+err.Error())
- return
- }
- go rs.SyncCalendarFromShanghai(researcherInfo.Mobile, startDate, endDate)
- }
- //中级/普通/admin 管理员
- if roleTypeCode == utils.ROLE_TYPE_CODE_ADMIN {
- condition += ` AND a.sys_user_id=?`
- pars = append(pars, sysUser.AdminId)
- }
- condition += ` AND b.start_date>=?`
- pars = append(pars, startDate)
- condition += ` AND b.end_date<=?`
- pars = append(pars, endDate)
- condition += ` AND b.status IN(2) `
- //pars = append(pars, 2)
- calendarList, err := roadshow.GetCalendarDetailList(condition, pars)
- if err != nil {
- this.FailWithMessage("获取数据失败!", "获取数据失败,GetCalendarDetailList Err:"+err.Error())
- return
- }
- matterList, err := roadshow.GetRsMattersList(startDate, endDate, sysUser.AdminId)
- if err != nil {
- this.FailWithMessage("获取数据失败!", "获取数据失败,GetRsMattersList Err:"+err.Error())
- return
- }
- resp := new(roadshow.CalendarPanelDetailResp)
- resp.CalendarList = calendarList
- resp.RsMattersList = matterList
- this.OkDetailed(resp, "删除成功")
- }
|