123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762 |
- package controllers
- import (
- "encoding/json"
- "fmt"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/utils"
- "rdluck_tools/paging"
- "strconv"
- "strings"
- "time"
- )
- //活动
- type ActivityCoAntroller struct {
- BaseAuthController
- }
- // @Title 活动类型列表
- // @Description活动类型列表接口
- // @Success 200 {object} models.ActivityTypeListResp
- // @router /activityTypelist [get]
- func (this *ActivityCoAntroller) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- resp := new(models.ActivityTypeListResp)
- list, err := models.GetActivityTypeList()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 活动列表
- // @Description 获取活动列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
- // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
- // @Param KeyWord query string false "搜索关键词"
- // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
- // @Param IsShowJurisdiction query int false "是否仅展示有权限的,1是,2否 默认为零"
- // @Success 200 {object} models.GetCygxActivityListRep
- // @router /list [get]
- func (this *ActivityCoAntroller) ActivityList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- chartPermissionIds := this.GetString("ChartPermissionIds")
- activityTypeIds := this.GetString("ActivityTypeIds")
- isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
- keyWord := this.GetString("KeyWord")
- activeState := this.GetString("ActiveState")
- if activeState == "" {
- activeState = "1"
- }
- //if isShowJurisdiction != 1 {
- // isShowJurisdiction = 0
- //}
- itemSearch := new(models.CygxActivityUserSearchContent)
- itemSearch.UserId = uid
- itemSearch.CreateTime = time.Now()
- itemSearch.Mobile = user.Mobile
- itemSearch.Email = user.Email
- itemSearch.CompanyId = user.CompanyId
- itemSearch.CompanyName = user.CompanyName
- itemSearch.ModifyTime = time.Now()
- itemSearch.ChartPermissionids = chartPermissionIds
- itemSearch.ActivityTypeids = activityTypeIds
- itemSearch.ActiveState = activeState
- itemSearch.IsShowJurisdiction = isShowJurisdiction
- _, errSearch := models.AddUserSearchContent(itemSearch)
- if errSearch != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSearch.Error()
- return
- }
- if isShowJurisdiction == 1 && chartPermissionIds == "" {
- resp := new(models.GetCygxActivityListRep)
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- if keyWord != "" {
- condition += ` AND (art.activity_name LIKE '%` + keyWord + `%' ) `
- }
- //行业名称
- if len(chartPermissionIds) > 0 {
- condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
- }
- condition += ` AND art.publish_status = 1 AND art.active_state IN (` + activeState + `)`
- total, err := models.GetActivityCount(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if activeState != "1" {
- condition += ` ORDER BY art.activity_time DESC `
- }
- list, errList := models.GetActivityListAll(condition, pars, uid, startSize, pageSize)
- if errList != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errList.Error()
- return
- }
- for k, v := range list {
- if strings.Contains(v.ActivityName, "【") {
- list[k].IsBrackets = 1
- }
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(models.GetCygxActivityListRep)
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 我的日程
- // @Description 我的日程列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.GetCygxActivityListRep
- // @router /scheduleList [get]
- func (this *ActivityCoAntroller) ScheduleList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- condition += ` AND art.publish_status = 1 AND art.active_state IN(1,2) AND s.is_cancel = 0 AND s.fail_type = 0 `
- total, err := models.GetScheduleCount(condition, uid)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- list, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
- if errList != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errList.Error()
- return
- }
- for k, v := range list {
- if strings.Contains(v.ActivityName, "【") {
- list[k].IsBrackets = 1
- }
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(models.GetCygxActivityListRep)
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 活动详情
- // @Description 获取活动详情接口
- // @Param ActivityId query int true "活动ID"
- // @Success Ret=200 {object} models.ActivityDetail
- // @router /detail [get]
- func (this *ActivityCoAntroller) Detail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- activityId, _ := this.GetInt("ActivityId")
- if activityId < 1 {
- br.Msg = "请输入活动ID"
- return
- }
- activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
- if activityInfo == nil {
- br.Msg = "活动不存在"
- br.ErrMsg = "活动ID错误,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
- return
- }
- detail, errDetail := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
- if errDetail != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
- return
- }
- if activityInfo.IsSignup > 0 {
- detail, errDetail := models.GetActivitySignupDetail(activityId, uid)
- if errDetail != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
- return
- }
- activityInfo.SignupType = detail.SignupType
- }
- activityInfo.ShowType = detail.ShowType
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = activityInfo
- }
- // @Title 活动报名
- // @Description 活动报名接口
- // @Param request body models.ActivitySingnupRep true "type json string"
- // @Success Ret=200 {object} models.SignupStatus
- // @router /signup/add [post]
- func (this *ActivityCoAntroller) SignupAdd() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- //var signupStatus string
- signupStatus := ""
- var req models.ActivitySingnupRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- activityId := req.ActivityId
- signupType := req.SignupType
- //if signupType != 1 && signupType != 2 {
- // br.Msg = "请选择正确的报名方式!"
- // return
- //}
- //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
- item := new(models.CygxActivitySignup)
- //if activityId%5 == 1 {
- // signupStatus = "FullStarffed"
- // item.FailType = 1
- //} else if activityId%5 == 2 {
- // signupStatus = "TwoPeople"
- // item.FailType = 2
- //} else if activityId%5 == 3 {
- // signupStatus = "BreakPromise"
- // item.FailType = 3
- //} else if activityId%5 == 4 {
- // signupStatus = "Overtime"
- //} else if activityId%5 == 5 {
- // signupStatus = "Success"
- //}
- signupStatus = "Success"
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
- if time.Now().After(resultTime.Add(-time.Minute * 60)) {
- signupStatus = "Overtime"
- }
- total, errtotal := models.GetActivitySignupCount(uid, activityId)
- if errtotal != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errtotal.Error()
- return
- }
- if total > 0 {
- br.Msg = "您已报名这个活动"
- return
- }
- if signupStatus == "Success" {
- item.UserId = uid
- item.ActivityId = activityId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.SignupType = signupType
- _, errSignup := models.AddActivitySignup(item)
- if errSignup != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSignup.Error()
- return
- }
- }
- resp := new(models.SignupStatus)
- resp.SignupType = signupType
- resp.SignupStatus = signupStatus
- if signupStatus == "Success" {
- resp.ActivityId = activityId
- }
- if activityId%2 == 1 {
- resp.GoFollow = true
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.Data = resp
- }
- // @Title 活动取消报名
- // @Description 活动取消报名接口
- // @Param request body models.ActivitySingnupRep true "type json string"
- // @Success Ret=200 {object} models.SignupStatus
- // @router /signup/cancel [post]
- func (this *ActivityCoAntroller) SignupCancel() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.ActivitySingnupRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- activityId := req.ActivityId
- signupType := req.SignupType
- if signupType != 1 && signupType != 2 {
- br.Msg = "请选择正确的报名方式!"
- return
- }
- item := new(models.CygxActivitySignup)
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
- if time.Now().After(resultTime.Add(-time.Minute * 60)) {
- if signupType == 1 {
- br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
- } else {
- br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
- }
- return
- }
- total, err := models.GetActivitySignupCount(uid, activityId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if total == 0 {
- br.Msg = "您暂未报名这个活动"
- return
- }
- item.UserId = uid
- item.ActivityId = activityId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- resp := new(models.SignupStatus)
- resp.ActivityId = activityId
- _, errSignup := models.CancelActivitySignup(item)
- if errSignup != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSignup.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.Data = resp
- }
- // @Title 用户搜索详情
- // @Description 获取用户搜索详情接口
- // @Param IsShowJurisdiction query int true "是否仅展示有权限的,默认为0,1是,2否 "
- // @Success Ret=200 {object} models.ActivityUserSearchContentList
- // @router /getUserSearchContent [get]
- func (this *ActivityCoAntroller) GetUserSearchContent() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- detailSeearch := new(models.CygxActivityUserSearchContent)
- detailSeearch.IsShowJurisdiction = 0
- detailSeearch.ChartPermissionids = ""
- detailSeearch.ActiveState = ""
- detail, _ := models.GetUserSearchContentByUid(uid)
- if detail == nil {
- detail = detailSeearch
- }
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取信息失败,Err:" + err.Error()
- // return
- //}
- isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
- //chartPermissionidsSlice := strings.Split(detail.ChartPermissionids, ",")
- //activityTypeidsSlice := strings.Split(detail.ActivityTypeids, ",")
- //activeStateSlice := strings.Split(detail.ActiveState, ",") //"活动进行状态 未开始:1、进行中2、已结束3"`
- listActivityType, errActivityType := models.GetActivityTypeList()
- if errActivityType != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + errActivityType.Error()
- return
- }
- //for _, v := range activityTypeidsSlice {
- // for k2, v2 := range listActivityType {
- // if strconv.Itoa(v2.ActivityTypeId) == v {
- // listActivityType[k2].IsChoose = true
- // }
- // }
- //}
- var listChartPermissionid []*models.ActivityChartPermission
- var errChart error
- if isShowJurisdiction == 1 {
- listChartPermissionidAll, errChartAll := models.GetUserCompanyPermission(user.CompanyId)
- listChartPermissionid = listChartPermissionidAll
- errChart = errChartAll
- } else if isShowJurisdiction == 2 {
- listChartPermissionidAll, errChartAll := models.GetChartPermissionActivity()
- listChartPermissionid = listChartPermissionidAll
- errChart = errChartAll
- } else {
- if detail.IsShowJurisdiction == 1 {
- listChartPermissionidAll, errChartAll := models.GetUserCompanyPermission(user.CompanyId)
- listChartPermissionid = listChartPermissionidAll
- errChart = errChartAll
- } else {
- listChartPermissionidAll, errChartAll := models.GetChartPermissionActivity()
- listChartPermissionid = listChartPermissionidAll
- errChart = errChartAll
- }
- }
- if errChart != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + errChart.Error()
- return
- }
- //for _, v := range chartPermissionidsSlice {
- // for k2, v2 := range listChartPermissionid {
- // if strconv.Itoa(v2.ChartPermissionId) == v {
- // listChartPermissionid[k2].IsChoose = true
- // }
- // }
- //}
- resp := new(models.ActivityUserSearchContentList)
- if detail.IsShowJurisdiction == 1 {
- resp.IsShowJurisdiction = true
- }
- fmt.Println(isShowJurisdiction)
- if isShowJurisdiction == 1 || detail.IsShowJurisdiction == 1 {
- resp.IsShowJurisdiction = true
- for k, _ := range listChartPermissionid {
- listChartPermissionid[k].IsChoose = true
- }
- }
- if isShowJurisdiction == 2 {
- resp.IsShowJurisdiction = false
- }
- activeStateList := []models.ActivityStaus{models.ActivityStaus{Id: 1, StatusName: "未开始", IsChoose: true}, models.ActivityStaus{Id: 2, StatusName: "进行中"}, models.ActivityStaus{Id: 3, StatusName: "已结束"}}
- //for _, v := range activeStateSlice {
- // for k2, v2 := range activeStateList {
- // if strconv.Itoa(v2.Id) == v {
- // //activeStateList[k2].IsChoose = true
- // }
- // }
- //}
- if activeStateList[1].IsChoose == activeStateList[2].IsChoose == false {
- activeStateList[0].IsChoose = true
- }
- resp.ListActivityType = listActivityType
- resp.ListChartPermission = listChartPermissionid
- resp.ListActivityStaus = activeStateList
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 添加会议提醒
- // @Description 添加会议提醒接口
- // @Param request body models.ActivityIdRep true "type json string"
- // @Success Ret=200 {object} models.SignupStatus
- // @router /meetingReminder/add [post]
- func (this *ActivityCoAntroller) MeetingReminderAdd() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- //var signupStatus string
- signupStatus := "Success"
- var req models.ActivityIdRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- activityId := req.ActivityId
- //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
- item := new(models.CygxActivityMeetingReminder)
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
- if time.Now().After(resultTime.Add(-time.Minute * 15)) {
- br.Msg = "活动开始前15分钟无法设置会议提醒"
- return
- }
- //if signupStatus == "Success" {
- //total, err := models.GetActivitySignupCount(uid, activityId)
- //if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取失败,Err:" + err.Error()
- // return
- //}
- //if total == 0 {
- // br.Msg = "您暂未预约外呼这个活动"
- // return
- //}
- totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
- if errMeeting != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
- return
- }
- if totalMeeting > 0 {
- br.Msg = "您已预约,请勿重复预约"
- return
- }
- item.UserId = uid
- item.ActivityId = activityId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- _, errSignup := models.AddActivityMeetingReminder(item)
- if errSignup != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSignup.Error()
- return
- }
- //}
- resp := new(models.SignupStatus)
- resp.SignupStatus = signupStatus
- resp.ActivityId = activityId
- if activityId%2 == 1 {
- resp.GoFollow = true
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
- br.Data = resp
- }
- // @Title 取消会议提醒
- // @Description 取消会议提醒接口
- // @Param request body models.ActivityIdRep true "type json string"
- // @Success Ret=200 {object} models.SignupStatus
- // @router /meetingReminder/cancel [post]
- func (this *ActivityCoAntroller) MeetingReminderCancel() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.ActivityIdRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- activityId := req.ActivityId
- signupStatus := "Success"
- item := new(models.CygxActivityMeetingReminder)
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- //if signupStatus == "Success" {
- total, err := models.GetActivityMeetingReminderCount(uid, activityId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if total == 0 {
- br.Msg = "您暂未添加该活动会议提醒"
- return
- }
- resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
- if time.Now().After(resultTime.Add(-time.Minute * 15)) {
- br.Msg = "活动开始前15分钟无法取消会议提醒"
- return
- }
- item.UserId = uid
- item.ActivityId = activityId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- _, errSignup := models.CancelActivityMeetingReminder(item)
- if errSignup != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSignup.Error()
- return
- }
- //}
- resp := new(models.SignupStatus)
- resp.SignupStatus = signupStatus
- resp.ActivityId = activityId
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.Data = resp
- }
|