123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 |
- package services
- import (
- "errors"
- "hongze/hongze_clpt/models"
- "hongze/hongze_clpt/utils"
- "strconv"
- "strings"
- "time"
- )
- // 获取用户已经报名的活动
- func GetActivitySignUpUserMap(activityIds []int, user *models.WxUserItem) (mapUserId map[int]int, err error) {
- userId := user.UserId
- var condition string
- var pars []interface{}
- activityIdsLen := len(activityIds)
- if activityIdsLen > 0 {
- condition += ` AND activity_id IN (` + utils.GetOrmInReplace(activityIdsLen) + `)`
- pars = append(pars, activityIds)
- }
- condition += ` AND user_id = ? AND do_fail_type = 0 `
- pars = append(pars, userId)
- list, e := models.GetActivitySignuListByUser(condition, pars)
- if e != nil {
- err = errors.New("GetCygxActivitySpecialTripList, Err: " + e.Error())
- return
- }
- mapUid := make(map[int]int)
- for _, v := range list {
- mapUid[v.ActivityId] = v.UserId
- }
- mapUserId = mapUid
- return
- }
- // 获取用户已经设置会议提醒的活动 cygx_activity_meeting_reminder
- func GetActivityReminderUserMasp(activityIds []int, user *models.WxUserItem) (mapUserId map[int]int, err error) {
- userId := user.UserId
- var condition string
- var pars []interface{}
- activityIdsLen := len(activityIds)
- if activityIdsLen > 0 {
- condition += ` AND activity_id IN (` + utils.GetOrmInReplace(activityIdsLen) + `)`
- pars = append(pars, activityIds)
- }
- condition += ` AND user_id = ? `
- pars = append(pars, userId)
- list, e := models.GetCygxReminderListByUser(condition, pars)
- if e != nil {
- err = errors.New("GetCygxReminderListByUser, Err: " + e.Error())
- return
- }
- mapUid := make(map[int]int)
- for _, v := range list {
- mapUid[v.ActivityId] = v.UserId
- }
- mapUserId = mapUid
- return
- }
- // 获取用户已经预约纪要的活动
- func GetActivityAppointmentUserMap(activityIds []int, user *models.WxUserItem) (mapUserId map[int]int, err error) {
- userId := user.UserId
- var condition string
- var pars []interface{}
- activityIdsLen := len(activityIds)
- if activityIdsLen > 0 {
- condition += ` AND activity_id IN (` + utils.GetOrmInReplace(activityIdsLen) + `)`
- pars = append(pars, activityIds)
- }
- condition += ` AND user_id = ? `
- pars = append(pars, userId)
- list, e := models.GetCygxAppointmentListByUser(condition, pars)
- if e != nil {
- err = errors.New("GetCygxActivitySpecialTripList, Err: " + e.Error())
- return
- }
- mapUid := make(map[int]int)
- for _, v := range list {
- mapUid[v.ActivityId] = v.UserId
- }
- mapUserId = mapUid
- return
- }
- // 活动列表的展示 HandleActivityListButton
- func HandleActivityListButton(list []*models.ActivityDetail, user *models.WxUserItem) (items []*models.ActivityDetail, err error) {
- var activityIds []int
- var activitySpecilalIds []int
- for k, v := range list {
- if v.SourceType == 2 {
- activitySpecilalIds = append(activitySpecilalIds, v.ActivityId)
- //把专项调研的线下改为活动的线下类型
- if v.ActivityType == 2 {
- list[k].ActivityType = 0
- }
- list[k].IsShowSignup = true
- } else {
- activityIds = append(activityIds, v.ActivityId)
- }
- }
- //处理活动
- if len(activityIds) > 0 {
- //处理用户是否报名
- mapSignUp, e := GetActivitySignUpUserMap(activityIds, user)
- if e != nil {
- err = errors.New("GetActivitySignUpUserMap, Err: " + e.Error())
- return
- }
- for k, v := range list {
- if v.SourceType != 2 {
- if _, ok := mapSignUp[v.ActivityId]; ok {
- list[k].IsSignup = 1
- }
- }
- }
- //处理用户是否预约纪要
- mapAppointment, e := GetActivityAppointmentUserMap(activityIds, user)
- if e != nil {
- err = errors.New("GetActivityAppointmentUserMap, Err: " + e.Error())
- return
- }
- for k, v := range list {
- if v.SourceType != 2 {
- if _, ok := mapAppointment[v.ActivityId]; ok {
- list[k].IsAppointment = 1
- }
- }
- }
- //处理用户是否预约会议提醒
- mapReminder, e := GetActivityReminderUserMasp(activityIds, user)
- if e != nil {
- err = errors.New("GetActivityReminderUserMasp, Err: " + e.Error())
- return
- }
- for k, v := range list {
- if v.SourceType != 2 {
- if _, ok := mapReminder[v.ActivityId]; ok {
- list[k].IsCancelMeetingReminder = 1
- }
- }
- }
- }
- //处理专项产业调研
- if len(activitySpecilalIds) > 0 {
- //处理用户是否报名
- UserMap, e := GetSpecialTripUserMap(activitySpecilalIds, user.UserId)
- if e != nil {
- err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
- return
- }
- for k, v := range list {
- if v.SourceType == 2 {
- if _, ok := UserMap[v.ActivityId]; ok {
- list[k].IsSignup = 1
- }
- }
- }
- for k, v := range list {
- if v.SourceType == 2 {
- resultTimeStart := utils.StrTimeToTime(v.ActivityTime) //时间字符串格式转时间格式
- resultTimeEnd := utils.StrTimeToTime(v.ActivityTimeEnd) //时间字符串格式转时间格式
- if resultTimeStart.After(time.Now()) {
- list[k].ActiveState = strconv.Itoa(1)
- } else if time.Now().After(resultTimeEnd) {
- list[k].ActiveState = strconv.Itoa(3)
- } else {
- list[k].ActiveState = strconv.Itoa(2)
- }
- }
- }
- }
- //var isShow bool
- isShow, e := GetShowSustainableNew()
- if e != nil {
- err = errors.New("GetShowSustainableNew, Err: " + e.Error())
- return
- }
- detail, e := models.GetConfigByCode("city_img_url")
- if e != nil {
- err = errors.New("GetConfigByCode, Err: " + e.Error())
- return
- }
- detailChart, e := models.GetConfigByCode("chart_img_url")
- if e != nil {
- err = errors.New("GetConfigByCode, Err: " + e.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.SourceType == 1 {
- 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]
- }
- }
- } else {
- if mapChart[v.ChartPermissionName] != "" {
- list[k].ImgUrl = mapChart[v.ChartPermissionName]
- }
- }
- expertTxt, _ := GetReportContentTextSub(v.Expert)
- list[k].Expert = expertTxt
- if v.IsHideAppointment == 0 {
- list[k].IsShowAppointment = IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
- }
- if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
- list[k].IsCClassMeeting = true
- }
- mapActivityId = append(mapActivityId, v.ActivityId)
- }
- //处理音频回放
- mapActivityVoice, e := GetActivityVoiceResp(mapActivityId)
- if e != nil {
- err = errors.New("GetActivityVoiceResp, Err: " + e.Error())
- return
- }
- //处理不同的报名方式按钮回显
- mapActivitySignup, e := GetActivitySignupResp(mapActivityId, user)
- if e != nil {
- err = errors.New("GetActivityVoiceResp, Err: " + e.Error())
- return
- }
- //处理视频回放
- mapActivityVideo, e := GetActivityVideoResp(mapActivityId)
- if e != nil {
- err = errors.New("GetActivityVoiceResp, Err: " + e.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]
- items = append(items, ActivityButtonShowSearch(v, user))
- }
- return
- }
- func ActivityButtonShowSearch(item *models.ActivityDetail, user *models.WxUserItem) (activityDetail *models.ActivityDetail) {
- activityDetail = item
- //IsShowAppointment bool `description:"是否展示预约纪要"`
- //IsShowOutboundCall bool `description:"是否展示预约外呼"`
- //IsShowMeetingReminder bool `description:"是否展示会议提醒"`
- //IsShowHelpSsk bool `description:"是否展示帮我带问"`
- //IsShowSignup bool `description:"是否展示我要报名"`
- //如果后台在添加活的时候,关联的报告类型不隐藏预约纪要按钮,而且满足以下展示预约纪要按钮类型就展示
- //if articleDetail.IsHideAppointment == 0 {
- // articleDetail.IsShowAppointment = IsShowAppointmentByactivityInfo(articleDetail, articleDetail.ChartPermissionName)
- //}
- activityPointsByUserAllMap := GetActivityPointsByUserAllMap() // 获取对用户进行研选扣点的活动
- activityDetail.IsResearchPoints = activityPointsByUserAllMap[activityDetail.ActivityId]
- if activityDetail.SiginupDeadline == utils.FormatDateTimeInit { //报名截止时间处理
- activityDetail.SiginupDeadline = ""
- }
- //如果报名截止时间不规范,或者是非研选扣点活动就把截止时间设置为空
- if activityDetail.CancelDeadline == utils.FormatDateTimeInit || !activityDetail.IsResearchPoints {
- activityDetail.CancelDeadline = ""
- }
- //articleDetail.SourceType = 1
- activityTimeText := activityDetail.ActivityTimeText
- activityTimeText = strings.Replace(activityTimeText, "(", "(", -1)
- activityTimeText = strings.Replace(activityTimeText, ")", ")", -1)
- activityDetail.ActivityTimeText = activityTimeText
- activityDetail.IsShowAppointment = false
- //易董的操作按钮都隐藏
- if activityDetail.YidongActivityId != "" {
- activityDetail.IsShowSignup = false
- activityDetail.IsShowDetails = true
- if activityDetail.YidongActivityId != "" {
- ydTgc, _ := GetYiDongCreateUserInfo(user)
- yidongLongLink, _ := GetYiDongOriginalLink(activityDetail)
- if yidongLongLink != "" {
- activityDetail.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
- }
- activityDetail.IsYidongActivity = true
- }
- } else {
- //专家电话会 1
- if activityDetail.ActivityTypeId == 1 && activityDetail.IsLimitPeople == 0 && (activityDetail.ActiveState == "1" || activityDetail.ActiveState == "2") {
- activityDetail.IsShowHelpSsk = true
- }
- if activityDetail.ActiveState == "1" {
- if activityDetail.IsCanAppointmentMinutes == 1 {
- activityDetail.IsShowAppointment = true
- }
- //专家电话会 1
- //专家电话会限制人数的展示我要报名,不限制的展示预约外外呼
- if activityDetail.ActivityTypeId == 1 {
- //articleDetail.IsShowOutboundCall = true
- if activityDetail.LimitPeopleNum == 0 {
- activityDetail.IsShowOutboundCall = true
- //articleDetail.IsShowHelpSsk = true
- } else {
- activityDetail.IsShowSignup = true
- }
- activityDetail.IsShowMeetingReminder = true
- activityDetail.IsShowHelpSsk = true
- }
- //分析师电话会 2
- if activityDetail.ActivityTypeId == 2 {
- if activityDetail.LimitPeopleNum == 0 {
- activityDetail.IsShowOutboundCall = true
- } else {
- activityDetail.IsShowSignup = true
- }
- activityDetail.IsShowMeetingReminder = true
- }
- //公司调研电话会 3
- if activityDetail.ActivityTypeId == 3 {
- //司调研电话会(3)、扣点的研选活动只展示我要报名
- if activityDetail.IsResearchPoints || activityDetail.LimitPeopleNum > 0 {
- activityDetail.IsShowSignup = true
- } else {
- activityDetail.IsShowMeetingReminder = true
- activityDetail.IsShowOutboundCall = true
- }
- }
- //公司线下调研 4
- if activityDetail.ActivityTypeId == 4 {
- activityDetail.IsShowSignup = true
- }
- //专家线下沙龙 5
- if activityDetail.ActivityTypeId == 5 {
- activityDetail.IsShowSignup = true
- }
- //分析师线下沙龙 6
- if activityDetail.ActivityTypeId == 6 {
- activityDetail.IsShowSignup = true
- }
- //分析师电话会(C类) 7
- if activityDetail.ActivityTypeId == 7 {
- activityDetail.IsShowSignup = true
- activityDetail.IsShowMeetingReminder = true
- }
- //买方线下交流 8 // 查研观向 11.0
- if activityDetail.ActivityTypeId == 8 {
- activityDetail.IsShowSignup = true
- }
- }
- }
- return
- }
|