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 } type ActivityNoLoginController struct { BaseAuthMobileController } // @Title 活动类型列表 // @Description 活动类型列表接口 // @Param IsResearch query bool true "是否为研选" // @Success 200 {object} models.ActivityTypeListResp // @router /activityTypelist [get] func (this *ActivityNoLoginController) 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) isResearch, _ := this.GetBool("IsResearch", false) var condition string //是否仅展示研选下的活动类型 if isResearch { condition = " AND source_type IN (0,2) " } list, err := models.GetActivityTypeList(condition) 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 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" // @Param IsExternalLabel query int false "是否仅展示外部资源 1:是、0:否 默认0" // @Param IsResearchPoints query int false "是否仅展示研选扣点 1:是、0:否 默认0" // @Param IsResearch query bool true "是否为研选" // @Success 200 {object} models.ActivityTypeListHomeResp // @router /labelTypeList [get] func (this *ActivityNoLoginController) 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") isExternalLabel, _ := this.GetInt("IsExternalLabel") // isResearchPoints, _ := this.GetInt("IsResearchPoints") // isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示) var condition string var conditioninit 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)) if isResearch { chartPermissionIds = strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) } else { conditioninit += ` AND ( art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + ` OR ( art.is_show_hz = 1 AND art.chart_permission_id = ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `) )` conditioninit += ` AND IF ( art.active_state = 3, art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `, 1 = 1 ) ` //V 11.0 研选活动结束后就不在已结束页面展示了 } //行业名称 if len(chartPermissionIds) > 0 { //conditioninit += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)` conditioninit += ` AND IF ( art.yidong_activity_id != '' , art.chart_permission_id_deputy IN (` + chartPermissionIds + `) ,1=1 ) ` conditioninit += ` AND IF ( art.yidong_activity_id = '' , art.chart_permission_id IN (` + chartPermissionIds + `) ,1=1 ) ` } //哪一天 if whichDay != "" { var startDate string var endDate string if whichDay == "1" { startDate = time.Now().Format(utils.FormatDate) endDate = startDate } else if whichDay == "2" { startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate) endDate = startDate } else if whichDay == "3" { startDate = utils.GetNowWeekMonday().Format(utils.FormatDate) endDate = utils.GetNowWeekSunday().Format(utils.FormatDate) } else if whichDay == "4" { startDate = utils.GetLastWeekMonday().Format(utils.FormatDate) endDate = utils.GetLastWeekSunday().Format(utils.FormatDate) } else if whichDay == "5" { startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate) endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate) } else if whichDay == "6" { startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate) endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate) } else if whichDay == "1,2" { startDate = time.Now().Format(utils.FormatDate) endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate) } else if whichDay == "3,4" { startDate = utils.GetLastWeekMonday().Format(utils.FormatDate) endDate = utils.GetNowWeekSunday().Format(utils.FormatDate) } else if whichDay == "5,6" { startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate) endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate) } else { startDate = time.Now().Format(utils.FormatDate) endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate) } conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'" conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'" } //活动状态搜索 if activeState != "" { // 默认查看未开始跟进行中 if activeState == "1" { conditioninit += ` AND art.active_state IN (1,2)` } else { conditioninit += ` AND art.active_state IN (` + activeState + `)` } } else { conditioninit += ` AND art.active_state IN (1,2)` } //是否为外部资源 if isExternalLabel == 1 { conditioninit += ` AND art.is_external_label = 1 ` } if isResearchPoints == 1 { conditioninit += ` AND art.is_research_points = 1 ` } conditionActivity, err := services.ActivityConditioninitSql(user, conditioninit, isPower) //conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0, 1) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取失败" br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error() return } //condition += ` AND art.is_limit_people = 1 ` + conditionActivity condition += 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 } var conditionType string if isResearch { conditionType = " AND source_type IN (0,2) " } else { conditionType = " AND source_type IN (0,1) " } list, err := models.GetActivityTypeHomeList(conditionType) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } list, err = services.HandleActivityTypeHomeList(list, activityList, user) //专项产业调研未开始状态不查询 if activeState == "1" { activeState = "" } conditionActivitySpecial := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState) speciaItem, err := services.GetActivityLabelSpecialList(user, conditionActivitySpecial, activeState) 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:音频" // @Param IsExternalLabel query int false "是否仅展示外部资源 1:是、0:否 默认0" // @Param IsResearchPoints query int false "是否仅展示研选扣点 1:是、0:否 默认0" // @Param IsResearch query bool false "是否为研选" // @Success 200 {object} models.GetCygxActivityListRep // @router /list [get] func (this *ActivityNoLoginController) 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") isPower, _ := this.GetInt("IsPower") activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签 isExternalLabel, _ := this.GetInt("IsExternalLabel") // isResearchPoints, _ := this.GetInt("IsResearchPoints") // isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示) if activityTypeId == "5" { activityTypeId = "5,8" //专家线下沙龙可以查看买方线下交流 } var startSize int if pageSize <= 0 { pageSize = utils.PageSize20 } if currentIndex <= 0 { currentIndex = 1 } startSize = utils.StartIndex(currentIndex, pageSize) var condition string var conditioninit string //初始化搜索条件 var pars []interface{} //主题 if label != "" { conditioninit += ` AND art.label LIKE "%` + label + `%" ` } //是否是研选 if isResearch { chartPermissionIds = strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) } else { conditioninit += ` AND ( art.chart_permission_id != '` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `' OR ( art.is_show_hz = 1 AND art.chart_permission_id = '` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `') )` conditioninit += ` AND IF ( art.active_state = 3, art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `, 1 = 1 ) ` //V 11.0 研选活动结束后就不在已结束页面展示了 } //行业名称 if len(chartPermissionIds) > 0 { //conditioninit += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)` conditioninit += ` AND IF ( art.yidong_activity_id != '' , art.chart_permission_id_deputy IN (` + chartPermissionIds + `) ,1=1 ) ` conditioninit += ` AND IF ( art.yidong_activity_id = '' , art.chart_permission_id IN (` + chartPermissionIds + `) ,1=1 ) ` } //哪一天 if whichDay != "" { var startDate string var endDate string if whichDay == "1" { startDate = time.Now().Format(utils.FormatDate) endDate = startDate } else if whichDay == "2" { startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate) endDate = startDate } else if whichDay == "3" { startDate = utils.GetNowWeekMonday().Format(utils.FormatDate) endDate = utils.GetNowWeekSunday().Format(utils.FormatDate) } else if whichDay == "4" { startDate = utils.GetLastWeekMonday().Format(utils.FormatDate) endDate = utils.GetLastWeekSunday().Format(utils.FormatDate) } else if whichDay == "5" { startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate) endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate) } else if whichDay == "6" { startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate) endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate) } else if whichDay == "1,2" { startDate = time.Now().Format(utils.FormatDate) endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate) } else if whichDay == "3,4" { startDate = utils.GetLastWeekMonday().Format(utils.FormatDate) endDate = utils.GetNowWeekSunday().Format(utils.FormatDate) } else if whichDay == "5,6" { startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate) endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate) } else { startDate = time.Now().Format(utils.FormatDate) endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate) } conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'" conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'" } //活动状态搜索 if activeState != "" { // 默认查看未开始跟进行中 if activeState == "1" { conditioninit += ` AND art.active_state IN (1,2)` } else { conditioninit += ` AND art.active_state IN (` + activeState + `)` } } else { conditioninit += ` AND art.active_state IN (1,2)` } // 如果是分析师电话会,那么可以连同C类一起查看 if activityTypeId != "" { if activityTypeId == strconv.Itoa(utils.ANALYST_TELL_ACTIVITY_TYPE_ID) { conditioninit += ` AND art.activity_type_id IN (` + activityTypeId + "," + strconv.Itoa(utils.C_CLASS_ACTIVITY_TYPE_ID) + `)` } else { conditioninit += ` AND art.activity_type_id IN (` + activityTypeId + `)` } } //关键词搜索 if keyWord != "" { conditioninit += ` AND (art.label REGEXP '` + keyWord + `' OR art.activity_name REGEXP '` + keyWord + `' ) ` } //回放 if playBack == 1 { //获取所有带回放的活动ID playBackActivityIds, err := services.GetActivityPlayBackActivityIds() if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } conditioninit += ` AND art.activity_id IN ( ` + playBackActivityIds + `) ` } //音频视频 1:视频 2:音频 if filter > 0 { videoOrVoiceActivityIds, err := services.GetActivityVideoOrVoiceActivityIds(filter) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } conditioninit += ` AND art.activity_id IN ( ` + videoOrVoiceActivityIds + `) ` } if isExternalLabel == 1 && isResearchPoints == 1 { conditioninit += ` AND ( art.is_external_label = 1 OR art.is_research_points = 1 )` } else { //是否为外部资源 if isExternalLabel == 1 { conditioninit += ` AND art.is_external_label = 1 ` } // 是否为研选扣点 if isResearchPoints == 1 { conditioninit += ` AND art.is_research_points = 1 ` } } condition = "" //活动可见限制 conditionActivity, err := services.ActivityConditioninitSql(user, conditioninit, isPower) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取失败" br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error() return } condition += ` 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 } //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" || activeState == "1,2" || activeState == "" { conditionOrder = ` ORDER BY art.top_time DESC , 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 } //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0 if v.YidongActivityId != "" { if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) { au.HasPermission = 1 } } } // 无权限的弹框提示 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, permissionArr)) } activityList = services.ActivityArrButtonShow(list, user, permissionArr) //处理不同的报名方式按钮回显 mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error() return } for _, v := range activityList { v.SignupType = mapActivitySignup[v.ActivityId] } // 查研观向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) //} if len(activityList) == 0 { activityList = make([]*models.ActivityListResp, 0) } if activityTypeId == "3" || activityTypeId == "5" { resp.IsShowResearchPoints = true } //预处理返给前端的字段 resp.List = activityList 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 strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { activityInfo.IsResearch = true } if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID { activityInfo.IsCClassMeeting = true } signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId) if err != nil { br.Msg = "获取信息" br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error() return } activityInfo.SignupNum = signupCount havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial detailResp := services.ActivityButtonShow(activityInfo, user, make([]string, 0)) detailResp, err = services.ActivityDetaailShow(detailResp) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId) return } if havePower { resp.HasPermission = 1 //permissionArr := make([]string, 0) //处理活动关联的产业 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) if activityInfo.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN { // 研选的音视频不在查研展示 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] } } //处理不同的报名方式按钮回显 mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error() return } detailResp.SignupType = mapActivitySignup[activityId] detailResp.ShareImg = services.GetActivityShareImg(activityInfo) 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 } detailResp.AuthInfo.HasPermission = resp.HasPermission // 判断是否属于研选类型的活动 if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = 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/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 email := req.Email //如果用户传了邮箱就绑定邮箱 if email != "" && user.Email == "" { if !utils.ValidateEmailFormatat(req.Email) { br.Msg = "邮箱格式错误,请重新输入" br.ErrMsg = "邮箱格式错误,请重新输入" return } user.Email = req.Email err = models.UpdateUserEmail(email, uid) if err != nil { br.Msg = "操作失败" br.ErrMsg = "绑定客户邮箱失败!" } } 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 } // 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会 if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 { signupType = 4 } havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial 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 } //限制人数为1人的专家电话会 用户操作时的消息提示 if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 { resp.HasPermission = hasPermission resp.SignupStatus = utils.FULLSTARFFED_MSG resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG 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 } popupMsg, err := services.CheckActivityUserAll(activityInfo, user) if err != nil { br.Msg = "报名失败!" br.ErrMsg = "CheckActivityUserAll,Err:" + err.Error() return } if popupMsg != "" { br.Msg = "报名失败!" br.ErrMsg = fmt.Sprint("userId:", uid, "Activity:id", popupMsg) return } //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"` //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙) //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 { if activityInfo.IsLimitPeople == 1 { signupStatus, resp.PopupMsg, item.FailType, err = services.CheckActivitySignUpLimit(user, activityInfo) //判断优先级:总人数限制→单机构2人限制→爽约3次限制 totalRestrict, err := models.GetUserRestrictCount(user.Mobile) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取客户信息失败,Err:" + err.Error() return } 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 = "预约成功,已加入您的活动日程

