|
@@ -0,0 +1,1732 @@
|
|
|
+package controllers
|
|
|
+
|
|
|
+import (
|
|
|
+ "encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ "hongze/hongze_clpt/models"
|
|
|
+ "hongze/hongze_clpt/services"
|
|
|
+ "hongze/hongze_clpt/utils"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+type ActivityController struct {
|
|
|
+ BaseAuthController
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 活动类型下的主题列表
|
|
|
+// @Description 获取活动类型下的主题列表接口
|
|
|
+// @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
|
|
|
+// @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
|
|
|
+// @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3 多个用 , 隔开"
|
|
|
+// @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
|
|
|
+// @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
|
|
|
+// @Success 200 {object} models.ActivityTypeListHomeResp
|
|
|
+// @router /labelTypeList [get]
|
|
|
+func (this *ActivityController) LabelTypeList() {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ chartPermissionIds := this.GetString("ChartPermissionIds")
|
|
|
+ isPower, _ := this.GetInt("IsPower")
|
|
|
+ whichDay := this.GetString("WhichDay")
|
|
|
+ activeState := this.GetString("ActiveState")
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+
|
|
|
+ // 查研观向7.4-始终查询宏观的活动
|
|
|
+ if chartPermissionIds != "" {
|
|
|
+ chartPermissionIds += ",1"
|
|
|
+ }
|
|
|
+
|
|
|
+ condition += `AND art.activity_time > ? `
|
|
|
+ pars = append(pars, time.Now().AddDate(0, -3, 0).Format(utils.FormatDate))
|
|
|
+
|
|
|
+ conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ condition += `AND art.is_limit_people = 1 ` + conditionActivity
|
|
|
+ sortTime := ` mintimesort ASC `
|
|
|
+ if activeState == "3" {
|
|
|
+ sortTime = ` timesort DESC `
|
|
|
+ }
|
|
|
+
|
|
|
+ activityList, err := models.GetCygxActivityList(condition, pars, sortTime, 0, 1000)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ list, err := models.GetActivityTypeHomeList()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ list, err = services.HandleActivityTypeHomeList(list, activityList, user)
|
|
|
+
|
|
|
+ conditionActivitySpecial := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState)
|
|
|
+
|
|
|
+ speciaItem, err := services.GetActivityLabelSpecialList(user, conditionActivitySpecial)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(speciaItem.List) == 0 {
|
|
|
+ speciaItem.List = make([]*models.CygxActivityLabelList, 0)
|
|
|
+ }
|
|
|
+ if speciaItem.ActivityTypeId > 0 {
|
|
|
+ list = append(list, speciaItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := new(models.ActivityTypeListHomeResp)
|
|
|
+ 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 Label query string false "搜索主题 多个用 , 隔开"
|
|
|
+// @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
|
|
|
+// @Param WhichDay query string false "哪一天 今天:1、明天:2, 本周:3 上周:4,本月:5上月:6多个用 , 隔开"
|
|
|
+// @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
|
|
|
+// @Param ActivityTypeId query string false "活动类型id 多个用 , 隔开"
|
|
|
+// @Param Source query int false "来源 0手机 ,1Pc 默认0"
|
|
|
+// @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
|
|
|
+// @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
|
|
|
+// @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
|
|
|
+// @Param ActivityId query int false "活动列表传过来的活动ID"
|
|
|
+// @Param Filter query int false "筛选条件 0:全部 1:视频 2:音频"
|
|
|
+// @Success 200 {object} models.GetCygxActivityListRep
|
|
|
+// @router /list [get]
|
|
|
+func (this *ActivityController) ActivityListNew() {
|
|
|
+ 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")
|
|
|
+ source, _ := this.GetInt("Source")
|
|
|
+ label := this.GetString("Label")
|
|
|
+ chartPermissionIds := this.GetString("ChartPermissionIds")
|
|
|
+ whichDay := this.GetString("WhichDay")
|
|
|
+ //whichTime := this.GetString("WhichTime")
|
|
|
+ activeState := this.GetString("ActiveState")
|
|
|
+ activityTypeId := this.GetString("ActivityTypeId")
|
|
|
+ keyWord := this.GetString("KeyWord")
|
|
|
+ playBack, _ := this.GetInt("PlayBack")
|
|
|
+ filter, _ := this.GetInt("Filter")
|
|
|
+ activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签
|
|
|
+
|
|
|
+ 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{}
|
|
|
+ //var activityList []*models.ActivityDetail
|
|
|
+ //mapDingActivityId := make(map[int]int)
|
|
|
+ condition = ""
|
|
|
+ //活动可见限制
|
|
|
+ conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord, playBack)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if source == 1 {
|
|
|
+ condition += ` AND art.yidong_activity_id = '' `
|
|
|
+ }
|
|
|
+
|
|
|
+ condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
|
|
|
+ total, err := models.GetActivityCount(condition, playBack, pars, filter)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var conditionOrder string
|
|
|
+ if activeState == "2" || activeState == "3" {
|
|
|
+ conditionOrder = ` ORDER BY art.activity_time DESC `
|
|
|
+ } else if activeState == "2,3" {
|
|
|
+ conditionOrder = ` ORDER BY art.active_state ASC, art.activity_time DESC `
|
|
|
+ } else {
|
|
|
+ conditionOrder = ` ORDER BY art.activity_time DESC , art.active_state ASC `
|
|
|
+ }
|
|
|
+
|
|
|
+ if label != "" && activeState == "1" {
|
|
|
+ conditionOrder = ` ORDER BY art.activity_time ASC `
|
|
|
+ }
|
|
|
+
|
|
|
+ if activeState == "1" {
|
|
|
+ conditionOrder = ` ORDER BY art.activity_time ASC `
|
|
|
+ }
|
|
|
+
|
|
|
+ condition += conditionOrder
|
|
|
+ list, errList := models.GetActivityListNew(condition, pars, uid, startSize, pageSize, playBack, filter)
|
|
|
+ if errList != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + errList.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var isShow bool
|
|
|
+ isShow = services.GetShowSustainable()
|
|
|
+ detail, err := models.GetConfigByCode("city_img_url")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败"
|
|
|
+ br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ detailChart, err := models.GetConfigByCode("chart_img_url")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败"
|
|
|
+ br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ addressList := strings.Split(detail.ConfigValue, "{|}")
|
|
|
+ mapAddress := make(map[string]string)
|
|
|
+ chartList := strings.Split(detailChart.ConfigValue, "{|}")
|
|
|
+ mapChart := make(map[string]string)
|
|
|
+ var cityName string
|
|
|
+ var chartName string
|
|
|
+ var imgUrl string
|
|
|
+ var imgUrlChart string
|
|
|
+ var mapActivityId []int
|
|
|
+ for _, v := range addressList {
|
|
|
+ vslice := strings.Split(v, "_")
|
|
|
+ cityName = vslice[0]
|
|
|
+ imgUrl = vslice[len(vslice)-1]
|
|
|
+ mapAddress[cityName] = imgUrl
|
|
|
+ }
|
|
|
+ for _, v := range chartList {
|
|
|
+ vslice := strings.Split(v, "_")
|
|
|
+ chartName = vslice[0]
|
|
|
+ imgUrlChart = vslice[len(vslice)-1]
|
|
|
+ mapChart[chartName] = imgUrlChart
|
|
|
+ }
|
|
|
+ for k, v := range list {
|
|
|
+ if strings.Contains(v.ActivityName, "【") {
|
|
|
+ list[k].IsBrackets = 1
|
|
|
+ }
|
|
|
+ if v.SignupNum > v.LimitPeopleNum {
|
|
|
+ list[k].SignupNum = v.LimitPeopleNum
|
|
|
+ }
|
|
|
+ if isShow && strings.Contains(v.ChartPermissionName, "研选") {
|
|
|
+ list[k].IsShowSustainable = true
|
|
|
+ }
|
|
|
+
|
|
|
+ if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
|
|
|
+ list[k].ActivityTypeName = "买方研选电话会"
|
|
|
+ list[k].ImgUrlText = utils.YAN_XUAN_IMG
|
|
|
+ }
|
|
|
+ if v.ActivityType == 0 {
|
|
|
+ if mapAddress[v.City] != "" {
|
|
|
+ list[k].ImgUrl = mapAddress[v.City]
|
|
|
+ } else {
|
|
|
+ list[k].ImgUrl = mapAddress["其它"]
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if mapChart[v.ChartPermissionName] != "" {
|
|
|
+ list[k].ImgUrl = mapChart[v.ChartPermissionName]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ expertTxt, _ := services.GetReportContentTextSub(v.Expert)
|
|
|
+ list[k].Expert = expertTxt
|
|
|
+ if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
|
|
|
+ list[k].IsCClassMeeting = true
|
|
|
+ }
|
|
|
+ mapActivityId = append(mapActivityId, v.ActivityId)
|
|
|
+ }
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp := new(models.GetCygxActivityListRep)
|
|
|
+ var activityList []*models.ActivityListResp
|
|
|
+ resp.Label = label
|
|
|
+ if activityTypeId != "" && label == "" {
|
|
|
+ activityTypeIdint, err := strconv.Atoi(activityTypeId)
|
|
|
+ if err == nil {
|
|
|
+ detail, errDetail := models.GetActivityTypeDetailById(activityTypeIdint)
|
|
|
+ if errDetail != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.ImgUrl = detail.OnlineIco
|
|
|
+ resp.Label = detail.ActivityTypeName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //处理音频回放
|
|
|
+ mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理视频回放
|
|
|
+ mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //用户权限
|
|
|
+ authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for k, v := range list {
|
|
|
+
|
|
|
+ au := new(models.UserPermissionAuthInfo)
|
|
|
+ au.SellerName = authInfo.SellerName
|
|
|
+ au.SellerMobile = authInfo.SellerMobile
|
|
|
+ au.HasPermission = authInfo.HasPermission
|
|
|
+ au.OperationMode = authInfo.OperationMode
|
|
|
+ if au.HasPermission == 1 {
|
|
|
+ // 非宏观权限进一步判断是否有权限
|
|
|
+ if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
|
|
|
+ au.HasPermission = 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 无权限的弹框提示
|
|
|
+ if au.HasPermission != 1 {
|
|
|
+ if au.OperationMode == services.UserPermissionOperationModeCall {
|
|
|
+ if v.FileType == 1 {
|
|
|
+ au.PopupMsg = services.UserPermissionPopupMsgCallMicroVoice
|
|
|
+ } else {
|
|
|
+ au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if v.FileType == 1 {
|
|
|
+ au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVoice
|
|
|
+ } else {
|
|
|
+ au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list[k].AuthInfo = au
|
|
|
+ if mapActivityVoice[v.ActivityId] != nil {
|
|
|
+ list[k].FileType = 1
|
|
|
+ list[k].AudioLink = true
|
|
|
+ if au.HasPermission == 1 {
|
|
|
+ list[k].VoiceList = mapActivityVoice[v.ActivityId]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if mapActivityVideo[v.ActivityId] != nil {
|
|
|
+ list[k].FileType = 2
|
|
|
+ list[k].AudioLink = true
|
|
|
+ if au.HasPermission == 1 {
|
|
|
+ list[k].VideoDetail = mapActivityVideo[v.ActivityId]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ activityList = append(activityList, services.ActivityButtonShow(list[k], user))
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查研观向7.4-判断标签是否为产业, 为产业时是否跳转资源包
|
|
|
+ if label != "" {
|
|
|
+ industry, e := models.GetIndustryByName(label)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取标签产业失败, Err:" + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if industry != nil {
|
|
|
+ sourceIndustry, e := models.GetSourceIndustryByName(label)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取标签产业资源包失败, Err:" + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if sourceIndustry != nil {
|
|
|
+ resp.IndustrialManagementId = sourceIndustry.IndustrialManagementId
|
|
|
+ resp.ChartPermissionId = sourceIndustry.ChartPermissionId
|
|
|
+ resp.IsJump = true
|
|
|
+ // 研选产业不跳资源包
|
|
|
+ if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
|
|
|
+ resp.IsJump = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 新标签
|
|
|
+ if activityId > 0 && activeState != "3" {
|
|
|
+ activityIds := []int{activityId}
|
|
|
+
|
|
|
+ activityNewMap, _, e := services.GetActivityNewLabelMap(activityIds)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取活动新标签失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.IndustryNewLabel = activityNewMap[activityId]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加活动搜索记录
|
|
|
+ //if keyWord != "" {
|
|
|
+ // go services.AddActivitykeyWordSearch(keyWord, user)
|
|
|
+ //}
|
|
|
+ fmt.Println(resp.Label)
|
|
|
+ //预处理返给前端的字段
|
|
|
+ resp.List = activityList
|
|
|
+ fmt.Println(len(resp.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.CygxActivityResp
|
|
|
+// @router /detail [get]
|
|
|
+func (this *ActivityController) 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
|
|
|
+ }
|
|
|
+ resp := new(models.CygxActivityResp)
|
|
|
+ activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if activityInfo == nil {
|
|
|
+ br.Msg = "活动不存在"
|
|
|
+ br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
|
|
|
+ activityInfo.IsCClassMeeting = true
|
|
|
+ }
|
|
|
+ havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if havePower {
|
|
|
+ resp.HasPermission = 1
|
|
|
+ detailResp := services.ActivityButtonShow(activityInfo, user)
|
|
|
+ detailResp, err = services.ActivityDetaailShow(detailResp)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //处理活动关联的产业
|
|
|
+ industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if activityInfo.TemporaryLabel != "" {
|
|
|
+ industrialList = make([]*models.IndustrialManagementRep, 0)
|
|
|
+ item := new(models.IndustrialManagementRep)
|
|
|
+ item.IndustryName = activityInfo.Label
|
|
|
+ industrialList = append(industrialList, item)
|
|
|
+ } else {
|
|
|
+ industryIds := make([]int, 0)
|
|
|
+ var industrialManagementId string
|
|
|
+ for k, v := range industrialList {
|
|
|
+ if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
|
|
|
+ industrialList[k].IsResearch = true
|
|
|
+ }
|
|
|
+ industryIds = append(industryIds, v.IndustrialManagementId)
|
|
|
+ industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查研观向7.4-行业新标签
|
|
|
+ industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //判断产业下是否有关联的报告,并处理是否跳转
|
|
|
+ industrialManagementId = strings.TrimRight(industrialManagementId, ",")
|
|
|
+ if industrialManagementId != "" {
|
|
|
+ var condition string
|
|
|
+ condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
|
|
|
+ condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
|
|
|
+ listIndustrialGrop, err := models.GetSearchResourceList(condition)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mapIndustrial := make(map[int]int)
|
|
|
+ if len(listIndustrialGrop) > 0 {
|
|
|
+ for _, v := range listIndustrialGrop {
|
|
|
+ mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for k, v := range industrialList {
|
|
|
+ if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
|
|
|
+ industrialList[k].IsJump = true
|
|
|
+ }
|
|
|
+ if activityInfo.ActivityTypeId == 1 {
|
|
|
+ industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //if activityInfo.YidongActivityId != "" {
|
|
|
+ // ydTgc, _ := services.GetYiDongCreateUserInfo(user)
|
|
|
+ // yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
|
|
|
+ // if err != nil {
|
|
|
+ // br.Msg = "获取信息失败"
|
|
|
+ // br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // detailResp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
|
|
|
+ //}
|
|
|
+ if len(industrialList) > 0 {
|
|
|
+ detailResp.Label = ""
|
|
|
+ }
|
|
|
+ detailResp.Listndustrial = industrialList
|
|
|
+
|
|
|
+ //处理音频回放
|
|
|
+ var mapActivityId []int
|
|
|
+ mapActivityId = append(mapActivityId, activityId)
|
|
|
+ mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if mapActivityVoice[activityId] != nil {
|
|
|
+ detailResp.FileType = 1
|
|
|
+ detailResp.AudioLink = true
|
|
|
+ detailResp.VoiceDetail = mapActivityVoice[activityId]
|
|
|
+ }
|
|
|
+ //处理视频回放
|
|
|
+ mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if mapActivityVideo[activityId] != nil {
|
|
|
+ detailResp.FileType = 2
|
|
|
+ detailResp.AudioLink = true
|
|
|
+ detailResp.VideoDetail = mapActivityVideo[activityId]
|
|
|
+ }
|
|
|
+
|
|
|
+ resp.Detail = detailResp
|
|
|
+ } else {
|
|
|
+ hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ popupMsg = "暂无查看权限"
|
|
|
+ resp.PopupMsg = popupMsg
|
|
|
+ resp.HasPermission = hasPermission
|
|
|
+ resp.SellerName = sellerName
|
|
|
+ resp.SellerMobile = sellerMobile
|
|
|
+ }
|
|
|
+ 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/add [post]
|
|
|
+func (this *ActivityController) 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
|
|
|
+ signupStatus := ""
|
|
|
+ var req models.ActivitySingnupRep
|
|
|
+ resp := new(models.SignupStatus)
|
|
|
+ var total int
|
|
|
+ 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
|
|
|
+ hasPermission := 0
|
|
|
+ if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
|
|
|
+ resp.GoBindEmail = true
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if havePower {
|
|
|
+ item := new(models.CygxActivitySignup)
|
|
|
+ item.RegisterPlatform = utils.REGISTER_PLATFORM
|
|
|
+ resp.HasPermission = 1
|
|
|
+ hasPermission = 1
|
|
|
+ signupStatus = "Success"
|
|
|
+ resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
|
|
|
+ if time.Now().After(resultTime.Add(-time.Minute * 60)) {
|
|
|
+ signupStatus = "Overtime"
|
|
|
+ resp.SignupType = signupType
|
|
|
+ resp.SignupStatus = signupStatus
|
|
|
+ resp.HasPermission = hasPermission
|
|
|
+ resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = ""
|
|
|
+ br.Data = resp
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var sellerName string
|
|
|
+ sellerName, err = models.GetCompanySellerName(user.CompanyId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "报名失败!"
|
|
|
+ br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
|
|
|
+ //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
|
|
|
+ //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
|
|
|
+ if activityInfo.IsLimitPeople == 1 {
|
|
|
+ //判断优先级:总人数限制→单机构2人限制→爽约3次限制
|
|
|
+ totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if totalRestrict >= 1 {
|
|
|
+ signupStatus = "BreakPromise"
|
|
|
+ resp.PopupMsg = "由于爽约次数过多,您暂时被限制报名资格"
|
|
|
+ item.FailType = 3
|
|
|
+ }
|
|
|
+ totalSignupCompany, err := models.GetActivitySignupCompanyCount(activityId, user.CompanyId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if totalSignupCompany >= 2 {
|
|
|
+ signupStatus = "TwoPeople"
|
|
|
+ resp.PopupMsg = "单机构最多2人报名同一活动,您所在机构报名人数已满"
|
|
|
+ item.FailType = 2
|
|
|
+ }
|
|
|
+ totaSignupPeopleNum, err := models.GetActivitySignupSuccessCount(activityId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if totaSignupPeopleNum >= activityInfo.LimitPeopleNum {
|
|
|
+ signupStatus = "FullStarffed"
|
|
|
+ resp.PopupMsg = "此活动报名人数已满,请留意下期活动"
|
|
|
+ item.FailType = 1
|
|
|
+ }
|
|
|
+ totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //解除报名限制之后二次报名相同活动
|
|
|
+ if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
|
|
|
+ item.UserId = uid
|
|
|
+ item.RealName = user.RealName
|
|
|
+ item.SellerName = sellerName
|
|
|
+ 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
|
|
|
+ item.FailType = 0
|
|
|
+ item.DoFailType = 0
|
|
|
+ _, errSignup := models.AddActivitySignupByRestrict(item)
|
|
|
+ if errSignup != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + errSignup.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.HaqveJurisdiction = true
|
|
|
+ resp.SignupType = signupType
|
|
|
+ resp.SignupStatus = "Success"
|
|
|
+ resp.HasPermission = hasPermission
|
|
|
+ resp.ActivityId = activityId
|
|
|
+ total, err = models.GetUserMeetingReminderCount(user.UserId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if total == 0 {
|
|
|
+ resp.GoFollow = true
|
|
|
+ }
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "操作成功"
|
|
|
+ br.Data = resp
|
|
|
+ return
|
|
|
+ }
|
|
|
+ totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
|
|
|
+ item.UserId = uid
|
|
|
+ item.RealName = user.RealName
|
|
|
+ item.SellerName = sellerName
|
|
|
+ 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
|
|
|
+ item.DoFailType = item.FailType
|
|
|
+ if user.OutboundMobile != "" {
|
|
|
+ item.OutboundMobile = user.OutboundMobile
|
|
|
+ if user.OutboundCountryCode == "" {
|
|
|
+ item.CountryCode = "86"
|
|
|
+ } else {
|
|
|
+ item.CountryCode = user.OutboundCountryCode
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ item.OutboundMobile = user.Mobile
|
|
|
+ if user.CountryCode == "" {
|
|
|
+ item.CountryCode = "86"
|
|
|
+ } else {
|
|
|
+ item.CountryCode = user.CountryCode
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //添加报名信息,但是不加入日程
|
|
|
+ _, errSignup := models.AddActivitySignupNoSchedule(item)
|
|
|
+ if errSignup != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + errSignup.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if totalMySuccess > 0 {
|
|
|
+ br.Msg = "您已报名这个活动"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if signupStatus == "Success" && resp.GoBindEmail != true {
|
|
|
+ item.UserId = uid
|
|
|
+ item.RealName = user.RealName
|
|
|
+ item.SellerName = sellerName
|
|
|
+ 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
|
|
|
+ item.FailType = 0
|
|
|
+ item.DoFailType = 0
|
|
|
+ item.OutboundMobile = user.Mobile
|
|
|
+ if user.OutboundMobile != "" {
|
|
|
+ item.OutboundMobile = user.OutboundMobile
|
|
|
+ if user.OutboundCountryCode == "" {
|
|
|
+ item.CountryCode = "86"
|
|
|
+ } else {
|
|
|
+ item.CountryCode = user.OutboundCountryCode
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ item.OutboundMobile = user.Mobile
|
|
|
+ if user.CountryCode == "" {
|
|
|
+ item.CountryCode = "86"
|
|
|
+ } else {
|
|
|
+ item.CountryCode = user.CountryCode
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _, errSignup := models.AddActivitySignup(item)
|
|
|
+ if errSignup != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + errSignup.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.HaqveJurisdiction = true
|
|
|
+ //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
|
|
|
+ if signupType == 1 {
|
|
|
+ //go services.ActivityUserRemind(user, activityInfo, 1)
|
|
|
+ resp.PopupMsg = item.CountryCode + "-" + item.Mobile + "<br/>预约成功,已加入您的活动日程<br/><br/>想要及时获取活动时间变更通知,请关注【查研观向小助手】公众号"
|
|
|
+ } else {
|
|
|
+ //go services.ActivityUserRemind(user, activityInfo, 4)
|
|
|
+ resp.PopupMsg = "报名成功,已加入您的活动日程<br/><br/>想要及时获取活动时间变更通知,请关注【查研观向小助手】公众号"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ popupMsg = "暂无查看权限"
|
|
|
+ resp.PopupMsg = popupMsg
|
|
|
+ resp.HasPermission = hasPermission
|
|
|
+ resp.SellerName = sellerName
|
|
|
+ resp.SellerMobile = sellerMobile
|
|
|
+ }
|
|
|
+
|
|
|
+ if signupType == 1 && user.IsMsgOutboundMobile == 0 {
|
|
|
+ resp.GoOutboundMobile = true
|
|
|
+ if user.Mobile != "" || user.OutboundMobile != "" {
|
|
|
+ go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if user.OutboundMobile == "" {
|
|
|
+ resp.Mobile = user.Mobile
|
|
|
+ if user.CountryCode == "" && len(user.Mobile) == 11 {
|
|
|
+ resp.CountryCode = "86"
|
|
|
+ } else {
|
|
|
+ resp.CountryCode = user.CountryCode
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ resp.Mobile = user.OutboundMobile
|
|
|
+ resp.CountryCode = user.OutboundCountryCode
|
|
|
+ }
|
|
|
+ //如果用户有绑定手机号,但是没有绑定外呼手机号
|
|
|
+ if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
|
|
|
+ var countryCode string
|
|
|
+ if len(user.Mobile) == 8 {
|
|
|
+ countryCode = "852"
|
|
|
+ } else if len(user.Mobile) == 9 {
|
|
|
+ countryCode = "886"
|
|
|
+ } else if len(user.Mobile) == 10 {
|
|
|
+ countryCode = "1"
|
|
|
+ } else if len(user.Mobile) >= 11 {
|
|
|
+ countryCode = "86"
|
|
|
+ }
|
|
|
+ models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
|
|
|
+ }
|
|
|
+ resp.SignupType = signupType
|
|
|
+ resp.SignupStatus = signupStatus
|
|
|
+ //resp.HasPermission = hasPermission
|
|
|
+ //if signupStatus == "Success" {
|
|
|
+ resp.ActivityId = activityId
|
|
|
+ //}
|
|
|
+ total, err = models.GetUserSignupCount(user.UserId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if total <= 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 *ActivityController) 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
|
|
|
+ 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
|
|
|
+ _, errSignup := models.CancelActivitySignup(item)
|
|
|
+ if errSignup != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + errSignup.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "操作成功"
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 添加会议提醒
|
|
|
+// @Description 添加会议提醒接口
|
|
|
+// @Param request body models.ActivityIdRep true "type json string"
|
|
|
+// @Success Ret=200 {object} models.SignupStatus
|
|
|
+// @router /meetingReminder/add [post]
|
|
|
+func (this *ActivityController) 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
|
|
|
+ signupStatus := ""
|
|
|
+ var req models.ActivitySingnupRep
|
|
|
+ resp := new(models.SignupStatus)
|
|
|
+
|
|
|
+ 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
|
|
|
+ hasPermission := 0
|
|
|
+ if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
|
|
|
+ resp.GoBindEmail = true
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if havePower {
|
|
|
+ item := new(models.CygxActivityMeetingReminder)
|
|
|
+ item.RegisterPlatform = utils.REGISTER_PLATFORM
|
|
|
+ resp.HasPermission = 1
|
|
|
+ hasPermission = 1
|
|
|
+ signupStatus = "Success"
|
|
|
+ resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
|
|
|
+ if time.Now().After(resultTime.Add(-time.Minute * 15)) {
|
|
|
+ signupStatus = "Overtime"
|
|
|
+ resp.SignupType = signupType
|
|
|
+ resp.SignupStatus = signupStatus
|
|
|
+ resp.HasPermission = hasPermission
|
|
|
+ resp.PopupMsg = "活动开始前15分钟无法设置会议提醒"
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = ""
|
|
|
+ br.Data = resp
|
|
|
+ return
|
|
|
+ }
|
|
|
+ hasPermission = 1
|
|
|
+ signupStatus = "Success"
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
|
|
|
+ resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
|
|
|
+ } else {
|
|
|
+ hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ popupMsg = "暂无查看权限"
|
|
|
+ resp.PopupMsg = popupMsg
|
|
|
+ resp.HasPermission = hasPermission
|
|
|
+ resp.SellerName = sellerName
|
|
|
+ resp.SellerMobile = sellerMobile
|
|
|
+ }
|
|
|
+
|
|
|
+ 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/cancel [post]
|
|
|
+func (this *ActivityController) 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
|
|
|
+ }
|
|
|
+ total, err := models.GetActivityMeetingReminderCount(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
|
|
|
+ _, errSignup := models.CancelActivityMeetingReminder(item)
|
|
|
+ if errSignup != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + errSignup.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp := new(models.SignupStatus)
|
|
|
+ resp.SignupStatus = signupStatus
|
|
|
+ resp.HasPermission = 1
|
|
|
+ resp.ActivityId = activityId
|
|
|
+ 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.AppointmentResp
|
|
|
+// @router /appointment/add [post]
|
|
|
+func (this *ActivityController) ActivityAppointmentAdd() {
|
|
|
+ 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
|
|
|
+ resp := new(models.SignupStatus)
|
|
|
+
|
|
|
+ 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 && user.Mobile == "" && user.OutboundMobile == "" {
|
|
|
+ resp.GoBindEmail = true
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if havePower {
|
|
|
+ item := new(models.CygxActivityAppointment)
|
|
|
+ item.RegisterPlatform = utils.REGISTER_PLATFORM
|
|
|
+ resp.HasPermission = 1
|
|
|
+ totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
|
|
|
+ if errMeeting != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if totalMeeting > 0 {
|
|
|
+ br.Msg = "您已预约,请勿重复预约"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var sellerName string
|
|
|
+ sellerName, err = models.GetCompanySellerName(user.CompanyId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "报名失败!"
|
|
|
+ br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
|
|
|
+ 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
|
|
|
+ item.SellerName = sellerName
|
|
|
+ item.RealName = user.RealName
|
|
|
+ err = models.AddCygxActivityAppointment(item)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.SignupStatus = "Success"
|
|
|
+ //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
|
|
|
+ //go services.ActivityUserRemind(user, activityInfo, 3)
|
|
|
+ } else {
|
|
|
+ hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ popupMsg = "暂无查看权限"
|
|
|
+ resp.PopupMsg = popupMsg
|
|
|
+ resp.HasPermission = hasPermission
|
|
|
+ resp.SellerName = sellerName
|
|
|
+ resp.SellerMobile = sellerMobile
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 /appointment/cancel [post]
|
|
|
+func (this *ActivityController) ActivityAppointmentCancel() {
|
|
|
+ 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.CygxActivityAppointment)
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ total, err := models.GetUserCygxActivityAppointmentCount(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
|
|
|
+ _, errSignup := models.CancelcygxActivityAppointment(item)
|
|
|
+ if errSignup != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + errSignup.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp := new(models.SignupStatus)
|
|
|
+ resp.SignupStatus = signupStatus
|
|
|
+ resp.ActivityId = activityId
|
|
|
+ resp.HasPermission = 1
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "已取消"
|
|
|
+ br.Data = resp
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 活动带问
|
|
|
+// @Description 新增活动带问接口
|
|
|
+// @Param request body models.AddCygxActivityHelpAsk true "type json string"
|
|
|
+// @Success Ret=200 新增成功
|
|
|
+// @router /askAdd [post]
|
|
|
+func (this *ActivityController) AskAdd() {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ var req models.CygxActivityHelpAsk
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if req.Content == "" {
|
|
|
+ br.Msg = "建议内容不可为空"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ content := req.Content
|
|
|
+ //itemToken, err := services.WxGetToken()
|
|
|
+ //if err != nil {
|
|
|
+ // br.Msg = "GetWxAccessToken Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //if itemToken.AccessToken == "" {
|
|
|
+ // br.Msg = "accessToken is empty"
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
|
|
|
+ //if err != nil {
|
|
|
+ // br.Msg = "内容校验失败!"
|
|
|
+ // br.ErrMsg = "内容校验失败,Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //if commerr.ErrCode != 0 {
|
|
|
+ // br.Msg = "内容违规,请重新提交!"
|
|
|
+ // br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ activityId := req.ActivityId
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ resp := new(models.SignupStatus)
|
|
|
+
|
|
|
+ havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if havePower {
|
|
|
+ companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "提交失败!"
|
|
|
+ br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if companyDetail == nil {
|
|
|
+ br.Msg = "提交失败!"
|
|
|
+ br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.SignupStatus = "Success"
|
|
|
+ resp.HasPermission = 1
|
|
|
+ item := new(models.CygxActivityHelpAsk)
|
|
|
+ item.RegisterPlatform = utils.REGISTER_PLATFORM
|
|
|
+ item.UserId = user.UserId
|
|
|
+ item.ActivityId = req.ActivityId
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.CompanyName = companyDetail.CompanyName
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.Email = user.Email
|
|
|
+ item.Content = content
|
|
|
+ _, err = models.AddActivityHelpAsk(item)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "提交失败"
|
|
|
+ br.ErrMsg = "提交带问失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var isSendMsg bool
|
|
|
+ resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
|
|
|
+ if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
|
|
|
+ if time.Now().After(resultTime.Add(-time.Minute * 15)) {
|
|
|
+ isSendMsg = true
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if time.Now().After(resultTime.Add(-time.Minute * 60)) {
|
|
|
+ isSendMsg = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if isSendMsg {
|
|
|
+ listEmail, err := models.GetAskEmail()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "提交失败"
|
|
|
+ br.ErrMsg = "提交带问失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var sendMobile string
|
|
|
+ for _, v := range listEmail {
|
|
|
+ if strings.Index(activityInfo.Host, v.Name) > 0 {
|
|
|
+ sendMobile = v.Mobile
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if activityInfo.ChartPermissionId == 31 {
|
|
|
+ sendMobile = utils.ActSendMsgMobile
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取销售信息
|
|
|
+ sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "提交失败"
|
|
|
+ br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //给研究员发送消息
|
|
|
+ if sendMobile != "" {
|
|
|
+ openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
|
|
|
+ if openIpItem != nil && openIpItem.OpenId != "" {
|
|
|
+ if sellerItem != nil {
|
|
|
+
|
|
|
+ services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 给所属销售发送消息
|
|
|
+ if sellerItem != nil {
|
|
|
+ openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
|
|
|
+ if openIpItem != nil && openIpItem.OpenId != "" {
|
|
|
+ services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ popupMsg = "暂无查看权限"
|
|
|
+ resp.PopupMsg = popupMsg
|
|
|
+ resp.HasPermission = hasPermission
|
|
|
+ resp.SellerName = sellerName
|
|
|
+ resp.SellerMobile = sellerMobile
|
|
|
+ }
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = resp
|
|
|
+ br.Msg = "提交成功"
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 视频详情
|
|
|
+// @Description 时间线接口
|
|
|
+// @Param VideoId query int true "视频ID"
|
|
|
+// @Success 200 {object} models.IndustryVideoDetailResp
|
|
|
+// @router /detailVideo [get]
|
|
|
+func (this *ActivityController) DetailVideo() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ user := this.User
|
|
|
+ if user == nil {
|
|
|
+ br.Msg = "请重新登录"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ videoId, _ := this.GetInt("VideoId")
|
|
|
+ videoSimple, au, err := services.GetActivityVideoDetailById(user, videoId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp := new(models.ActivityVideoDetailResp)
|
|
|
+ resp.VideoDetail = videoSimple
|
|
|
+ resp.AuthInfo = au
|
|
|
+ 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 KeyWord query string false "搜索关键词 多个用 , 隔开"
|
|
|
+// @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
|
|
|
+// @Success 200 {object} models.GetCygxActivityListRep
|
|
|
+// @router /listSearch [get]
|
|
|
+func (this *ActivityController) ActivityListSearch() {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ source, _ := this.GetInt("Source")
|
|
|
+ keyWord := this.GetString("KeyWord")
|
|
|
+ playBack, _ := this.GetInt("PlayBack")
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
+ var condition string
|
|
|
+ //活动可见限制
|
|
|
+ conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "3", "", 0, 1, keyWord, playBack)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if source == 1 {
|
|
|
+ condition += ` AND art.yidong_activity_id = '' `
|
|
|
+ }
|
|
|
+ condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
|
|
|
+ listActivity, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, keyWord, playBack)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //用户权限
|
|
|
+ authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp := new(models.HomeResourceDataListResp)
|
|
|
+ var list []*models.CygxResourceDataResp
|
|
|
+ for _, v := range listActivity {
|
|
|
+ var item = new(models.CygxResourceDataResp)
|
|
|
+ //resp.List = append(resp.List, &models.CygxResourceDataResp{
|
|
|
+ item.SourceId = v.ActivityId
|
|
|
+ if v.SourceType == 1 {
|
|
|
+ item.Source = "activity"
|
|
|
+ } else {
|
|
|
+ item.Source = "activityspecial"
|
|
|
+ }
|
|
|
+ item.Title = v.ActivityName
|
|
|
+ item.City = v.City
|
|
|
+ item.IsSignup = v.IsSignup
|
|
|
+ item.IsCancelMeetingReminder = v.IsCancelMeetingReminder
|
|
|
+ item.IsAppointment = v.IsAppointment
|
|
|
+ item.ActiveState = v.ActiveState
|
|
|
+ item.ImgUrlText = v.ImgUrlText
|
|
|
+ item.ImgUrl = v.ImgUrl
|
|
|
+ item.ActivityType = v.ActivityType
|
|
|
+ item.IsShowOutboundCall = v.IsShowOutboundCall
|
|
|
+ item.IsShowMeetingReminder = v.IsShowMeetingReminder
|
|
|
+ item.IsShowHelpSsk = v.IsShowHelpSsk
|
|
|
+ item.IsShowSignup = v.IsShowSignup
|
|
|
+ item.IsShowAppointment = v.IsShowAppointment
|
|
|
+ item.IsShowDetails = v.IsShowDetails
|
|
|
+ item.ActivityTimeText = v.ActivityTimeText
|
|
|
+ item.Expert = v.Expert
|
|
|
+ item.Speaker = v.Speaker
|
|
|
+ item.PublishDate = v.ActivityTime
|
|
|
+ item.TripImgLink = v.TripImgLink
|
|
|
+ item.TripStatus = 2
|
|
|
+ item.ActiveState = v.ActiveState
|
|
|
+ item.PublishDate = v.ActivityTime
|
|
|
+ item.FileType = v.FileType
|
|
|
+ if v.VoiceList != nil || v.VideoDetail != nil {
|
|
|
+ item.AudioLink = true
|
|
|
+ if v.FileType == 1 {
|
|
|
+ if v.VoiceList != nil {
|
|
|
+ item.VoiceDetail = v.VoiceList
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if v.VideoDetail != nil {
|
|
|
+ item.VideoDetail = v.VideoDetail
|
|
|
+ }
|
|
|
+ }
|
|
|
+ au := new(models.UserPermissionAuthInfo)
|
|
|
+ au.SellerName = authInfo.SellerName
|
|
|
+ au.SellerMobile = authInfo.SellerMobile
|
|
|
+ au.HasPermission = authInfo.HasPermission
|
|
|
+ au.OperationMode = authInfo.OperationMode
|
|
|
+ if au.HasPermission == 1 {
|
|
|
+ // 非宏观权限进一步判断是否有权限
|
|
|
+ if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
|
|
|
+ au.HasPermission = 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 无权限的弹框提示
|
|
|
+ if au.HasPermission != 1 {
|
|
|
+ if au.OperationMode == services.UserPermissionOperationModeCall {
|
|
|
+ if v.FileType == 1 {
|
|
|
+ au.PopupMsg = services.UserPermissionPopupMsgCallActivity
|
|
|
+ } else {
|
|
|
+ au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if v.FileType == 1 {
|
|
|
+ au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
|
|
|
+ } else {
|
|
|
+ au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.AuthInfo = au
|
|
|
+ }
|
|
|
+ list = append(list, item)
|
|
|
+ }
|
|
|
+ if len(resp.List) == 0 {
|
|
|
+ resp.List = make([]*models.CygxResourceDataResp, 0)
|
|
|
+ }
|
|
|
+ //添加活动搜索记录
|
|
|
+ if keyWord != "" {
|
|
|
+ //go services.AddActivitykeyWordSearch(keyWord, user)
|
|
|
+ }
|
|
|
+ resp.Paging = page
|
|
|
+ resp.List = list
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|