package controllers
import (
"encoding/json"
"fmt"
"hongze/hongze_cygx/models"
"hongze/hongze_cygx/services"
"hongze/hongze_cygx/utils"
"sort"
"strconv"
"strings"
"time"
"github.com/medivhzhan/weapp/v2"
"github.com/rdlucklib/rdluck_tools/paging"
)
// 活动
type ActivityCoAntroller struct {
BaseAuthController
}
type ActivityABaseController struct {
BaseCommonController
}
type ActivityNoLoginController struct {
BaseAuthMobileController
}
// @Title 活动类型列表
// @Description活动类型列表接口
// @Param IsResearch query bool true "是否为研选"
// @Success 200 {object} models.ActivityTypeListResp
// @router /activityTypelist [get]
func (this *ActivityCoAntroller) List() {
br := new(models.BaseResponse).Init()
defer func() {
this.Data["json"] = br
this.ServeJSON()
}()
user := this.User
if user == nil {
br.Msg = "请登录"
br.ErrMsg = "请登录,SysUser Is Empty"
br.Ret = 408
return
}
resp := new(models.ActivityTypeListResp)
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 PageSize query int true "每页数据条数"
// @Param CurrentIndex query int true "当前页页码,从1开始"
// @Param Source query int false "来源 0:手机 ,1:Pc 默认0"
// @Success 200 {object} models.GetCygxActivityListRep
// @router /scheduleList [get]
func (this *ActivityCoAntroller) ScheduleList() {
br := new(models.BaseResponse).Init()
defer func() {
this.Data["json"] = br
this.ServeJSON()
}()
user := this.User
if user == nil {
br.Msg = "请登录"
br.ErrMsg = "请登录,SysUser Is Empty"
return
}
uid := user.UserId
pageSize, _ := this.GetInt("PageSize")
currentIndex, _ := this.GetInt("CurrentIndex")
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, "研选") && 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.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))
}
resp.Paging = page
br.Ret = 200
br.Success = true
br.Msg = "获取成功"
br.Data = resp
}
// @Title 活动详情
// @Description 获取活动详情接口
// @Param ActivityId query int true "活动ID"
// @Param IsSendWx query int false "是否是通过微信模版进来的 1是,其它否"
// @Success Ret=200 {object} models.CygxActivityResp
// @router /detail [get]
func (this *ActivityCoAntroller) Detail() {
br := new(models.BaseResponse).Init()
defer func() {
this.Data["json"] = br
this.ServeJSON()
}()
user := this.User
if user == nil {
br.Msg = "请登录"
br.ErrMsg = "请登录,用户信息为空"
br.Ret = 408
return
}
uid := user.UserId
activityId, _ := this.GetInt("ActivityId")
isSendWx, _ := this.GetInt("IsSendWx")
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) {
resp.IsResearch = 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
if havePower {
//是否展示限免标签
if services.GetShowSustainable() && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
activityInfo.IsShowSustainable = true
}
resp.HasPermission = 1
configCode := "description_of_research"
detail, err := models.GetConfigByCode(configCode)
if err != nil {
br.Msg = "获取数据失败"
br.ErrMsg = "获取数据失败,Err:" + err.Error()
return
}
activityInfo.Description = detail.ConfigValue
if activityInfo.SignupNum > activityInfo.LimitPeopleNum {
activityInfo.SignupNum = activityInfo.LimitPeopleNum
}
if activityInfo.ChartPermissionNames != "" {
activityInfo.ChartPermissionName = activityInfo.ChartPermissionNames
}
if activityInfo.IsHideAppointment == 0 {
activityInfo.IsShowAppointment = services.IsShowAppointment(activityInfo.ActivityTypeId, activityInfo.ChartPermissionName)
}
activityInfo.ActivityTypeName = strings.Replace(activityInfo.ActivityTypeName, "(C类)", "", -1)
//处理活动关联的产业
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(user.UserId, condition, 0, 0)
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
}
//非买方研选下的才展示New标签
if activityInfo.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN {
industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
}
}
}
}
activityInfo.Listndustrial = industrialList
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
}
//yidongKwy := activityInfo.YidongActivityUrl
//activityInfo.YidongActivityUrl = yidongLongLink + "?source=11&fromHz=true&tgc=" + ydTgc
activityInfo.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
}
//处理音频回放
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 {
activityInfo.FileType = 1
activityInfo.AudioLink = true
activityInfo.VoiceList = mapActivityVoice[activityId]
}
//处理视频回放
mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
return
}
if mapActivityVideo[activityId] != nil {
activityInfo.FileType = 2
activityInfo.AudioLink = true
activityInfo.VideoDetail = mapActivityVideo[activityId]
}
}
//8.5 小程序活动详情页 除专家电话外 其余属于新产业的活动 ,不显示 new 标签
if activityInfo.ActivityTypeName != "专家电话会" {
for _, rep := range activityInfo.Listndustrial {
rep.IndustryNewLabel = false
}
}
//8.5 买方研选的活动去掉限免标签
if strings.Contains(activityInfo.ChartPermissionName, "研选") {
activityInfo.IsShowSustainable = false
}
//处理不同的报名方式按钮回显
mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
return
}
activityInfo.SignupType = mapActivitySignup[activityId]
//处理活动关联的产业
industrialListNew, err := models.GetIndustrialActivityGroupManagementList(activityId)
if err != nil && err.Error() != utils.ErrNoRow() {
br.Msg = "获取信息失败"
br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
return
}
//判断是不是通过微信模版推送消息进来的
if isSendWx == 1 && len(industrialListNew) > 0 {
industryUserFollowMap, err := services.GetIndustryUserFollowMap(user)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "GetIndustryUserFollowMap,Err:" + err.Error()
return
}
for _, v := range industrialListNew {
if industryUserFollowMap[v.IndustrialManagementId] {
activityInfo.IsFollowButton = true
}
}
activityInfo.IsShowFollowButton = true
}
if activityInfo.ReportLink != "" {
artList, err := services.GetActivityReportLinkToArticleList(activityInfo)
if err != nil && err.Error() != utils.ErrNoRow() {
br.Msg = "获取信息失败"
br.ErrMsg = "解析文章关联的报告内容失败:" + activityInfo.ReportLink
return
}
activityInfo.ArticleList = artList
} else {
activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
}
if services.GetBelongingRai(user.Mobile) && activityInfo.SigninImg != "" {
activityInfo.IsShowSigninButton = true
activityInfo.IsShowSignUpDetail = true
}
//处理按钮是否展示问题
//resp.Detail = services.ActivityButtonShow(activityInfo)
} else {
//用户未登录(绑定登录信息)的时候也能展示 v12.2.1
if user.UserId == 0 {
resp.HasPermission = 1
//resp.Detail = services.ActivityButtonShow(activityInfo)
} else {
hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
return
}
resp.PopupMsg = popupMsg
resp.HasPermission = hasPermission
resp.SellerName = sellerName
resp.SellerMobile = sellerMobile
}
}
//获取活动对应的封面图
mapUrl := services.GetActivityImgMap([]*models.ActivityDetail{activityInfo})
if mapUrl[activityId] != nil {
activityInfo.ImgUrl = mapUrl[activityId].ImgUrl
}
activityInfo.HighlightsText, _ = services.GetReportContentTextSub(activityInfo.HighlightsText)
activityInfo.ExpertText, _ = services.GetReportContentTextSub(activityInfo.Expert)
activityInfo.ThemeText, _ = services.GetReportContentTextSub(activityInfo.Theme)
//处理按钮是否展示问题
resp.Detail = services.ActivityButtonShow(activityInfo)
collectCount1, err := models.GetActivityVoiceCollectCount(uid, activityId)
if err != nil && err.Error() != utils.ErrNoRow() {
br.Msg = "获取信息失败"
br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";activityId" + strconv.Itoa(activityId)
return
}
collectCount2, err := models.GetActivityVideoCollectCountByActivityId(uid, activityId)
if err != nil && err.Error() != utils.ErrNoRow() {
br.Msg = "获取信息失败"
br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";activityId" + strconv.Itoa(activityId)
return
}
if collectCount1+collectCount2 > 0 {
resp.Detail.IsCollect = 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 *ActivityCoAntroller) SignupAdd() {
br := new(models.BaseResponse).Init()
defer func() {
this.Data["json"] = br
this.ServeJSON()
}()
user := this.User
if user == nil {
br.Msg = "请登录"
br.ErrMsg = "请登录,用户信息为空"
br.Ret = 408
return
}
uid := user.UserId
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
}
if user.Mobile == "" {
user.Mobile = user.OutboundMobile
}
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
}
detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error()
return
}
// 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会
if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 {
signupType = 4
}
item := new(models.CygxActivitySignup)
// 判断是否属于研选类型的活动
if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
resp.IsResearch = true
}
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"
resp.HasPermission = hasPermission
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 = popupMsg
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
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 = "预约成功,已加入您的活动日程
想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
resp.PopupMsg = "预约成功,已加入您的活动日程
是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
} else if signupType == 4 {
go services.ActivityUserRemind(user, activityInfo, 4)
//resp.PopupMsg = "报名成功,请复制腾讯会议号打开腾讯会议app参会
想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
resp.PopupMsg = "报名成功,请复制腾讯会议号打开腾讯会议app参会
是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
} else {
go services.ActivityUserRemind(user, activityInfo, 4)
//resp.PopupMsg = "报名成功,已加入您的活动日程
想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
resp.PopupMsg = "报名成功,已加入您的活动日程
是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
}
// 如果是买方研选下的专家沙龙,同时推给内容组四人
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.GetUserHasPermissionActivity(user, activityInfo)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
return
}
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
}
//公司线下调研活动客户报名后给建会人,所属销售推送模板信息
if signupStatus == "Success" {
go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "报名")
}
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
resp.ActivityTypeName = activityInfo.ActivityName
resp.ActivityTime = activityInfo.ActivityTime
resp.ActivityType = detailActivityType.ActivityType
//}
//去关注12.6小程序添加日历 去关注公众号强制取消关注
//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 *ActivityCoAntroller) SignupCancel() {
br := new(models.BaseResponse).Init()
defer func() {
this.Data["json"] = br
this.ServeJSON()
}()
user := this.User
if user == nil {
br.Msg = "请登录"
br.ErrMsg = "请登录,用户信息为空"
br.Ret = 408
return
}
uid := user.UserId
var req models.ActivitySingnupRep
err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
if err != nil {
br.Msg = "参数解析异常!"
br.ErrMsg = "参数解析失败,Err:" + err.Error()
return
}
activityId := req.ActivityId
signupType := req.SignupType
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
}
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小时内无法取消报名,请联系对口销售处理"
}
return
}
total, err := models.GetActivitySignupCount(uid, activityId)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
if total == 0 {
br.Msg = "您暂未报名这个活动"
return
}
item.UserId = uid
item.ActivityId = activityId
item.CreateTime = time.Now()
item.Mobile = user.Mobile
item.Email = user.Email
item.CompanyId = user.CompanyId
item.CompanyName = user.CompanyName
resp := new(models.SignupStatus)
resp.ActivityId = activityId
_, errSignup := models.CancelActivitySignup(item)
if errSignup != nil {
br.Msg = "操作失败"
br.ErrMsg = "操作失败,Err:" + errSignup.Error()
return
}
// 如果是买方研选下的专家沙龙,同时推给内容组四人
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 = "操作成功"
br.Data = resp
}
// @Title 用户搜索详情
// @Description 获取用户搜索详情接口
// @Param IsShowJurisdiction query int true "是否仅展示有权限的,默认为0,1是,2否 "
// @Param IsHideResearch query int true "是否隐藏研选行业 "
// @Success Ret=200 {object} models.ActivityUserSearchContentList
// @router /getUserSearchContent [get]
func (this *ActivityCoAntroller) GetUserSearchContent() {
br := new(models.BaseResponse).Init()
defer func() {
this.Data["json"] = br
this.ServeJSON()
}()
user := this.User
if user == nil {
br.Msg = "请登录"
br.ErrMsg = "请登录,用户信息为空"
br.Ret = 408
return
}
isHideResearch, _ := this.GetBool("IsHideResearch", false)
uid := user.UserId
detailSeearch := new(models.CygxActivityUserSearchContent)
detailSeearch.IsShowJurisdiction = 0
detailSeearch.ChartPermissionids = ""
detailSeearch.ActiveState = ""
resp := new(models.ActivityUserSearchContentList)
detail, _ := models.GetUserSearchContentByUid(uid)
if detail == nil {
detail = detailSeearch
}
isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
listActivityType, errActivityType := models.GetActivityTypeList("")
if errActivityType != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取数据失败,Err:" + errActivityType.Error()
return
}
var listChartPermissionid []*models.ActivityChartPermission
var errChart error
if isShowJurisdiction == 1 {
listChartPermissionidAll, errChartAll := models.GetUserCompanyPermission(user.CompanyId)
listChartPermissionid = listChartPermissionidAll
errChart = errChartAll
} else if isShowJurisdiction == 2 {
listChartPermissionidAll, errChartAll := models.GetChartPermissionActivity()
listChartPermissionid = listChartPermissionidAll
errChart = errChartAll
} else {
if detail.IsShowJurisdiction == 1 {
listChartPermissionidAll, errChartAll := models.GetUserCompanyPermission(user.CompanyId)
listChartPermissionid = listChartPermissionidAll
errChart = errChartAll
} else {
listChartPermissionidAll, errChartAll := models.GetChartPermissionActivity()
listChartPermissionid = listChartPermissionidAll
errChart = errChartAll
}
}
if errChart != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "获取品种信息失败,Err:" + errChart.Error()
return
}
if detail.IsShowJurisdiction == 1 {
resp.IsShowJurisdiction = true
}
if isShowJurisdiction == 1 || detail.IsShowJurisdiction == 1 {
resp.IsShowJurisdiction = true
for k, _ := range listChartPermissionid {
listChartPermissionid[k].IsChoose = true
}
}
if isShowJurisdiction == 2 {
resp.IsShowJurisdiction = false
}
activeStateList := []models.ActivityStaus{models.ActivityStaus{Id: 1, StatusName: "未开始", IsChoose: true}, models.ActivityStaus{Id: 2, StatusName: "进行中"}, models.ActivityStaus{Id: 3, StatusName: "已结束"}}
list2, err := models.GetChartPermissionActivity()
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
return
}
if activeStateList[1].IsChoose == activeStateList[2].IsChoose == false {
activeStateList[0].IsChoose = true
}
var userType int
userType, _, err = services.GetUserType(user.CompanyId)
if err != nil {
br.Msg = "获取信息失败!"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
var listChartPermissionidNew2 []*models.ActivityChartPermission
for _, v := range list2 {
if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
v.PermissionName = utils.MAI_FANG_YAN_XUAN_NAME
}
if userType == 1 || isHideResearch {
if !strings.Contains(v.PermissionName, "研选") {
listChartPermissionidNew2 = append(listChartPermissionidNew2, v)
}
} else {
listChartPermissionidNew2 = append(listChartPermissionidNew2, v)
}
}
resp.ListChartPermission2 = listChartPermissionidNew2
var listChartPermissionidNew []*models.ActivityChartPermission
for _, v := range listChartPermissionid {
if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
v.PermissionName = utils.MAI_FANG_YAN_XUAN_NAME
}
if userType == 1 || isHideResearch {
if !strings.Contains(v.PermissionName, "研选") {
listChartPermissionidNew = append(listChartPermissionidNew, v)
}
} else {
listChartPermissionidNew = append(listChartPermissionidNew, v)
}
}
resp.ListActivityType = listActivityType
resp.ListChartPermission = listChartPermissionidNew
resp.ListActivityStaus = activeStateList
br.Ret = 200
br.Success = true
br.Msg = "获取成功"
br.Data = resp
}
// @Title 添加会议提醒
// @Description 添加会议提醒接口
// @Param request body models.ActivityIdRep true "type json string"
// @Success Ret=200 {object} models.SignupStatus
// @router /meetingReminder/add [post]
func (this *ActivityCoAntroller) MeetingReminderAdd() {
br := new(models.BaseResponse).Init()
defer func() {
this.Data["json"] = br
this.ServeJSON()
}()
user := this.User
if user == nil {
br.Msg = "请登录"
br.ErrMsg = "请登录,用户信息为空"
br.Ret = 408
return
}
uid := user.UserId
//var signupStatus string
signupStatus := "Success"
var req models.ActivityIdRep
err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
if err != nil {
br.Msg = "参数解析异常!"
br.ErrMsg = "参数解析失败,Err:" + err.Error()
return
}
activityId := req.ActivityId
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
}
//SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
item := new(models.CygxActivityMeetingReminder)
resp := new(models.SignupStatus)
hasPermission := 0
resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
if time.Now().After(resultTime.Add(-time.Minute * 15)) {
br.Msg = "活动开始前15分钟无法设置会议提醒"
return
}
// 判断是否属于研选类型的活动
if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
resp.IsResearch = true
}
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
}
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
resp.HasPermission = hasPermission
_, errSignup := models.AddActivityMeetingReminder(item)
if errSignup != nil {
br.Msg = "操作失败"
br.ErrMsg = "操作失败,Err:" + errSignup.Error()
return
}
resp.HaqveJurisdiction = true
//1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
go services.ActivityUserRemind(user, activityInfo, 2)
} else {
hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
return
}
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.SignupStatus = signupStatus
resp.ActivityId = activityId
//var total int
//total, err = models.GetUserActivityMeetingReminderCount(user.UserId)
//if err != nil {
// br.Msg = "获取信息失败"
// br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
// return
//}
//if total <= 1 {
// resp.GoFollow = true
//}
detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error()
return
}
resp.ActivityTypeName = activityInfo.ActivityName
resp.ActivityTime = activityInfo.ActivityTime
resp.ActivityType = detailActivityType.ActivityType
br.Ret = 200
br.Success = true
if hasPermission == 1 {
br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒
是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
//resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒
请关注【查研观向小助手】公众号,以获取微信消息提醒"
}
br.Data = resp
}
// @Title 取消会议提醒
// @Description 取消会议提醒接口
// @Param request body models.ActivityIdRep true "type json string"
// @Success Ret=200 {object} models.SignupStatus
// @router /meetingReminder/cancel [post]
func (this *ActivityCoAntroller) MeetingReminderCancel() {
br := new(models.BaseResponse).Init()
defer func() {
this.Data["json"] = br
this.ServeJSON()
}()
user := this.User
if user == nil {
br.Msg = "请登录"
br.ErrMsg = "请登录,用户信息为空"
br.Ret = 408
return
}
uid := user.UserId
var req models.ActivityIdRep
err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
if err != nil {
br.Msg = "参数解析异常!"
br.ErrMsg = "参数解析失败,Err:" + err.Error()
return
}
activityId := req.ActivityId
signupStatus := "Success"
item := new(models.CygxActivityMeetingReminder)
activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
if activityInfo == nil {
br.Msg = "操作失败"
br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
return
}
if errInfo != nil {
br.Msg = "操作失败"
br.ErrMsg = "操作失败,Err:" + errInfo.Error()
return
}
//if signupStatus == "Success" {
total, err := models.GetActivityMeetingReminderCount(uid, activityId)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
if total == 0 {
br.Msg = "您暂未添加该活动会议提醒"
return
}
resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
if time.Now().After(resultTime.Add(-time.Minute * 15)) {
br.Msg = "活动开始前15分钟无法取消会议提醒"
return
}
item.UserId = uid
item.ActivityId = activityId
item.CreateTime = time.Now()
item.Mobile = user.Mobile
item.Email = user.Email
item.CompanyId = user.CompanyId
item.CompanyName = user.CompanyName
_, errSignup := models.CancelActivityMeetingReminder(item)
if errSignup != nil {
br.Msg = "操作失败"
br.ErrMsg = "操作失败,Err:" + errSignup.Error()
return
}
//}
resp := new(models.SignupStatus)
resp.SignupStatus = signupStatus
resp.ActivityId = activityId
br.Ret = 200
br.Success = true
br.Msg = "会议提醒已取消"
br.Data = resp
}
// @Title 敏捷搜索关键词的列表
// @Description 获取敏捷搜索关键词的列表接口
// @Success 200 {object} models.ActivityFastsearchKeywordsListResp
// @router /fastSearchKeWord [get]
func (this *ActivityABaseController) FastSearch() {
br := new(models.BaseResponse).Init()
defer func() {
this.Data["json"] = br
this.ServeJSON()
}()
resp := new(models.ActivityFastsearchKeywordsListResp)
list, err := models.GetActivityFastsearchKeywordsList()
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 request body models.AddCygxActivityHelpAsk true "type json string"
// @Success Ret=200 新增成功
// @router /askAdd [post]
func (this *ActivityCoAntroller) 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
}
//resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
//if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
// if time.Now().After(resultTime.Add(-time.Minute * 15)) {
// br.Msg = "活动开始前15分钟内无法提交问题"
// return
// }
//} else {
// if time.Now().After(resultTime.Add(-time.Minute * 60)) {
// br.Msg = "活动开始前1小时内无法提交问题"
// return
// }
//}
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
}
item := new(models.CygxActivityHelpAsk)
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+")", "提问:"+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+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
}
go services.SendWxCategoryMsgWithAsk(user, activityInfo, content, int(msgId))
}
}
br.Ret = 200
br.Success = true
br.Msg = "提交成功"
}
// @Title 更多主题列表(4.3版本)
// @Description 获取活动更多主题列表接口(4.3版本)
// @Success 200 {object} models.GetCygxActivityLabelListRep
// @router /labelMoreList [get]
func (this *ActivityCoAntroller) LabelMoreList() {
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
}
userType, permissionStr, err := services.GetUserType(user.CompanyId)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
var startSize, pageSize int
pageSize = 24
var condition string
var sortTime string
//var conditionStatus string
var pars []interface{}
//活动可见限制
var sqlExport string
resp := new(models.GetCygxActivityLabelListRep)
slicePer := strings.Split(permissionStr, ",")
var permissionSqlStr string
for _, v := range slicePer {
if userType == 1 {
//if v != "研选" {
if !strings.Contains(v, "研选") {
permissionSqlStr += "'" + v + "',"
}
} else {
permissionSqlStr += "'" + v + "',"
}
}
permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionSqlStr + `)`
sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
if userType == 2 {
sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
}
if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
}
sqlExport += `) `
//进行中的活动
condition = ` AND art.publish_status = 1 AND art.label != '' AND art.active_state = 2 `
var conditionOr string
if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
}
if (userType == 5) && strings.Contains(permissionStr, "专家") {
conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
}
if userType == 1 {
conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
} else {
conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
}
//判断客户规模是否属于可见范围的活动
companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
if err != nil && err.Error() != utils.ErrNoRow() {
br.Msg = "获取信息失败"
br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
return
}
if companyProduct != nil {
if companyProduct.Scale != "" {
conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
}
}
condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
//进行中的活动
sortTime = ` mintimesort ASC `
list, errList := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
if errList != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + errList.Error()
return
}
//已结束的活动
conditionOr = ""
condition = ` AND art.publish_status = 1 AND art.label != '' AND art.active_state = 3 `
if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
}
if (userType == 5) && strings.Contains(permissionStr, "专家") {
conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
}
if userType == 1 {
conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
} else {
conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
}
condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
startSize = 0
pageSize = 24 - len(list)
//已结束的活动
sortTime = ` timesort DESC `
listEnd, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
for _, v := range listEnd {
list = append(list, v)
}
//标签字段关联的产业与标签处理
for k, v := range list {
list[k].KeyWord = services.LabelStr(v.KeyWord)
}
//添加更多主题访问记录
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 = "LabelMore"
go models.AddCygxPageHistoryRecord(item)
resp.List = list
br.Ret = 200
br.Success = true
br.Msg = "获取成功"
br.Data = resp
}
// @Title 活动列表(4.3版本)
// @Description 获取活动列表接口(4.3版本)
// @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 TypeName query string false "电话会类型 ,1专家电话会 2分析师电话会"
// @Param IsExternalLabel query int false "是否仅展示外部资源 1:是、0:否 默认0"
// @Param IsResearchPoints query string false "是否仅展示研选扣点 1:展示研选扣点、2:展示外部资源 ,1,2两者都展示" //兼容前端
// @Param IsResearch query bool true "是否为研选"
// @Success 200 {object} models.GetCygxActivityListRep
// @router /listNew [get]
func (this *ActivityCoAntroller) 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.GetString("IsResearchPoints") //
isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示)
if label == "undefined" {
label = ""
}
if chartPermissionIds == "undefined" {
chartPermissionIds = ""
}
// 查研观向7.4-始终查询宏观的活动
if chartPermissionIds != "" {
chartPermissionIds += ",1"
}
if whichDay == "undefined" {
whichDay = ""
}
if activeState == "undefined" {
activeState = ""
}
if activityTypeId == "undefined" {
activityTypeId = ""
}
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)
//userType, permissionStr, err := services.GetUserType(user.CompanyId)
var condition string
var conditioninit string //初始化搜索条件
var pars []interface{}
var activityList []*models.ActivityDetail
mapDingActivityId := make(map[int]int)
//主题
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 isResearchPoints == "1,2" || isResearchPoints == "2,1" {
conditioninit += ` AND ( art.is_external_label = 1 OR art.is_research_points = 1 )`
} else {
// 是否为研选扣点
if isResearchPoints == "1" {
conditioninit += ` AND art.is_research_points = 1 `
}
//是否为外部资源
if isResearchPoints == "2" {
conditioninit += ` AND art.is_external_label = 1 `
}
}
//活动可见限制
//conditionActivityAll, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord, playBack, 3)
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
//var conditionCount string
//conditionCount = condition + conditionActivityAll
total, err := models.GetActivityCount(condition, playBack, pars, filter)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
//搜索关键词初始化
//conditionActivityKey, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord, playBack, 1)
//if err != nil && err.Error() != utils.ErrNoRow() {
// 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" || activeState == "1,2" || activeState == "" {
conditionOrder = ` ORDER BY art.top_time DESC , art.activity_time ASC `
}
//conditionActivityKey += condition + conditionOrder
condition += conditionOrder
//fmt.Println(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 = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
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.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)
}
page := paging.GetPaging(currentIndex, pageSize, total)
resp := new(models.GetCygxActivityListRep)
resp.Label = label
if activityTypeId != "" {
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
}
//处理不同的报名方式按钮回显
mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
return
}
for _, v := range list {
if mapDingActivityId[v.ActivityId] == 0 {
activityList = append(activityList, v)
}
v.SignupType = mapActivitySignup[v.ActivityId]
}
for k, v := range activityList {
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]
}
//resp.List = append(resp.List, services.ActivityButtonShow(v))
}
resp.List = services.ActivityArrButtonShow(activityList)
// 查研观向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.IsJump = true
// 研选产业不跳资源包
if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
resp.IsJump = false
}
}
}
// 新标签
if activityId > 0 {
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 activityTypeId == "3" || activityTypeId == "5" {
resp.IsShowResearchPoints = true
}
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 /checkAsk [post]
func (this *ActivityCoAntroller) 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.GetUserHasPermissionActivity(user, activityInfo)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
return
}
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
}
// @Title 活动类型下的主题列表(5.3版本)
// @Description 获取活动类型下的主题列表接口(5.3版本)
// @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 WhichWeek query string false "哪一周 本周:1 上周:2"
// @Param WhichMonth query string false "哪一月 本月:1 上月:2"
// @Param WhichMonth query string false "哪一月 本月:1 上月:2"
// @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
// @Param IsResearch query bool true "是否为研选"
// @Success 200 {object} models.ActivityTypeListHomeResp
// @router /labelTypeListV5 [get]
func (this *ActivityCoAntroller) LabelTypeListV5() {
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")
isPower, _ := this.GetInt("IsPower")
chartPermissionIds := this.GetString("ChartPermissionIds")
whichDay := this.GetString("WhichDay")
activeState := this.GetString("ActiveState")
isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示)
//入参为 undefined 时的处理
if chartPermissionIds == "undefined" {
chartPermissionIds = ""
}
if whichDay == "undefined" {
whichDay = ""
}
if activeState == "undefined" || activeState == "" {
activeState = "1"
}
// 查研观向7.4-始终查询宏观的活动
if chartPermissionIds != "" {
chartPermissionIds += ",1"
}
userType, _, err := services.GetUserType(user.CompanyId)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
var startSize int
pageSize = 1000
var sortTime string
var conditioninit string
var pars []interface{}
//活动可见限制
permissionZhengShiStr, err := models.GetCompanyPermissionByUserZhengShi(user.CompanyId)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
slicePer := strings.Split(permissionZhengShiStr, ",")
//var permissionSqlStr string
var permissionNameStr string
for _, v := range slicePer {
if userType == 1 {
//if v != "研选" {
if !strings.Contains(v, "研选") {
permissionNameStr += "'" + v + "',"
}
} else {
permissionNameStr += "'" + v + "',"
}
}
permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
permissionNameStr = strings.TrimRight(permissionNameStr, ",")
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)`
}
var condition string
//conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0, 1)
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.is_limit_people = 1 ` + conditionActivity
condition += conditionActivity
sortTime = ` mintimesort ASC `
listActivity, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
mapCity, err := services.GetActivityCityResp()
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取数据失败,Err:" + err.Error()
return
}
mapActivity := make(map[int][]*models.CygxActivityLabelList)
mapkeyWord := make(map[string]string)
activityPointsByUserAllMap := services.GetActivityPointsByUserAllMap() // 获取对用户进行研选扣点的活动
for _, v := range listActivity {
if v.KeyWord == "" {
continue
}
// 如果是C类电话会就不展示内容,且合并到分析师电话会
if v.ActivityTypeId == 7 {
v.ActivityTypeId = 2
}
// 如果是买方线下交流的活动,合并到专家线下交流
if v.ActivityTypeId == 8 {
v.ActivityTypeId = 5
}
item := new(models.CygxActivityLabelList)
item.IsResearchPoints = activityPointsByUserAllMap[v.ActivityId]
item.City = mapCity[fmt.Sprint(v.KeyWord, "{|}", v.ActivityTypeId)]
item.KeyWord = services.LabelStrV5(v.KeyWord, v.IsShowSubjectName, v.TemporaryLabel)
if _, ok := mapkeyWord[fmt.Sprint(v.ActivityTypeId, "-", item.KeyWord)]; ok {
continue
}
item.Resource = 1
item.ActivityId = v.ActivityId
if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
item.IsResearch = true
}
//易董同步过来的活动只展示外部资源标签
if v.YidongActivityId != "" {
item.IsResearchPoints = false
item.IsResearch = false
}
item.IsExternalLabel = v.IsExternalLabel
mapActivity[v.ActivityTypeId] = append(mapActivity[v.ActivityTypeId], item)
mapkeyWord[fmt.Sprint(v.ActivityTypeId, "-", item.KeyWord)] = item.KeyWord
}
//
var conditionType string
var parsType []interface{}
if isResearch {
conditionType = " AND source_type IN (0,2) "
} else {
conditionType = " AND source_type IN (0,1) "
}
list, err := models.GetActivityTypeHomeList(conditionType, parsType)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取数据失败,Err:" + err.Error()
return
}
resp := new(models.ActivityTypeListHomeResp)
for k, v := range list {
if len(mapActivity[v.ActivityTypeId]) > 0 {
for _, v2 := range mapActivity[v.ActivityTypeId] {
v2.ImgUrlBg = v.ImgUrlBgs
}
}
list[k].List = mapActivity[v.ActivityTypeId]
list[k].Resource = 1
}
//获取对应活动的数量并排序
activityIds := make([]int, 0) // 用于查询活动【新】标签Map
intArr := make([]int, 0)
var items []*models.ActivityTypeHome
for _, v := range list {
item := new(models.ActivityTypeHome)
if len(v.List) > 0 {
for i := range v.List {
activityIds = append(activityIds, v.List[i].ActivityId)
}
item.List = v.List
item.ActivityTypeName = v.ActivityTypeName
item.ActivityTypeId = v.ActivityTypeId
item.ImgUrlBg = v.ImgUrlBg
item.ImgUrl = v.ImgUrl
item.Resource = v.Resource
items = append(items, item)
intArr = append(intArr, len(v.List))
}
}
sort.Sort(sort.Reverse(sort.IntSlice(intArr)))
// 活动【新】标签Map
newLabelMap, _, e := services.GetActivityNewLabelMap(activityIds)
if e != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取活动【新】标签Map失败, Err: " + e.Error()
return
}
for k, _ := range list {
for k2 := range list[k].List {
list[k].List[k2].IsNew = newLabelMap[list[k].List[k2].ActivityId]
}
}
var itemsNew []*models.ActivityTypeHome
activityMap := make(map[int]int)
for _, v := range intArr {
for _, v2 := range items {
item := new(models.ActivityTypeHome)
if len(v2.List) > 0 && v == len(v2.List) && activityMap[v2.ActivityTypeId] == 0 {
item.List = v2.List
item.ActivityTypeName = v2.ActivityTypeName
item.ActivityTypeId = v2.ActivityTypeId
item.ImgUrlBg = v2.ImgUrlBg
item.ImgUrl = v2.ImgUrl
item.Resource = v2.Resource
itemsNew = append(itemsNew, item)
activityMap[v2.ActivityTypeId] = len(v2.List)
}
}
}
var lenList int
//按照像素进行排序
rowHeight := 83 //每一行的行高
basicsHeight := 178 // 基础高度
position := 1 // 初始化位置 ,1,左边, 2 右边
var leftPx, rightPx int
for k, v := range itemsNew {
if leftPx <= rightPx {
position = 1
} else {
position = 2
}
itemsNew[k].Position = position
lenList = len(v.List)
if lenList > 8 {
lenList = 8
}
if position == 1 {
leftPx += basicsHeight + rowHeight*lenList
if lenList > 8 {
lenList = leftPx - 41
}
} else {
rightPx += basicsHeight + rowHeight*lenList
if lenList > 8 {
lenList = leftPx - 41
}
}
}
//研选互动不展示专项产业调研
if !isResearch {
//专项产业调研未开始状态不查询
if activeState == "1" {
activeState = ""
}
conditionActivitySpecial := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState)
//查询专项产业调研展示权限 仅对大套餐客户跟永续客户展示
//if whichDay == "" {
//speciaItem, err := services.GetActivityLabelSpecialList(user, isPower, chartPermissionIds, permissionNameStr)
speciaItem, err := services.GetActivityLabelSpecialList(user, conditionActivitySpecial, activeState)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
if speciaItem != nil {
if leftPx > rightPx {
speciaItem.Position = 2
} else {
speciaItem.Position = 1
}
if len(speciaItem.List) > 0 {
itemsNew = append(itemsNew, speciaItem)
}
}
//}
}
//记录用户搜索的筛选条件
item := new(models.CygxActivitySearchHistory)
item.UserId = user.UserId
item.Mobile = user.Mobile
item.CompanyId = user.CompanyId
item.CompanyName = user.CompanyName
item.CreateTime = time.Now()
item.ChartPermissionIds = chartPermissionIds
item.IsPower = isPower
item.WhichDay = whichDay
go models.AddCygxActivitySearchHistory(item)
resp.List = itemsNew
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.GetCygxActivitySpecialDetailListResp
// @router /special/del_list [get]
func (this *ActivityCoAntroller) SpecialList() {
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")
userType, permissionStr, err := services.GetUserType(user.CompanyId)
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 sqlExport string
slicePer := strings.Split(permissionStr, ",")
var permissionSqlStr string
for _, v := range slicePer {
if userType == 1 {
//if v != "研选" {
if !strings.Contains(v, "研选") {
permissionSqlStr += "'" + v + "',"
}
} else {
permissionSqlStr += "'" + v + "',"
}
}
//判断客户规模是否属于可见范围的活动
companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
if err != nil && err.Error() != utils.ErrNoRow() {
br.Msg = "获取信息失败"
br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
return
}
permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionSqlStr + `)`
sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
if userType == 2 {
sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
}
if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
}
sqlExport += `) `
condition += ` AND art.publish_status = 1 `
condition = ` AND art.publish_status = 1 AND art.label != '' `
var conditionOr string
if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
}
if (userType == 5) && strings.Contains(permissionStr, "专家") {
conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
}
if userType == 1 {
conditionOr += ` OR ( 1=1` + condition + permissionSqlStr + `) `
}
if companyProduct != nil {
if companyProduct.Scale != "" {
conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
}
}
if companyProduct != nil {
if companyProduct.Scale != "" {
conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
}
}
condition += sqlExport + conditionOr
total, err := models.GetActivitySpecialCount(condition, pars)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
list, errList := models.GetCygxActivitySpecialDetailList(condition, pars, uid, startSize, pageSize)
if errList != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + errList.Error()
return
}
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
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 {
list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
if mapChart[v.ChartPermissionName] != "" {
list[k].ImgUrl = mapChart[v.ChartPermissionName]
}
list[k].ActivityTypeName = "专项调研"
}
page := paging.GetPaging(currentIndex, pageSize, total)
resp := new(models.GetCygxActivitySpecialDetailListResp)
count, err := models.GetCygxUserFollowSpecial(user.UserId)
if err != nil {
br.Msg = "获取数据失败!"
br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
return
}
if count == 1 && user.UserId > 0 {
resp.IsFollow = true
}
if user.Mobile != "" {
resp.IsBindingMobile = true
}
resp.List = list
resp.Paging = page
br.Ret = 200
br.Success = true
br.Msg = "获取成功"
br.Data = resp
}
// @Title 专项产业调研详情
// @Description 获取专项产业调研详情接口
// @Param ActivityId query int true "活动ID"
// @Success Ret=200 {object} models.CygxActivitySpecialResp
// @router /special/detail [get]
func (this *ActivityCoAntroller) SpecialDetail() {
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.CygxActivitySpecialResp)
hasPermission := 0
activityInfo, err := models.GetCygxActivitySpecialDetailById(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
}
applyCount, err := models.GetApplyRecordCount(uid)
if err != nil && err.Error() != utils.ErrNoRow() {
br.Msg = "获取信息失败"
br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
return
}
//获取FICC销售信息 如果是FICC的客户类型,则默认他申请过
sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
if err != nil && err.Error() != utils.ErrNoRow() {
br.Msg = "获取信息失败"
br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
return
}
if user.CompanyId <= 1 {
//companyDetailStatus = ""
} else {
companyPermission, err := models.GetCompanyPermission(user.CompanyId)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
return
}
if companyPermission == "" {
if applyCount > 0 {
hasPermission = 4
} else {
if sellerItem != nil {
hasPermission = 5
} else {
//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
if err != nil && err.Error() != utils.ErrNoRow() {
br.Msg = "获取信息失败"
br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
return
}
if sellerItemQy != nil {
hasPermission = 2
resp.SellerMobile = sellerItemQy.Mobile
resp.SellerName = sellerItemQy.RealName
} else {
hasPermission = 3
}
}
}
resp.HasPermission = hasPermission
resp.OperationMode = "Apply"
resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
br.Ret = 200
br.Success = true
br.Msg = "获取成功"
br.Data = resp
return
}
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) + "CompanyId:" + strconv.Itoa(user.CompanyId)
return
}
}
userType, permissionStr, err := services.GetUserType(user.CompanyId)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
return
}
itemAct := new(models.ActivityDetail)
itemAct.CustomerTypeIds = activityInfo.CustomerTypeIds
noPower, err := services.GetShareNoPowe(itemAct, permissionStr, userType, user)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
return
}
//获取用户的产业规模,判断是否允许可见
companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
if err != nil && err.Error() != utils.ErrNoRow() {
br.Msg = "获取信息失败"
br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
return
}
if companyProduct != nil {
if companyProduct.Scale != "" {
if strings.Count(activityInfo.Scale, companyProduct.Scale) > 0 {
noPower = false
}
}
}
if noPower {
br.Msg = "您暂无查看该活动权限"
br.ErrMsg = "被分享客户不可见,获取信息失败"
br.IsSendEmail = false
return
}
if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
br.Msg = "您暂无查看该活动权限"
br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
return
}
//判断是否已经申请过
if user.CompanyId > 1 {
permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "获取客户权限信息失败,Err:" + err.Error()
return
}
companyItem, err := models.GetCompanyDetailById(user.CompanyId)
//冻结客户
if err != nil {
if err.Error() == utils.ErrNoRow() {
if applyCount > 0 {
hasPermission = 4
} else {
if sellerItem != nil {
hasPermission = 5
} else {
//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
if err != nil && err.Error() != utils.ErrNoRow() {
br.Msg = "获取信息失败"
br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
return
}
if sellerItemQy != nil {
hasPermission = 2
resp.SellerMobile = sellerItemQy.Mobile
resp.SellerName = sellerItemQy.RealName
} else {
hasPermission = 3
}
}
}
resp.HasPermission = hasPermission
resp.OperationMode = "Apply"
resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
br.Ret = 200
br.Success = true
br.Msg = "获取成功"
br.Data = resp
return
} else {
br.Msg = "获取信息失败"
br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
return
}
}
var havePower bool
if strings.Contains(permissionStr, activityInfo.ActivityTypeName) {
havePower = true
}
if havePower {
hasPermission = 1
resp.HaqveJurisdiction = true
} else {
if permissionStr == "专家" {
resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
resp.MsgType = "Type"
} else {
resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
resp.MsgType = "Industry"
}
if companyItem.ProductId == 2 {
resp.SellerMobile = companyItem.Mobile
resp.SellerName = companyItem.SellerName
resp.OperationMode = "Call"
hasPermission = 2
} else {
hasPermission = 5
}
}
} else { //潜在客户
if applyCount > 0 {
hasPermission = 4
} else {
if sellerItem != nil {
hasPermission = 5
} else {
hasPermission = 3
}
}
resp.OperationMode = "Apply"
resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
}
if hasPermission == 1 {
count, err := models.GetCygxUserFollowSpecial(user.UserId)
if err != nil {
br.Msg = "获取数据失败!"
br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
return
}
if count == 1 {
resp.IsFollow = true
}
activityInfo.ActivityTypeName = "专项调研"
resp.Detail = activityInfo
}
resp.HasPermission = hasPermission
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.SignupSpecialStatus
// @router /special/signup/add [post]
func (this *ActivityCoAntroller) SpecialSignupAdd() {
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
resp := new(models.SignupSpecialStatus)
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.GetCygxActivitySpecialDetail(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.GetSpecialDetailUserPower(user, activityInfo)
//if err != nil {
// br.Msg = "获取信息失败"
// br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
// return
//}
var havePower bool
havePower = true
//判断有没有对应的权限,如果没有则给出对应的状态码
if havePower {
resp.HasPermission = 1
total, err := models.GetUserCygxActivitySpecialSignup(user.UserId, activityId)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
return
}
resp.SignupStatus = 1
//判断是删除还是添加
if total == 0 {
//获取销售信息
sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
if err != nil {
br.Msg = "操作失败"
br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
return
}
item := new(models.CygxActivitySpecialSignup)
item.UserId = uid
item.RealName = user.RealName
item.ActivityId = activityId
item.CreateTime = time.Now()
item.Mobile = user.Mobile
item.Email = user.Email
item.CompanyId = user.CompanyId
item.CompanyName = user.CompanyName
if sellerItem != nil {
item.SellerName = sellerItem.RealName
}
err = models.AddCygxActivitySpecialSignup(item)
if err != nil {
br.Msg = "操作失败"
br.ErrMsg = "操作失败,Err:" + err.Error()
return
}
resp.Status = 1
resp.PopupMsg = "感谢反馈"
resp.PopupMsg2 = "此调研具体行程尚未确认,待预报名人数满10人后弘则会确定行程并推送给您活动日期,只有在确认行程中再次报名才完成占位。"
//给所属销售发送消息
//if sellerItem.Mobile != "" {
// openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
// if openIpItem != nil && openIpItem.OpenId != "" {
// if sellerItem != nil {
// go services.SendSpecialTemplateMsg(user.RealName+"【"+user.CompanyName+"】", time.Now().Format(utils.FormatDateTime), user.Mobile, activityInfo.ResearchTheme, "sale", openIpItem)
// }
// }
//}
// 给芳姐发消息
//cnf, _ := models.GetConfigByCode("tpl_msg")
actList, _ := models.GetActivityListSpecialByActivityId(activityId)
//if cnf != nil {
// openIpItem, _ := models.GetUserRecordByMobile(4, cnf.ConfigValue)
// if openIpItem != nil && openIpItem.OpenId != "" {
// if len(actList) == 5 {
// var companyName string
// for _, v := range actList {
// companyName += "【" + v.CompanyName + "】"
// }
// go services.SendSpecialTemplateMsg(companyName, "", "", activityInfo.ResearchTheme, "", openIpItem)
// }
// }
//}
//感兴趣人数到达10人时,模板消息发送给活动负责人
if len(actList) == 10 {
go services.SendWxMsgActivitySpecial10(activityInfo)
}
//用户专项调研操作行为,模板消息推送
//go services.SpecialActivityUserRemind(user, activityInfo, 1)
//用户相关行为,给对应销售发模板消息
go services.ActivitySpecialUserRmind(user, activityId, 1)
} else {
err = models.DeleteCygxActivitySpecialSignup(user.UserId, activityId)
if err != nil {
br.Msg = "操作失败"
br.ErrMsg = "操作失败,Err:" + err.Error()
return
}
resp.Status = 2
}
} 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
}
br.Ret = 200
br.Success = true
br.Msg = "操作成功"
br.Data = resp
}
// @Title 新调研通知取消跟添加
// @Description 新调研通知取消跟添加接口
// @Param request body models.ArticleCollectResp true "type json string"
// @Success 200
// @router /special/follow [post]
func (this *ActivityCoAntroller) SpecialMsg() {
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
}
resp := new(models.ArticleCollectResp)
count, err := models.GetCygxUserFollowSpecial(user.UserId)
if err != nil {
br.Msg = "获取数据失败!"
br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
return
}
if count == 0 {
item := new(models.CygxUserFollowSpecial)
item.UserId = user.UserId
item.RealName = user.RealName
item.CreateTime = time.Now()
item.Mobile = user.Mobile
item.Email = user.Email
item.CompanyId = user.CompanyId
item.CompanyName = user.CompanyName
item.CreateTime = time.Now()
err := models.AddUserFollowSpecial(item)
if err != nil {
br.Msg = "操作失败!"
br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
return
}
resp.Status = 1
} else {
err := models.DeleteCygxUserFollowSpecial(user.UserId)
if err != nil {
br.Msg = "操作失败!"
br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
return
}
resp.Status = 2
}
br.Ret = 200
br.Data = resp
br.Success = true
br.Msg = "操作成功!"
}
// @Title 活动类型下的主题列表(6.0Pc版本)
// @Description 获取活动类型下的主题列表接口(6.0Pc版本)
// @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.ActivityTypeListHomeRespPc
// @router /labelTypeListV6Pc_del [get]
func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
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")
isPower, _ := this.GetInt("IsPower")
playBack, _ := this.GetInt("PlayBack")
//currentIndex, _ := this.GetInt("CurrentIndex")
chartPermissionIds := this.GetString("ChartPermissionIds")
//activityTypeIds := this.GetString("ActivityTypeIds")
whichDay := this.GetString("WhichDay")
activeState := this.GetString("ActiveState")
//入参为 undefined 时的处理
if chartPermissionIds == "undefined" {
chartPermissionIds = ""
}
// 查研观向7.4-始终查询宏观的活动
if chartPermissionIds != "" {
chartPermissionIds += ",1"
}
if whichDay == "undefined" {
whichDay = ""
}
if activeState == "undefined" || activeState == "" || activeState == "1" {
activeState = "1,2"
}
//adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
//if err != nil {
// br.Msg = "获取失败"
// br.ErrMsg = "获取本组下的销售失败,Err:" + err.Error()
// return
//}
userType, permissionStr, err := services.GetUserType(user.CompanyId)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
//isMaker := user.IsMaker
var startSize int
pageSize = 8
var sortTime string
var pars []interface{}
//活动可见限制
slicePer := strings.Split(permissionStr, ",")
var permissionNameStr string
for _, v := range slicePer {
if userType == 1 {
//if v != "研选" {
if !strings.Contains(v, "研选") {
permissionNameStr += "'" + v + "',"
}
} else {
permissionNameStr += "'" + v + "',"
}
}
permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
permissionNameStr = strings.TrimRight(permissionNameStr, ",")
// 查研观向7.4-始终查询宏观的权限(无论是否有权限)
if permissionNameStr == `` {
permissionNameStr = `'宏观'`
} else {
permissionNameStr += `, '宏观'`
}
list, err := models.GetActivityTypeHomeListPc()
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取数据失败,Err:" + err.Error()
return
}
//判断客户规模是否属于可见范围的活动
//companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
//if err != nil && err.Error() != utils.ErrNoRow() {
// br.Msg = "获取信息失败"
// br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
// return
//}
var sqlExport string
//处理专家权限的查询
sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
if userType == 2 {
sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
}
if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
}
sqlExport += `) `
resp := new(models.ActivityTypeListHomeRespPc)
for k, v := range list {
// 如果是C类电话会就不展示内容,且合并到分析师电话会
if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
continue
}
var condition string
conditionActivity, err := services.GetActivityonditionList(user, strconv.Itoa(v.ActivityTypeId), chartPermissionIds, whichDay, activeState, "", isPower, 1, "", playBack, 1)
if err != nil && err.Error() != utils.ErrNoRow() {
br.Msg = "获取失败"
br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
return
}
//condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
condition += `AND art.is_limit_people = 1 AND art.yidong_activity_id = '' ` + conditionActivity
sortTime = ` mintimesort ASC `
labelList, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
//标签字段关联的产业与标签处理
for k2, v2 := range labelList {
labelList[k2].KeyWord = services.LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
labelList[k2].Resource = 1
}
list[k].List = labelList
list[k].Resource = 1
}
//if whichDay == "" {
// //查询专项产业调研展示权限
// //var scale string
// //if companyProduct != nil {
// // scale = companyProduct.Scale
// //}
// speciaItem, err := services.GetActivityLabelSpecialList(user, isPower, chartPermissionIds, permissionNameStr)
// if err != nil {
// br.Msg = "获取失败"
// br.ErrMsg = "获取失败,Err:" + err.Error()
// return
// }
// if len(speciaItem.List) > 0 {
// itemList := new(models.ActivityTypeHomePc)
// itemList.ActivityTypeName = "专项产业调研"
// itemList.Resource = 2
// itemList.List = speciaItem.List
// itemList.ActivityTypeId = 7
// itemList.OnlineIco = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/0H4md6VgZMuIttggMUnJxgrlayxC.png"
// itemList.ImgUrlBgPc = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/rFwAM1c4fIMJM0EGoUkUYl25XH9L.png"
// list = append(list, itemList)
// }
//}
// 查研观向7.4-活动【新】标签
activityIds := make([]int, 0)
for _, v := range list {
if len(v.List) > 0 {
for i := range v.List {
activityIds = append(activityIds, v.List[i].ActivityId)
}
}
}
newLabelMap, _, e := services.GetActivityNewLabelMap(activityIds)
if e != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取活动【新】标签Map失败, Err: " + e.Error()
return
}
for k := range list {
for k2 := range list[k].List {
list[k].List[k2].IsNew = newLabelMap[list[k].List[k2].ActivityId]
}
}
//记录用户搜索的筛选条件
{
item := new(models.CygxActivitySearchHistory)
item.UserId = user.UserId
item.Mobile = user.Mobile
item.CompanyId = user.CompanyId
item.CompanyName = user.CompanyName
item.CreateTime = time.Now()
item.ChartPermissionIds = chartPermissionIds
item.IsPower = isPower
item.WhichDay = whichDay
go models.AddCygxActivitySearchHistory(item)
}
resp.List = list
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 *ActivityCoAntroller) 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
signupStatus := "Success"
var req models.ActivityIdRep
err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
if err != nil {
br.Msg = "参数解析异常!"
br.ErrMsg = "参数解析失败,Err:" + err.Error()
return
}
activityId := req.ActivityId
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
}
//判断是否已经预约过
totalAppointment, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
if totalAppointment > 0 {
br.Msg = "您已预约!"
return
}
//SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
item := new(models.CygxActivityAppointment)
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
}
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.HaqveJurisdiction = true
//1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
go services.ActivityUserRemind(user, activityInfo, 3)
resp.HasPermission = hasPermission
resp.SignupStatus = signupStatus
} else {
hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
return
}
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
//var total int
//total, err = models.GetUserCygxActivityAppointmentCountByUid(user.UserId)
//if err != nil {
// br.Msg = "获取信息失败"
// br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
// return
//}
//if total <= 1 {
// resp.GoFollow = true
//}
detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
if err != nil {
br.Msg = "获取信息失败"
br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error()
return
}
resp.ActivityTypeName = activityInfo.ActivityName
resp.ActivityTime = activityInfo.ActivityTime
resp.ActivityType = detailActivityType.ActivityType
br.Ret = 200
br.Success = true
if hasPermission == 1 {
br.Msg = "请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
resp.PopupMsg = "会议纪要预约成功
请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
}
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 *ActivityCoAntroller) 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
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 /voiceHistory/add [post]
func (this *ActivityCoAntroller) 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
}
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
}
go services.AddActivityVoiceHistory(user, activityId, playSeconds)
br.Ret = 200
br.Success = true
br.Msg = "操作成功"
return
}
// @Title 记录用户浏览视频回放接口
// @Description 记录用户浏览音频回放接口
// @Param request body models.ActivityIdRep true "type json string"
// @Success Ret=200 {object} models.AppointmentResp
// @router /videoHistory/add [post]
func (this *ActivityCoAntroller) ActivityVideoHistoryAdd() {
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
activityInfo, errInfo := models.GetCygxActivityVideoByActivityId(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.CygxActivityVideoHistory{
ActivityId: activityId,
VideoId: activityInfo.VideoId,
UserId: uid,
CreateTime: time.Now(),
Mobile: user.Mobile,
Email: user.Email,
CompanyId: user.CompanyId,
CompanyName: user.CompanyName,
RealName: user.RealName,
SellerName: sellerName,
ModifyTime: time.Now(),
}
err = models.AddCygxActivityVideoHistory(&item)
if err != nil {
br.Msg = "操作失败"
br.ErrMsg = "操作失败,Err:" + err.Error()
return
}
err = models.UpdateActivityVideoCounts(activityId)
if err != nil {
br.Msg = "更新失败"
br.ErrMsg = "更新失败,Err:" + err.Error()
return
}
br.Ret = 200
br.Success = true
br.Msg = "操作成功"
return
}
// @Title 活动、专项调研搜索
// @Description 活动、专项调研搜索接口
// @Param PageSize query int true "每页数据条数"
// @Param CurrentIndex query int true "当前页页码,从1开始"
// @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
// @Param IsResearch query bool true "是否为研选"
// @Success 200 {object} models.GetCygxActivityListRep
// @router /listSearch [get]
func (this *ActivityCoAntroller) 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, "", "", "", "", "", 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 = '' `
}
condition += ` AND art.publish_status = 1 ` + conditionActivity
list, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, keyWord)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
page := paging.GetPaging(currentIndex, pageSize, total)
resp := new(models.GetCygxActivityListRep)
//添加活动搜索记录
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 ChartPermissionIds query string false "行业id 多个用 , 隔开"
// @Param WhichDay query string false "哪一天 3本周、4上周,5本月,6上月 可多选"
// @Param IsPower query string false "是否选择有权限行业 ,1是 0 否 默认0"
// @Param TypeName query string false "电话会类型 ,1专家电话会 2分析师电话会"
// @Success 200 {object} models.GetCygxActivityLabelListRep
// @router /overActivityList [get]
func (this *ActivityCoAntroller) OverActivityList() {
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
}
isPower, _ := this.GetInt("IsPower")
chartPermissionIds := this.GetString("ChartPermissionIds")
whichDay := this.GetString("WhichDay")
typeName := this.GetString("TypeName")
//入参为 undefined 时的处理
if chartPermissionIds == "undefined" {
chartPermissionIds = ""
}
if whichDay == "undefined" {
whichDay = ""
}
resp := new(models.GetCygxActivityLabelListRep)
if user.CompanyId <= 1 && user.UserId > 0 {
resp.List = make([]*models.CygxActivityLabelList, 0)
br.Ret = 200
br.Success = true
br.Msg = "获取成功"
br.Data = resp
return
}
var condition string
var conditionSpecialinit string
var conditionSpecial string
var sortTime string
var pars []interface{}
//已结束的活动 不展示研选 11.0
condition = ` AND art.publish_status = 1 AND art.label != '' AND art.active_state = 3 AND art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
if whichDay != "" {
var startDate string
var endDate string
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 == "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 = utils.GetNowWeekMonday().Format(utils.FormatDate)
endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
}
condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
conditionSpecialinit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
conditionSpecialinit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
}
if len(chartPermissionIds) > 0 {
condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
}
// 如果是C类电话会就不展示内容,且合并到分析师电话会
if typeName == "1" || typeName == "2" {
if typeName == strconv.Itoa(utils.ANALYST_TELL_ACTIVITY_TYPE_ID) {
condition += ` AND art.publish_status = 1 AND art.label != '' AND art.activity_type_id IN (` + typeName + "," + strconv.Itoa(utils.C_CLASS_ACTIVITY_TYPE_ID) + `)`
} else {
condition += ` AND art.publish_status = 1 AND art.label != '' AND art.activity_type_id IN (` + typeName + `)`
}
conditionSpecialinit += ` AND art.activity_id = 0 `
}
conditionActivity, err := services.ActivityConditioninitSql(user, condition, isPower)
if err != nil && err.Error() != utils.ErrNoRow() {
br.Msg = "获取失败"
br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
return
}
sortTime = ` activity_time DESC `
//如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
if user.UserId > 0 { // v12.2.1
companyDetail, err := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
if companyDetail.Status == "永续" {
conditionSpecial, err = services.HandleActivityLabelSpecialPermission(user)
} else {
conditionSpecial, _, err = services.HandleActivityLabelSpecialTripPermission(user)
}
}
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
conditionSpecial += ` AND art.days >0 AND art.publish_status =1 AND art.is_offline = 0 `
conditionSpecial += ` AND art.activity_time_end < ` + "'" + time.Now().Format(utils.FormatDateTime) + "'"
condition += conditionActivity
list, err := models.GetActivityLabelListAllNoLimit(condition, sortTime, pars, conditionSpecialinit+conditionSpecial)
if err != nil {
br.Msg = "获取失败"
br.ErrMsg = "获取失败,Err:" + err.Error()
return
}
//标签字段关联的产业与标签处理
mapKeyWord := make(map[string]string)
for _, v := range list {
keyWord := services.LabelStr(v.KeyWord)
if _, ok := mapKeyWord[keyWord]; ok {
continue
}
if keyWord == "" {
continue
}
v.KeyWord = keyWord
resp.List = append(resp.List, v)
mapKeyWord[keyWord] = keyWord
}
if len(list) == 0 {
resp.List = make([]*models.CygxActivityLabelList, 0)
}
//添加更多主题访问记录
//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 = "OverActivity"
//go models.AddCygxPageHistoryRecord(item)
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 *ActivityCoAntroller) 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.GetUserHasPermissionActivity(user, activityInfo)
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
}