想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号" } else if signupType == 4 { go services.ActivityUserRemind(user, activityInfo, 4) resp.PopupMsg = "报名成功,请复制腾讯会议号打开腾讯会议app参会

想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号" } else { go services.ActivityUserRemind(user, activityInfo, 4) resp.PopupMsg = "报名成功,已加入您的活动日程

想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号" } if activityInfo.IsResearchPoints { resp.PopupMsg = "报名成功,已加入您的活动日程

想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号" } // 如果是买方研选下的专家沙龙,同时推给内容组四人 if activityInfo.ActivityTypeId == 5 && activityInfo.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN { go services.SendNeiRongZuActivitieSignTemplateMsg(user, activityInfo) go services.SendNeiRongZuActivitieSignCategoryTemplateMsg(user, activityInfo) } go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点 } } 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) } // 判断是否属于研选类型的活动 if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } //公司线下调研活动客户报名后给建会人,所属销售推送模板信息 if signupStatus == "Success" { go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "报名") } 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 } //checkTime, _ := services.CheckSiginupDeadline(activityInfo) //if !checkTime { // br.Msg = "报名名单已提交举办方,若想取消,请联系对口销售" // br.ErrMsg = "报名名单已提交举办方,若想取消,请联系对口销售" // return //} cancelDeadlineMsg := services.CheckCancelDeadline(activityInfo) if cancelDeadlineMsg != "" { br.Msg = cancelDeadlineMsg br.ErrMsg = cancelDeadlineMsg 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小时内无法取消报名,请联系对口销售处理" } br.ErrMsg = br.Msg 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 } // 如果是买方研选下的专家沙龙,同时推给内容组四人 if activityInfo.ActivityTypeId == 5 { go services.SendActivitieCancelSignTemplateMsg(user, activityInfo) go services.SendActivitieCancelSignCategoryTemplateMsg(user, activityInfo) } go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "取消报名") //公司线下调研活动客户报名后给建会人,所属销售推送模板信息 go services.YanXuanActivityPointsBillSignupCancel(activityId, uid) // 用户取消报名添加到处理研选扣点 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, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial 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 } //限制人数为1人的专家电话会 用户操作时的消息提示 if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 { resp.HasPermission = hasPermission resp.SignupStatus = utils.FULLSTARFFED_MSG resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG br.Ret = 200 br.Success = true br.Msg = "" br.Data = resp 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 } br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒" resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒

