123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- package roadshow
- import (
- "encoding/json"
- "fmt"
- "hongze/hz_crm_api/controllers"
- "hongze/hz_crm_api/models"
- "hongze/hz_crm_api/models/cygx"
- "hongze/hz_crm_api/models/roadshow"
- "hongze/hz_crm_api/utils"
- "strconv"
- "strings"
- "time"
- )
- // 日历参会名单
- type CalendarMeetingUserController struct {
- controllers.BaseAuthController
- }
- // @Title 新增路演活动参会名单接口
- // @Description 新增路演活动参会名单接口
- // @Param request body roadshow.AddRsCalendarMeetingUserReq true "type json string"
- // @Success Ret=200 保存成功
- // @router /rs_calendar_meeting_user/add [post]
- func (this *CalendarMeetingUserController) Add() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req roadshow.AddRsCalendarMeetingUserReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- rsCalendarId := req.RsCalendarId
- userIds := req.UserId
- tagList := req.TagList
- roadShowTheme := req.RoadShowTheme
- if rsCalendarId == 0 {
- br.Msg = "路演信息错误!"
- return
- }
- if roadShowTheme == "" {
- br.Msg = "请输入路演主题名称!"
- return
- }
- var itemsGroup []*roadshow.RsCalendarMeetingLabelGroup
- for _, v := range tagList {
- itemGroup := new(roadshow.RsCalendarMeetingLabelGroup)
- itemGroup.RsCalendarId = rsCalendarId
- itemGroup.TagType = v.TagType
- itemGroup.TagId = v.TagId
- itemGroup.AdminId = sysUser.AdminId
- itemGroup.AdminName = sysUser.RealName
- itemGroup.CreateTime = time.Now()
- itemGroup.ModifyTime = time.Now()
- itemsGroup = append(itemsGroup, itemGroup)
- }
- err = roadshow.AddRsCalendarMeetingLabelGroupMulti(itemsGroup, rsCalendarId)
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取信息失败-AddRsCalendarMeetingLabelGroupMulti!Err:" + err.Error()
- return
- }
- var items []*roadshow.RsCalendarMeetingUser
- if len(userIds) > 0 {
- var userIdsStr []string
- for _, v := range userIds {
- userIdsStr = append(userIdsStr, strconv.Itoa(v))
- }
- listUser, err := models.GetWxUserListByUserIdsHaveCompany(strings.Join(userIdsStr, ","))
- if err != nil {
- br.Msg = "获取用户信息失败!"
- br.ErrMsg = "获取用户信息失败-GetWxUserListByUserIdsHaveCompany!Err:" + err.Error()
- return
- }
- for _, v := range listUser {
- item := new(roadshow.RsCalendarMeetingUser)
- item.RsCalendarId = rsCalendarId
- item.UserId = v.UserId
- item.Mobile = v.Mobile
- item.Email = v.Email
- item.CompanyId = v.CompanyId
- item.CompanyName = v.CompanyName
- item.RealName = v.RealName
- item.Position = v.Position
- item.AdminId = sysUser.AdminId
- item.AdminName = sysUser.RealName
- item.RoadShowTheme = req.RoadShowTheme
- item.CreateTime = time.Now()
- item.ModifyTime = time.Now()
- items = append(items, item)
- }
- }
- err = roadshow.MultiAddRsCalendarMeetingUser(items, roadShowTheme, rsCalendarId)
- if err != nil {
- br.Msg = "操作失败!"
- br.ErrMsg = "操作失败-MultiAddRsCalendarMeetingUser!Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "添加成功"
- br.IsAddLog = true
- }
- // @Title 路演活动参会名单列表接口
- // @Description 路演活动参会名单列表接口
- // @Param RsCalendarId query int true "路演活动id"
- // @Success 200 {object} roadshow.CalendarListResp
- // @router /rs_calendar_meeting_user/list [get]
- func (this *CalendarMeetingUserController) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- rsCalendarId, _ := this.GetInt("RsCalendarId")
- resp := new(roadshow.RsCalendarMeetingUserListResp)
- list, err := roadshow.GetRsCalendarMeetingUserListByRsCalendarId(rsCalendarId)
- if err != nil {
- br.Msg = "获取失败!"
- br.ErrMsg = "操作失败-GetRsCalendarMeetingUserListByRsCalendarId!Err:" + err.Error()
- return
- }
- totalGroup, err := roadshow.GetRsCalendarMeetingLabelGroupByRsCalendarId(rsCalendarId)
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取用户信息失败-GetRsCalendarMeetingLabelGroupByRsCalendarId!Err:" + err.Error()
- return
- }
- var lebelDetail []*cygx.RaiServeTagResp
- if totalGroup > 0 {
- listGroup, err := roadshow.GetRsCalendarMeetingLabelGroupListByRsCalendarId(rsCalendarId)
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取用户信息失败-GetRsCalendarMeetingLabelGroupListByRsCalendarId!Err:" + err.Error()
- return
- }
- var industrialManagementIds []int
- var industrialSubjectIds []int
- mapindustrialManagementName := make(map[int]string)
- mapindustrialSubjectName := make(map[int]string)
- mapCelueName := make(map[int]string)
- for _, v := range listGroup {
- switch v.TagType {
- case 1:
- industrialManagementIds = append(industrialManagementIds, v.TagId)
- case 2:
- industrialSubjectIds = append(industrialSubjectIds, v.TagId)
- case 3:
- mapCelueName[v.TagId] = "策略"
- }
- }
- if len(industrialManagementIds) > 0 {
- IndustryList, err := cygx.GetIndustryListByConditionByIds(industrialManagementIds)
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取用户信息失败-GetIndustryListByConditionByIds!Err:" + err.Error()
- return
- }
- for _, v := range IndustryList {
- mapindustrialManagementName[v.IndustrialManagementId] = v.IndustryName
- }
- }
- if len(industrialSubjectIds) > 0 {
- SubjectList, err := cygx.GetIndustrialSubjectDetailByIds(industrialSubjectIds)
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取用户信息失败-GetIndustryListByConditionByIds!Err:" + err.Error()
- return
- }
- for _, v := range SubjectList {
- mapindustrialSubjectName[v.IndustrialSubjectId] = v.SubjectName
- }
- }
- for _, v := range listGroup {
- item := new(cygx.RaiServeTagResp)
- item.TagType = v.TagType
- item.TagId = v.TagId
- item.Md5Key = utils.MD5(fmt.Sprintf("K_", v.TagType, "V_", v.TagId))
- switch v.TagType {
- case 1:
- item.TagName = mapindustrialManagementName[v.TagId]
- case 2:
- item.TagName = mapindustrialSubjectName[v.TagId]
- case 3:
- item.TagName = mapCelueName[v.TagId]
- }
- lebelDetail = append(lebelDetail, item)
- }
- }
- if len(list) == 0 {
- list = make([]*roadshow.RsCalendarMeetingUserResp, 0)
- } else {
- for _, v := range list {
- resp.RoadShowTheme = v.RoadShowTheme
- }
- }
- if len(lebelDetail) == 0 {
- lebelDetail = make([]*cygx.RaiServeTagResp, 0)
- }
- resp.List = list
- resp.ListLebel = lebelDetail
- br.Ret = 200
- br.Success = true
- br.Data = resp
- br.Msg = "获取成功"
- }
- // @Title 路演活动参会删除接口
- // @Description 路演活动参会删除接口
- // @Param RsCalendarMeetingUserId query int true "参会名单主键ID"
- // @Success Ret=200 删除成功
- // @router /rs_calendar_meeting_user/delete [post]
- func (this *CalendarMeetingUserController) Delete() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req roadshow.DeleteRsCalendarMeetingUserReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- rsCalendarMeetingUserId := req.RsCalendarMeetingUserId
- err = roadshow.DeleteRsCalendarMeetingUser(rsCalendarMeetingUserId)
- if err != nil {
- br.Msg = "删除失败!"
- br.ErrMsg = "删除失败-DeleteRsCalendarMeetingUser!Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "删除成功"
- br.IsAddLog = true
- }
|