请关注【查研观向小助手】公众号,以获取微信消息提醒" } 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 strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } 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, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial if havePower { item := new(models.CygxActivityAppointment) item.RegisterPlatform = utils.REGISTER_PLATFORM resp.HasPermission = 1 //限制人数为1人的专家电话会 用户操作时的消息提示 if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 { resp.SignupStatus = utils.FULLSTARFFED_MSG resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG br.Ret = 200 br.Success = true br.Msg = "" br.Data = resp return } 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 } // 判断是否属于研选类型的活动 if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } 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 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, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial 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 msgId, 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) services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId)) } } } // 给所属销售发送消息 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) services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId)) } go services.SendWxCategoryMsgWithAsk(user, activityInfo, content, int(msgId)) } } } 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 strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } 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, 1) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取失败" br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error() return } if source == 1 { condition += ` AND art.yidong_activity_id = '' ` } //conditionActivity, err := services.ActivityConditioninitSql(user, conditionInit, 0) //if err != nil && err.Error() != utils.ErrNoRow() { // br.Msg = "获取失败" // br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error() // return //} condition += ` AND art.publish_status = 1 ` + conditionActivity listActivity, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, playBack, keyWord) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } //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.SignupType = v.SignupType item.ActivityTypeId = v.ActivityTypeId 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.DistinguishedGuest = v.DistinguishedGuest item.PublishDate = v.ActivityTime item.TripImgLink = v.TripImgLink item.TripStatus = 2 item.ActiveState = v.ActiveState item.PublishDate = v.ActivityTime item.FileType = v.FileType item.IsYidongConduct = v.IsYidongConduct item.IsCanOutboundCall = v.IsCanOutboundCall item.IsLimitPeople = v.IsLimitPeople item.IsResearchPoints = v.IsResearchPoints item.SiginupDeadline = v.SiginupDeadline item.IsYidongActivity = v.IsYidongActivity // 判断是否属于研选类型的活动 if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { item.IsResearch = true if (v.ActivityTypeId == 3 || v.ActivityTypeId == 5) && v.YidongActivityId == "" && strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) && utils.InArrayByStr(permissionArr, utils.CHART_PERMISSION_NAME_MF_YANXUAN) { item.IsResearchSpecial = true } } 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 } //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0 if v.YidongActivityId != "" { if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) { au.HasPermission = 1 } } } // 无权限的弹框提示 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(list) == 0 { 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 } // @Title 我的日程 // @Description 我的日程列表接口 // @Param PageSize query int true "每页数据条数" // @Param CurrentIndex query int true "当前页页码,从1开始" // @Success 200 {object} models.GetCygxActivityListRep // @router /scheduleList [get] func (this *ActivityController) 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") //source, _ := this.GetInt("Source") var startSize int if pageSize <= 0 { pageSize = utils.PageSize20 } if currentIndex <= 0 { currentIndex = 1 } startSize = utils.StartIndex(currentIndex, pageSize) var condition string var conditionCount string var pars []interface{} condition += ` AND art.publish_status = 1 ` //if source == 1 { // condition += ` AND art.yidong_activity_id = '' ` // conditionCount += ` AND art.yidong_activity_id = '' ` //} total, err := models.GetScheduleCount(conditionCount, uid) specialtotal, err := models.GetSpecialScheduleCount(uid) page := paging.GetPaging(currentIndex, pageSize, total+specialtotal) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } conditionCount = ` AND art.active_state = 2 ` totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量 if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } var list []*models.ActivityDetail //全部都是进行中的活动 if totalCount > currentIndex*pageSize { condition += ` AND art.active_state IN(2) ` //if source == 1 { // condition += ` AND art.yidong_activity_id = '' ` //} listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize) list = listHave if errList != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + errList.Error() return } } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动 condition = ` AND art.publish_status = 1 AND art.active_state IN(2) ` //if source == 1 { // condition += ` AND art.yidong_activity_id = '' ` //} listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize) list = listHave if errList != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + errList.Error() return } pageSize = pageSize - len(listHave) condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) ` //if source == 1 { // condition += ` AND art.yidong_activity_id = '' ` //} //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize) listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize) if errList != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + errList.Error() return } if len(listOther) > 0 { for _, v := range listOther { list = append(list, v) } } } else { condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动 //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize) listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize) list = listOther 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, utils.CHART_PERMISSION_NAME_YANXUAN) { list[k].IsResearch = true } if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 { //list[k].ActivityTypeName = "买方研选电话会" //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png" list[k].ImgUrlText = utils.YAN_XUAN_IMG } if v.ActivityType == 0 && v.SourceType == 1 { 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.IsHideAppointment == 0 { list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName) } if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID { list[k].IsCClassMeeting = true } mapActivityId = append(mapActivityId, v.ActivityId) } //添加我的日程访问记录 item := new(models.CygxPageHistoryRecord) item.UserId = user.UserId item.CreateTime = time.Now() item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName item.PageType = "MySchedule" go models.AddCygxPageHistoryRecord(item) resp := new(models.GetCygxActivityListRep) //处理音频回放 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 } //处理不同的报名方式按钮回显 mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error() return } for k, v := range list { if mapActivityVoice[v.ActivityId] != nil { list[k].FileType = 1 list[k].AudioLink = true list[k].VoiceList = mapActivityVoice[v.ActivityId] } if mapActivityVideo[v.ActivityId] != nil { list[k].FileType = 2 list[k].AudioLink = true list[k].VideoDetail = mapActivityVideo[v.ActivityId] } v.SignupType = mapActivitySignup[v.ActivityId] //处理列表的标签是否展示逻辑 resp.List = append(resp.List, services.ActivityButtonShow(v, user, make([]string, 0))) } resp.Paging = page 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 /check [post] func (this *ActivityController) Check() { 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 } 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 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.ActivityCheck) resp.CancelPopupMsg, err = services.ActivityCancelDeadlineMsg(activityInfo) //处理取消报名截止时间的弹窗文案 if err != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + err.Error() return } hasPermission := 0 havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial if havePower { hasPermission = 1 resp.CheckPermission = true resp.HasPermission = hasPermission } else { hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error() return } resp.PopupMsg = popupMsg resp.HasPermission = hasPermission resp.SellerName = sellerName resp.SellerMobile = sellerMobile } if resp.CheckPermission { //如果权限通过了校验,那么就来校验时间 resp.CheckTime, resp.PopupMsg = services.CheckSiginupDeadline(activityInfo) } if resp.CheckTime { // 如果时间通过校验就校验点数 resp.CheckPoints, resp.PopupMsg, resp.CompanyPoints, resp.ActivityPoints, err = services.CheckActivityPoints(activityInfo, user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "CheckActivityPoints,Err:" + err.Error() return } } if resp.CheckPoints { //如果通过点数的校验,就来校验邮箱 resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user) } // 判断是否属于研选类型的活动 if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } br.Ret = 200 br.Success = true br.Data = resp } // @Title 记录用户浏览音频回放接口 // @Description 记录用户浏览音频回放接口 // @Param request body models.ActivityIdRep true "type json string" // @Success Ret=200 {object} models.AppointmentResp // @router /voiceHistory/add [post] func (this *ActivityController) ActivityVoiceHistoryAdd() { 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 playSeconds := req.PlaySeconds 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 } var sellerName string sellerName, err = models.GetCompanySellerName(user.CompanyId) if err != nil { br.Msg = "报名失败!" br.ErrMsg = "获取对应销售失败,Err:" + err.Error() return } item := models.CygxActivityVoiceHistory{ ActivityId: activityId, UserId: uid, CreateTime: time.Now(), Mobile: user.Mobile, Email: user.Email, CompanyId: user.CompanyId, CompanyName: user.CompanyName, RealName: user.RealName, SellerName: sellerName, PlaySeconds: strconv.Itoa(req.PlaySeconds), ModifyTime: time.Now(), } if playSeconds != 0 { lastItem, err := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId) if err != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,GetLastCygxActivityVoiceHistory Err:" + err.Error() return } err = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id) if err != nil { br.Msg = "更新失败" br.ErrMsg = "更新失败,UpdateLastCygxActivityVoiceHistory Err:" + err.Error() return } } else { err = models.AddCygxActivityVoiceHistory(&item) if err != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + err.Error() return } err = models.UpdateCygxActivityVoiceCounts(activityId) if err != nil { br.Msg = "更新失败" br.ErrMsg = "更新失败,Err:" + err.Error() return } go services.ActivityVideoUserRmind(user, activityId, 2) } br.Ret = 200 br.Success = true br.Msg = "操作成功" return } // @Title 获取易董活动跳转地址详情 // @Description 获取易董活动跳转地址详情接口 // @Param ActivityId query int true "活动ID" // @Success Ret=200 {object} models.CygxActivityResp // @router /get_yidong_url [get] func (this *ActivityController) GetYidongUrl() { 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.CygxYidongActivityUrlResp) activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error() return } havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial if havePower { resp.HasPermission = 1 if activityInfo.YidongActivityId != "" { ydTgc, _ := services.GetYiDongCreateUserInfo(user) yidongLongLink, _ := services.GetYiDongOriginalLink(activityInfo) if yidongLongLink != "" { resp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc } } } 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 /checkAsk [post] func (this *ActivityController) CheckAsk() { 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 } var signupStatus string 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 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) hasPermission := 0 havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial if havePower { hasPermission = 1 signupStatus = "Success" //限制人数为1人的专家电话会 用户操作时的消息提示 if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 { resp.HasPermission = hasPermission resp.SignupStatus = utils.FULLSTARFFED_MSG resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG br.Ret = 200 br.Success = true br.Msg = "" br.Data = resp return } resp.HaqveJurisdiction = true resp.HasPermission = hasPermission resp.SignupStatus = signupStatus } 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 strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } resp.ActivityId = activityId br.Ret = 200 br.Success = true br.Data = resp }