1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755 |
- package controllers
- import (
- "encoding/json"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_clpt/models"
- "hongze/hongze_clpt/services"
- "hongze/hongze_clpt/utils"
- "strconv"
- "strings"
- "time"
- )
- type ActivityController struct {
- BaseAuthController
- }
- type ActivityNoLoginController struct {
- BaseAuthMobileController
- }
- // @Title 活动类型列表
- // @Description 活动类型列表接口
- // @Param IsResearch query bool true "是否为研选"
- // @Success 200 {object} models.ActivityTypeListResp
- // @router /activityTypelist [get]
- func (this *ActivityNoLoginController) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- resp := new(models.ActivityTypeListResp)
- isResearch, _ := this.GetBool("IsResearch", false)
- var condition string
- //是否仅展示研选下的活动类型
- if isResearch {
- condition = " AND source_type IN (0,2) "
- }
- list, err := models.GetActivityTypeList(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 活动类型下的主题列表
- // @Description 获取活动类型下的主题列表接口
- // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
- // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
- // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3 多个用 , 隔开"
- // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
- // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
- // @Param IsExternalLabel query int false "是否仅展示外部资源 1:是、0:否 默认0"
- // @Param IsResearchPoints query int false "是否仅展示研选扣点 1:是、0:否 默认0"
- // @Param IsResearch query bool true "是否为研选"
- // @Success 200 {object} models.ActivityTypeListHomeResp
- // @router /labelTypeList [get]
- func (this *ActivityNoLoginController) LabelTypeList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- chartPermissionIds := this.GetString("ChartPermissionIds")
- isPower, _ := this.GetInt("IsPower")
- whichDay := this.GetString("WhichDay")
- activeState := this.GetString("ActiveState")
- isExternalLabel, _ := this.GetInt("IsExternalLabel") //
- isResearchPoints, _ := this.GetInt("IsResearchPoints") //
- isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示)
- var condition string
- var conditioninit string
- var pars []interface{}
- // 查研观向7.4-始终查询宏观的活动
- if chartPermissionIds != "" {
- chartPermissionIds += ",1"
- }
- //condition += `AND art.activity_time > ? `
- //pars = append(pars, time.Now().AddDate(0, -3, 0).Format(utils.FormatDate))
- if isResearch {
- chartPermissionIds = strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
- } else {
- conditioninit += ` AND ( art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + ` OR ( art.is_show_hz = 1 AND art.chart_permission_id = ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `) )`
- conditioninit += ` AND IF ( art.active_state = 3, art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `, 1 = 1 ) ` //V 11.0 研选活动结束后就不在已结束页面展示了
- }
- //行业名称
- if len(chartPermissionIds) > 0 {
- //conditioninit += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
- conditioninit += ` AND IF ( art.yidong_activity_id != '' , art.chart_permission_id_deputy IN (` + chartPermissionIds + `) ,1=1 ) `
- conditioninit += ` AND IF ( art.yidong_activity_id = '' , art.chart_permission_id IN (` + chartPermissionIds + `) ,1=1 ) `
- }
- //哪一天
- if whichDay != "" {
- var startDate string
- var endDate string
- if whichDay == "1" {
- startDate = time.Now().Format(utils.FormatDate)
- endDate = startDate
- } else if whichDay == "2" {
- startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
- endDate = startDate
- } else if whichDay == "3" {
- startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
- endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
- } else if whichDay == "4" {
- startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
- endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
- } else if whichDay == "5" {
- startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
- endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
- } else if whichDay == "6" {
- startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
- endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
- } else if whichDay == "1,2" {
- startDate = time.Now().Format(utils.FormatDate)
- endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
- } else if whichDay == "3,4" {
- startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
- endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
- } else if whichDay == "5,6" {
- startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
- endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
- } else {
- startDate = time.Now().Format(utils.FormatDate)
- endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
- }
- conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
- conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
- }
- //活动状态搜索
- if activeState != "" {
- // 默认查看未开始跟进行中
- if activeState == "1" {
- conditioninit += ` AND art.active_state IN (1,2)`
- } else {
- conditioninit += ` AND art.active_state IN (` + activeState + `)`
- }
- } else {
- conditioninit += ` AND art.active_state IN (1,2)`
- }
- //是否为外部资源
- if isExternalLabel == 1 {
- conditioninit += ` AND art.is_external_label = 1 `
- }
- if isResearchPoints == 1 {
- conditioninit += ` AND art.is_research_points = 1 `
- }
- conditionActivity, err := services.ActivityConditioninitSql(user, conditioninit, isPower)
- //conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0, 1)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
- return
- }
- //condition += ` AND art.is_limit_people = 1 ` + conditionActivity
- condition += conditionActivity
- sortTime := ` mintimesort ASC `
- if activeState == "3" {
- sortTime = ` timesort DESC `
- }
- activityList, err := models.GetCygxActivityList(condition, pars, sortTime, 0, 1000)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- var conditionType string
- if isResearch {
- conditionType = " AND source_type IN (0,2) "
- } else {
- conditionType = " AND source_type IN (0,1) "
- }
- list, err := models.GetActivityTypeHomeList(conditionType)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- list, err = services.HandleActivityTypeHomeList(list, activityList, user)
- //专项产业调研未开始状态不查询
- if activeState == "1" {
- activeState = ""
- }
- conditionActivitySpecial := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState)
- speciaItem, err := services.GetActivityLabelSpecialList(user, conditionActivitySpecial, activeState)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if len(speciaItem.List) == 0 {
- speciaItem.List = make([]*models.CygxActivityLabelList, 0)
- }
- if speciaItem.ActivityTypeId > 0 {
- list = append(list, speciaItem)
- }
- resp := new(models.ActivityTypeListHomeResp)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 活动列表
- // @Description 获取活动列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param Label query string false "搜索主题 多个用 , 隔开"
- // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
- // @Param WhichDay query string false "哪一天 今天:1、明天:2, 本周:3 上周:4,本月:5上月:6多个用 , 隔开"
- // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
- // @Param ActivityTypeId query string false "活动类型id 多个用 , 隔开"
- // @Param Source query int false "来源 0手机 ,1Pc 默认0"
- // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
- // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
- // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
- // @Param ActivityId query int false "活动列表传过来的活动ID"
- // @Param Filter query int false "筛选条件 0:全部 1:视频 2:音频"
- // @Param IsExternalLabel query int false "是否仅展示外部资源 1:是、0:否 默认0"
- // @Param IsResearchPoints query int false "是否仅展示研选扣点 1:是、0:否 默认0"
- // @Param IsResearch query bool false "是否为研选"
- // @Success 200 {object} models.GetCygxActivityListRep
- // @router /list [get]
- func (this *ActivityNoLoginController) ActivityListNew() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- //source, _ := this.GetInt("Source")
- label := this.GetString("Label")
- chartPermissionIds := this.GetString("ChartPermissionIds")
- whichDay := this.GetString("WhichDay")
- //whichTime := this.GetString("WhichTime")
- activeState := this.GetString("ActiveState")
- activityTypeId := this.GetString("ActivityTypeId")
- keyWord := this.GetString("KeyWord")
- playBack, _ := this.GetInt("PlayBack")
- filter, _ := this.GetInt("Filter")
- isPower, _ := this.GetInt("IsPower")
- activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签
- isExternalLabel, _ := this.GetInt("IsExternalLabel") //
- isResearchPoints, _ := this.GetInt("IsResearchPoints") //
- isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示)
- if activityTypeId == "5" {
- activityTypeId = "5,8" //专家线下沙龙可以查看买方线下交流
- }
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- var conditioninit string //初始化搜索条件
- var pars []interface{}
- //主题
- if label != "" {
- conditioninit += ` AND art.label LIKE "%` + label + `%" `
- }
- //是否是研选
- if isResearch {
- chartPermissionIds = strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
- } else {
- conditioninit += ` AND ( art.chart_permission_id != '` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `' OR ( art.is_show_hz = 1 AND art.chart_permission_id = '` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `') )`
- conditioninit += ` AND IF ( art.active_state = 3, art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `, 1 = 1 ) ` //V 11.0 研选活动结束后就不在已结束页面展示了
- }
- //行业名称
- if len(chartPermissionIds) > 0 {
- //conditioninit += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
- conditioninit += ` AND IF ( art.yidong_activity_id != '' , art.chart_permission_id_deputy IN (` + chartPermissionIds + `) ,1=1 ) `
- conditioninit += ` AND IF ( art.yidong_activity_id = '' , art.chart_permission_id IN (` + chartPermissionIds + `) ,1=1 ) `
- }
- //哪一天
- if whichDay != "" {
- var startDate string
- var endDate string
- if whichDay == "1" {
- startDate = time.Now().Format(utils.FormatDate)
- endDate = startDate
- } else if whichDay == "2" {
- startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
- endDate = startDate
- } else if whichDay == "3" {
- startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
- endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
- } else if whichDay == "4" {
- startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
- endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
- } else if whichDay == "5" {
- startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
- endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
- } else if whichDay == "6" {
- startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
- endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
- } else if whichDay == "1,2" {
- startDate = time.Now().Format(utils.FormatDate)
- endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
- } else if whichDay == "3,4" {
- startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
- endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
- } else if whichDay == "5,6" {
- startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
- endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
- } else {
- startDate = time.Now().Format(utils.FormatDate)
- endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
- }
- conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
- conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
- }
- //活动状态搜索
- if activeState != "" {
- // 默认查看未开始跟进行中
- if activeState == "1" {
- conditioninit += ` AND art.active_state IN (1,2)`
- } else {
- conditioninit += ` AND art.active_state IN (` + activeState + `)`
- }
- } else {
- conditioninit += ` AND art.active_state IN (1,2)`
- }
- // 如果是分析师电话会,那么可以连同C类一起查看
- if activityTypeId != "" {
- if activityTypeId == strconv.Itoa(utils.ANALYST_TELL_ACTIVITY_TYPE_ID) {
- conditioninit += ` AND art.activity_type_id IN (` + activityTypeId + "," + strconv.Itoa(utils.C_CLASS_ACTIVITY_TYPE_ID) + `)`
- } else {
- conditioninit += ` AND art.activity_type_id IN (` + activityTypeId + `)`
- }
- }
- //关键词搜索
- if keyWord != "" {
- conditioninit += ` AND (art.label REGEXP '` + keyWord + `' OR art.activity_name REGEXP '` + keyWord + `' ) `
- }
- //回放
- if playBack == 1 {
- //获取所有带回放的活动ID
- playBackActivityIds, err := services.GetActivityPlayBackActivityIds()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- conditioninit += ` AND art.activity_id IN ( ` + playBackActivityIds + `) `
- }
- //音频视频 1:视频 2:音频
- if filter > 0 {
- videoOrVoiceActivityIds, err := services.GetActivityVideoOrVoiceActivityIds(filter)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- conditioninit += ` AND art.activity_id IN ( ` + videoOrVoiceActivityIds + `) `
- }
- if isExternalLabel == 1 && isResearchPoints == 1 {
- conditioninit += ` AND ( art.is_external_label = 1 OR art.is_research_points = 1 )`
- } else {
- //是否为外部资源
- if isExternalLabel == 1 {
- conditioninit += ` AND art.is_external_label = 1 `
- }
- // 是否为研选扣点
- if isResearchPoints == 1 {
- conditioninit += ` AND art.is_research_points = 1 `
- }
- }
- condition = ""
- //活动可见限制
- conditionActivity, err := services.ActivityConditioninitSql(user, conditioninit, isPower)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
- return
- }
- condition += ` AND art.publish_status = 1 ` + conditionActivity
- total, err := models.GetActivityCount(condition, playBack, pars, filter)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- //return
- var conditionOrder string
- if activeState == "2" || activeState == "3" {
- conditionOrder = ` ORDER BY art.activity_time DESC `
- } else if activeState == "2,3" {
- conditionOrder = ` ORDER BY art.active_state ASC, art.activity_time DESC `
- } else {
- conditionOrder = ` ORDER BY art.activity_time DESC , art.active_state ASC `
- }
- if label != "" && activeState == "1" {
- conditionOrder = ` ORDER BY art.activity_time ASC `
- }
- //未开始进行中默认按照时间正序
- if activeState == "1" || activeState == "1,2" || activeState == "" {
- conditionOrder = ` ORDER BY art.top_time DESC , art.activity_time ASC `
- }
- condition += conditionOrder
- list, errList := models.GetActivityListNew(condition, pars, uid, startSize, pageSize, playBack, filter, "")
- if errList != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errList.Error()
- return
- }
- var isShow bool
- isShow = services.GetShowSustainable()
- detail, err := models.GetConfigByCode("city_img_url")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
- return
- }
- detailChart, err := models.GetConfigByCode("chart_img_url")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
- return
- }
- addressList := strings.Split(detail.ConfigValue, "{|}")
- mapAddress := make(map[string]string)
- chartList := strings.Split(detailChart.ConfigValue, "{|}")
- mapChart := make(map[string]string)
- var cityName string
- var chartName string
- var imgUrl string
- var imgUrlChart string
- var mapActivityId []int
- for _, v := range addressList {
- vslice := strings.Split(v, "_")
- cityName = vslice[0]
- imgUrl = vslice[len(vslice)-1]
- mapAddress[cityName] = imgUrl
- }
- for _, v := range chartList {
- vslice := strings.Split(v, "_")
- chartName = vslice[0]
- imgUrlChart = vslice[len(vslice)-1]
- mapChart[chartName] = imgUrlChart
- }
- for k, v := range list {
- if strings.Contains(v.ActivityName, "【") {
- list[k].IsBrackets = 1
- }
- if v.SignupNum > v.LimitPeopleNum {
- list[k].SignupNum = v.LimitPeopleNum
- }
- if isShow && strings.Contains(v.ChartPermissionName, "研选") {
- list[k].IsShowSustainable = true
- }
- if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
- //list[k].ActivityTypeName = "买方研选电话会"
- list[k].ImgUrlText = utils.YAN_XUAN_IMG
- }
- if v.ActivityType == 0 {
- if mapAddress[v.City] != "" {
- list[k].ImgUrl = mapAddress[v.City]
- } else {
- list[k].ImgUrl = mapAddress["其它"]
- }
- } else {
- if mapChart[v.ChartPermissionName] != "" {
- list[k].ImgUrl = mapChart[v.ChartPermissionName]
- }
- }
- expertTxt, _ := services.GetReportContentTextSub(v.Expert)
- list[k].Expert = expertTxt
- if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
- list[k].IsCClassMeeting = true
- }
- mapActivityId = append(mapActivityId, v.ActivityId)
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(models.GetCygxActivityListRep)
- var activityList []*models.ActivityListResp
- resp.Label = label
- if activityTypeId != "" && label == "" {
- activityTypeIdint, err := strconv.Atoi(activityTypeId)
- if err == nil {
- detail, errDetail := models.GetActivityTypeDetailById(activityTypeIdint)
- if errDetail != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
- return
- }
- resp.ImgUrl = detail.OnlineIco
- resp.Label = detail.ActivityTypeName
- }
- }
- //处理音频回放
- mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
- return
- }
- //处理视频回放
- mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
- return
- }
- //用户权限
- authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
- return
- }
- for k, v := range list {
- au := new(models.UserPermissionAuthInfo)
- au.SellerName = authInfo.SellerName
- au.SellerMobile = authInfo.SellerMobile
- au.HasPermission = authInfo.HasPermission
- au.OperationMode = authInfo.OperationMode
- if au.HasPermission == 1 {
- // 非宏观权限进一步判断是否有权限
- if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
- au.HasPermission = 2
- }
- //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0
- if v.YidongActivityId != "" {
- if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) {
- au.HasPermission = 1
- }
- }
- }
- // 无权限的弹框提示
- if au.HasPermission != 1 {
- if au.OperationMode == services.UserPermissionOperationModeCall {
- if v.FileType == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgCallMicroVoice
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
- }
- } else {
- if v.FileType == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVoice
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
- }
- }
- }
- list[k].AuthInfo = au
- if mapActivityVoice[v.ActivityId] != nil {
- list[k].FileType = 1
- list[k].AudioLink = true
- if au.HasPermission == 1 {
- list[k].VoiceList = mapActivityVoice[v.ActivityId]
- }
- }
- if mapActivityVideo[v.ActivityId] != nil {
- list[k].FileType = 2
- list[k].AudioLink = true
- if au.HasPermission == 1 {
- list[k].VideoDetail = mapActivityVideo[v.ActivityId]
- }
- }
- //activityList = append(activityList, services.ActivityButtonShow(list[k], user, permissionArr))
- }
- activityList = services.ActivityArrButtonShow(list, user, permissionArr)
- //处理不同的报名方式按钮回显
- mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
- return
- }
- for _, v := range activityList {
- v.SignupType = mapActivitySignup[v.ActivityId]
- }
- // 查研观向7.4-判断标签是否为产业, 为产业时是否跳转资源包
- if label != "" {
- industry, e := models.GetIndustryByName(label)
- if e != nil && e.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标签产业失败, Err:" + e.Error()
- return
- }
- if industry != nil {
- sourceIndustry, e := models.GetSourceIndustryByName(label)
- if e != nil && e.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标签产业资源包失败, Err:" + e.Error()
- return
- }
- if sourceIndustry != nil {
- resp.IndustrialManagementId = sourceIndustry.IndustrialManagementId
- resp.ChartPermissionId = sourceIndustry.ChartPermissionId
- resp.IsJump = true
- // 研选产业不跳资源包
- if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
- resp.IsJump = false
- }
- }
- }
- // 新标签
- if activityId > 0 && activeState != "3" {
- activityIds := []int{activityId}
- activityNewMap, _, e := services.GetActivityNewLabelMap(activityIds)
- if e != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动新标签失败, Err: " + e.Error()
- return
- }
- resp.IndustryNewLabel = activityNewMap[activityId]
- }
- }
- //添加活动搜索记录
- //if keyWord != "" {
- // go services.AddActivitykeyWordSearch(keyWord, user)
- //}
- if len(activityList) == 0 {
- activityList = make([]*models.ActivityListResp, 0)
- }
- if activityTypeId == "3" || activityTypeId == "5" {
- resp.IsShowResearchPoints = true
- }
- //预处理返给前端的字段
- resp.List = activityList
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 活动详情
- // @Description 获取活动详情接口
- // @Param ActivityId query int true "活动ID"
- // @Success Ret=200 {object} models.CygxActivityResp
- // @router /detail [get]
- func (this *ActivityController) Detail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- activityId, _ := this.GetInt("ActivityId")
- if activityId < 1 {
- br.Msg = "请输入活动ID"
- return
- }
- resp := new(models.CygxActivityResp)
- activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
- return
- }
- if activityInfo == nil {
- br.Msg = "活动不存在"
- br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
- return
- }
- // 判断是否属于研选类型的活动
- if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- activityInfo.IsResearch = true
- }
- if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
- activityInfo.IsCClassMeeting = true
- }
- signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId)
- if err != nil {
- br.Msg = "获取信息"
- br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error()
- return
- }
- activityInfo.SignupNum = signupCount
- havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
- return
- }
- resp.IsResearchSpecial = isResearchSpecial
- detailResp := services.ActivityButtonShow(activityInfo, user, make([]string, 0))
- detailResp, err = services.ActivityDetaailShow(detailResp)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
- return
- }
- if havePower {
- resp.HasPermission = 1
- //permissionArr := make([]string, 0)
- //处理活动关联的产业
- industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
- return
- }
- if activityInfo.TemporaryLabel != "" {
- industrialList = make([]*models.IndustrialManagementRep, 0)
- item := new(models.IndustrialManagementRep)
- item.IndustryName = activityInfo.Label
- industrialList = append(industrialList, item)
- } else {
- industryIds := make([]int, 0)
- var industrialManagementId string
- for k, v := range industrialList {
- if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
- industrialList[k].IsResearch = true
- }
- industryIds = append(industryIds, v.IndustrialManagementId)
- industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
- }
- // 查研观向7.4-行业新标签
- industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
- if e != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
- return
- }
- //判断产业下是否有关联的报告,并处理是否跳转
- industrialManagementId = strings.TrimRight(industrialManagementId, ",")
- if industrialManagementId != "" {
- var condition string
- condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
- condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
- listIndustrialGrop, err := models.GetSearchResourceList(condition)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
- return
- }
- mapIndustrial := make(map[int]int)
- if len(listIndustrialGrop) > 0 {
- for _, v := range listIndustrialGrop {
- mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId
- }
- }
- for k, v := range industrialList {
- if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
- industrialList[k].IsJump = true
- }
- if activityInfo.ActivityTypeId == 1 {
- industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
- }
- }
- }
- }
- //if activityInfo.YidongActivityId != "" {
- // ydTgc, _ := services.GetYiDongCreateUserInfo(user)
- // yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
- // if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
- // return
- // }
- // detailResp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
- //}
- if len(industrialList) > 0 {
- detailResp.Label = ""
- }
- detailResp.Listndustrial = industrialList
- //处理音频回放
- var mapActivityId []int
- mapActivityId = append(mapActivityId, activityId)
- if activityInfo.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN { // 研选的音视频不在查研展示
- mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
- return
- }
- if mapActivityVoice[activityId] != nil {
- detailResp.FileType = 1
- detailResp.AudioLink = true
- detailResp.VoiceDetail = mapActivityVoice[activityId]
- }
- //处理视频回放
- mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
- return
- }
- if mapActivityVideo[activityId] != nil {
- detailResp.FileType = 2
- detailResp.AudioLink = true
- detailResp.VideoDetail = mapActivityVideo[activityId]
- }
- }
- //处理不同的报名方式按钮回显
- mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
- return
- }
- detailResp.SignupType = mapActivitySignup[activityId]
- detailResp.ShareImg = services.GetActivityShareImg(activityInfo)
- resp.Detail = detailResp
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- detailResp.AuthInfo.HasPermission = resp.HasPermission
- // 判断是否属于研选类型的活动
- if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.IsResearch = true
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 活动报名
- // @Description 活动报名接口
- // @Param request body models.ActivitySingnupRep true "type json string"
- // @Success Ret=200 {object} models.SignupStatus
- // @router /signup/add [post]
- func (this *ActivityController) SignupAdd() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- signupStatus := ""
- var req models.ActivitySingnupRep
- resp := new(models.SignupStatus)
- var total int
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- activityId := req.ActivityId
- signupType := req.SignupType
- email := req.Email
- //如果用户传了邮箱就绑定邮箱
- if email != "" && user.Email == "" {
- if !utils.ValidateEmailFormatat(req.Email) {
- br.Msg = "邮箱格式错误,请重新输入"
- br.ErrMsg = "邮箱格式错误,请重新输入"
- return
- }
- user.Email = req.Email
- err = models.UpdateUserEmail(email, uid)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "绑定客户邮箱失败!"
- }
- }
- hasPermission := 0
- if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
- resp.GoBindEmail = true
- }
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- // 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会
- if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 {
- signupType = 4
- }
- havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
- return
- }
- resp.IsResearchSpecial = isResearchSpecial
- if havePower {
- item := new(models.CygxActivitySignup)
- item.RegisterPlatform = utils.REGISTER_PLATFORM
- resp.HasPermission = 1
- hasPermission = 1
- signupStatus = "Success"
- resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
- if time.Now().After(resultTime.Add(-time.Minute * 60)) {
- signupStatus = "Overtime"
- resp.SignupType = signupType
- resp.SignupStatus = signupStatus
- resp.HasPermission = hasPermission
- resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
- br.Ret = 200
- br.Success = true
- br.Msg = ""
- br.Data = resp
- return
- }
- //限制人数为1人的专家电话会 用户操作时的消息提示
- if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
- resp.HasPermission = hasPermission
- resp.SignupStatus = utils.FULLSTARFFED_MSG
- resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
- br.Ret = 200
- br.Success = true
- br.Msg = ""
- br.Data = resp
- return
- }
- var sellerName string
- sellerName, err = models.GetCompanySellerName(user.CompanyId)
- if err != nil {
- br.Msg = "报名失败!"
- br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
- return
- }
- popupMsg, err := services.CheckActivityUserAll(activityInfo, user)
- if err != nil {
- br.Msg = "报名失败!"
- br.ErrMsg = "CheckActivityUserAll,Err:" + err.Error()
- return
- }
- if popupMsg != "" {
- br.Msg = "报名失败!"
- br.ErrMsg = fmt.Sprint("userId:", uid, "Activity:id", popupMsg)
- return
- }
- //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
- //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
- //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
- if activityInfo.IsLimitPeople == 1 {
- signupStatus, resp.PopupMsg, item.FailType, err = services.CheckActivitySignUpLimit(user, activityInfo)
- //判断优先级:总人数限制→单机构2人限制→爽约3次限制
- totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
- return
- }
- totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- //解除报名限制之后二次报名相同活动
- if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
- item.UserId = uid
- item.RealName = user.RealName
- item.SellerName = sellerName
- item.ActivityId = activityId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.SignupType = signupType
- item.FailType = 0
- item.DoFailType = 0
- _, errSignup := models.AddActivitySignupByRestrict(item)
- if errSignup != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSignup.Error()
- return
- }
- resp.HaqveJurisdiction = true
- resp.SignupType = signupType
- resp.SignupStatus = "Success"
- resp.HasPermission = hasPermission
- resp.ActivityId = activityId
- total, err = models.GetUserMeetingReminderCount(user.UserId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
- return
- }
- if total == 0 {
- resp.GoFollow = true
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.Data = resp
- return
- }
- totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
- item.UserId = uid
- item.RealName = user.RealName
- item.SellerName = sellerName
- item.ActivityId = activityId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.SignupType = signupType
- item.DoFailType = item.FailType
- if user.OutboundMobile != "" {
- item.OutboundMobile = user.OutboundMobile
- if user.OutboundCountryCode == "" {
- item.CountryCode = "86"
- } else {
- item.CountryCode = user.OutboundCountryCode
- }
- } else {
- item.OutboundMobile = user.Mobile
- if user.CountryCode == "" {
- item.CountryCode = "86"
- } else {
- item.CountryCode = user.CountryCode
- }
- }
- //添加报名信息,但是不加入日程
- _, errSignup := models.AddActivitySignupNoSchedule(item)
- if errSignup != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSignup.Error()
- return
- }
- }
- }
- totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if totalMySuccess > 0 {
- br.Msg = "您已报名这个活动"
- return
- }
- if signupStatus == "Success" && resp.GoBindEmail != true {
- item.UserId = uid
- item.RealName = user.RealName
- item.SellerName = sellerName
- item.ActivityId = activityId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.SignupType = signupType
- item.FailType = 0
- item.DoFailType = 0
- item.OutboundMobile = user.Mobile
- if user.OutboundMobile != "" {
- item.OutboundMobile = user.OutboundMobile
- if user.OutboundCountryCode == "" {
- item.CountryCode = "86"
- } else {
- item.CountryCode = user.OutboundCountryCode
- }
- } else {
- item.OutboundMobile = user.Mobile
- if user.CountryCode == "" {
- item.CountryCode = "86"
- } else {
- item.CountryCode = user.CountryCode
- }
- }
- _, errSignup := models.AddActivitySignup(item)
- if errSignup != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSignup.Error()
- return
- }
- resp.HaqveJurisdiction = true
- //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
- if signupType == 1 {
- go services.ActivityUserRemind(user, activityInfo, 1)
- resp.PopupMsg = "<b>预约成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
- } else if signupType == 4 {
- go services.ActivityUserRemind(user, activityInfo, 4)
- resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
- } else {
- go services.ActivityUserRemind(user, activityInfo, 4)
- resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
- if activityInfo.IsZoom == 1 && activityInfo.IsLimitPeople > 0 {
- resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><b>届时请通过zoom会议链接或app自主入会</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
- }
- }
- if activityInfo.IsResearchPoints {
- resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
- }
- // 如果是买方研选下的专家沙龙,同时推给内容组四人
- if activityInfo.ActivityTypeId == 5 && activityInfo.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
- go services.SendNeiRongZuActivitieSignTemplateMsg(user, activityInfo)
- go services.SendNeiRongZuActivitieSignCategoryTemplateMsg(user, activityInfo)
- }
- go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点
- }
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- if signupType == 1 && user.IsMsgOutboundMobile == 0 {
- resp.GoOutboundMobile = true
- if user.Mobile != "" || user.OutboundMobile != "" {
- go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
- }
- }
- if user.OutboundMobile == "" {
- resp.Mobile = user.Mobile
- if user.CountryCode == "" && len(user.Mobile) == 11 {
- resp.CountryCode = "86"
- } else {
- resp.CountryCode = user.CountryCode
- }
- } else {
- resp.Mobile = user.OutboundMobile
- resp.CountryCode = user.OutboundCountryCode
- }
- //如果用户有绑定手机号,但是没有绑定外呼手机号
- if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
- var countryCode string
- if len(user.Mobile) == 8 {
- countryCode = "852"
- } else if len(user.Mobile) == 9 {
- countryCode = "886"
- } else if len(user.Mobile) == 10 {
- countryCode = "1"
- } else if len(user.Mobile) >= 11 {
- countryCode = "86"
- }
- models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
- }
- // 判断是否属于研选类型的活动
- if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.IsResearch = true
- }
- //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
- if signupStatus == "Success" {
- go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "报名")
- }
- resp.SignupType = signupType
- resp.SignupStatus = signupStatus
- //resp.HasPermission = hasPermission
- //if signupStatus == "Success" {
- resp.ActivityId = activityId
- //}
- total, err = models.GetUserSignupCount(user.UserId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
- return
- }
- if total <= 1 {
- resp.GoFollow = true
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.Data = resp
- }
- // @Title 活动取消报名
- // @Description 活动取消报名接口
- // @Param request body models.ActivitySingnupRep true "type json string"
- // @Success Ret=200 {object} models.SignupStatus
- // @router /signup/cancel [post]
- func (this *ActivityController) SignupCancel() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.ActivitySingnupRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- activityId := req.ActivityId
- signupType := req.SignupType
- item := new(models.CygxActivitySignup)
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- //checkTime, _ := services.CheckSiginupDeadline(activityInfo)
- //if !checkTime {
- // br.Msg = "报名名单已提交举办方,若想取消,请联系对口销售"
- // br.ErrMsg = "报名名单已提交举办方,若想取消,请联系对口销售"
- // return
- //}
- cancelDeadlineMsg := services.CheckCancelDeadline(activityInfo)
- if cancelDeadlineMsg != "" {
- br.Msg = cancelDeadlineMsg
- br.ErrMsg = cancelDeadlineMsg
- return
- }
- resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
- if time.Now().After(resultTime.Add(-time.Minute * 60)) {
- if signupType == 1 {
- br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
- } else {
- br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
- }
- br.ErrMsg = br.Msg
- return
- }
- total, err := models.GetActivitySignupCount(uid, activityId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if total == 0 {
- br.Msg = "您暂未报名这个活动"
- return
- }
- item.UserId = uid
- item.ActivityId = activityId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- _, errSignup := models.CancelActivitySignup(item)
- if errSignup != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSignup.Error()
- return
- }
- // 如果是买方研选下的专家沙龙,同时推给内容组四人
- if activityInfo.ActivityTypeId == 5 {
- go services.SendActivitieCancelSignTemplateMsg(user, activityInfo)
- go services.SendActivitieCancelSignCategoryTemplateMsg(user, activityInfo)
- }
- go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "取消报名") //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
- go services.YanXuanActivityPointsBillSignupCancel(activityId, uid) // 用户取消报名添加到处理研选扣点
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- }
- // @Title 添加会议提醒
- // @Description 添加会议提醒接口
- // @Param request body models.ActivityIdRep true "type json string"
- // @Success Ret=200 {object} models.SignupStatus
- // @router /meetingReminder/add [post]
- func (this *ActivityController) MeetingReminderAdd() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- signupStatus := ""
- var req models.ActivitySingnupRep
- resp := new(models.SignupStatus)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- activityId := req.ActivityId
- signupType := req.SignupType
- hasPermission := 0
- if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
- resp.GoBindEmail = true
- }
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
- return
- }
- resp.IsResearchSpecial = isResearchSpecial
- if havePower {
- item := new(models.CygxActivityMeetingReminder)
- item.RegisterPlatform = utils.REGISTER_PLATFORM
- resp.HasPermission = 1
- hasPermission = 1
- signupStatus = "Success"
- resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
- if time.Now().After(resultTime.Add(-time.Minute * 15)) {
- signupStatus = "Overtime"
- resp.SignupType = signupType
- resp.SignupStatus = signupStatus
- resp.HasPermission = hasPermission
- resp.PopupMsg = "活动开始前15分钟无法设置会议提醒"
- br.Ret = 200
- br.Success = true
- br.Msg = ""
- br.Data = resp
- return
- }
- //限制人数为1人的专家电话会 用户操作时的消息提示
- if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
- resp.HasPermission = hasPermission
- resp.SignupStatus = utils.FULLSTARFFED_MSG
- resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
- br.Ret = 200
- br.Success = true
- br.Msg = ""
- br.Data = resp
- return
- }
- totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
- if errMeeting != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
- return
- }
- if totalMeeting > 0 {
- br.Msg = "您已预约,请勿重复预约"
- return
- }
- item.UserId = uid
- item.ActivityId = activityId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- _, errSignup := models.AddActivityMeetingReminder(item)
- if errSignup != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSignup.Error()
- return
- }
- br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
- resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- // 判断是否属于研选类型的活动
- if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.IsResearch = true
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.Data = resp
- }
- // @Title 取消会议提醒
- // @Description 取消会议提醒接口
- // @Param request body models.ActivityIdRep true "type json string"
- // @Success Ret=200 {object} models.SignupStatus
- // @router /meetingReminder/cancel [post]
- func (this *ActivityController) MeetingReminderCancel() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.ActivityIdRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- activityId := req.ActivityId
- signupStatus := "Success"
- item := new(models.CygxActivityMeetingReminder)
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- total, err := models.GetActivityMeetingReminderCount(uid, activityId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if total == 0 {
- br.Msg = "您暂未添加该活动会议提醒"
- return
- }
- item.UserId = uid
- item.ActivityId = activityId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- _, errSignup := models.CancelActivityMeetingReminder(item)
- if errSignup != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSignup.Error()
- return
- }
- resp := new(models.SignupStatus)
- resp.SignupStatus = signupStatus
- resp.HasPermission = 1
- resp.ActivityId = activityId
- br.Ret = 200
- br.Success = true
- br.Msg = "会议提醒已取消"
- br.Data = resp
- }
- // @Title 预约纪要
- // @Description 预约纪要接口
- // @Param request body models.ActivityIdRep true "type json string"
- // @Success Ret=200 {object} models.AppointmentResp
- // @router /appointment/add [post]
- func (this *ActivityController) ActivityAppointmentAdd() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.ActivitySingnupRep
- resp := new(models.SignupStatus)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- activityId := req.ActivityId
- signupType := req.SignupType
- if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
- resp.GoBindEmail = true
- }
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
- return
- }
- resp.IsResearchSpecial = isResearchSpecial
- if havePower {
- item := new(models.CygxActivityAppointment)
- item.RegisterPlatform = utils.REGISTER_PLATFORM
- resp.HasPermission = 1
- //限制人数为1人的专家电话会 用户操作时的消息提示
- if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
- resp.SignupStatus = utils.FULLSTARFFED_MSG
- resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
- br.Ret = 200
- br.Success = true
- br.Msg = ""
- br.Data = resp
- return
- }
- totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
- if errMeeting != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
- return
- }
- if totalMeeting > 0 {
- br.Msg = "您已预约,请勿重复预约"
- return
- }
- var sellerName string
- sellerName, err = models.GetCompanySellerName(user.CompanyId)
- if err != nil {
- br.Msg = "报名失败!"
- br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
- return
- }
- item.UserId = uid
- item.ActivityId = activityId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.SellerName = sellerName
- item.RealName = user.RealName
- err = models.AddCygxActivityAppointment(item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- resp.SignupStatus = "Success"
- //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
- //go services.ActivityUserRemind(user, activityInfo, 3)
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- // 判断是否属于研选类型的活动
- if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.IsResearch = true
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.Data = resp
- }
- // @Title 取消预约纪要
- // @Description 取消预约纪要接口
- // @Param request body models.ActivityIdRep true "type json string"
- // @Success Ret=200 {object} models.SignupStatus
- // @router /appointment/cancel [post]
- func (this *ActivityController) ActivityAppointmentCancel() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.ActivityIdRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- activityId := req.ActivityId
- signupStatus := "Success"
- item := new(models.CygxActivityAppointment)
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if total == 0 {
- br.Msg = "您暂未预约该纪要"
- return
- }
- item.UserId = uid
- item.ActivityId = activityId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- _, errSignup := models.CancelcygxActivityAppointment(item)
- if errSignup != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSignup.Error()
- return
- }
- resp := new(models.SignupStatus)
- resp.SignupStatus = signupStatus
- resp.ActivityId = activityId
- resp.HasPermission = 1
- br.Ret = 200
- br.Success = true
- br.Msg = "已取消"
- br.Data = resp
- }
- // @Title 活动带问
- // @Description 新增活动带问接口
- // @Param request body models.AddCygxActivityHelpAsk true "type json string"
- // @Success Ret=200 新增成功
- // @router /askAdd [post]
- func (this *ActivityController) AskAdd() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req models.CygxActivityHelpAsk
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.Content == "" {
- br.Msg = "建议内容不可为空"
- return
- }
- content := req.Content
- activityId := req.ActivityId
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- resp := new(models.SignupStatus)
- havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
- return
- }
- resp.IsResearchSpecial = isResearchSpecial
- if havePower {
- companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
- if err != nil {
- br.Msg = "提交失败!"
- br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
- return
- }
- if companyDetail == nil {
- br.Msg = "提交失败!"
- br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
- return
- }
- resp.SignupStatus = "Success"
- resp.HasPermission = 1
- item := new(models.CygxActivityHelpAsk)
- item.RegisterPlatform = utils.REGISTER_PLATFORM
- item.UserId = user.UserId
- item.ActivityId = req.ActivityId
- item.CompanyId = user.CompanyId
- item.CompanyName = companyDetail.CompanyName
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.Content = content
- msgId, err := models.AddActivityHelpAsk(item)
- if err != nil {
- br.Msg = "提交失败"
- br.ErrMsg = "提交带问失败,Err:" + err.Error()
- return
- }
- var isSendMsg bool
- resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
- if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
- if time.Now().After(resultTime.Add(-time.Minute * 15)) {
- isSendMsg = true
- }
- } else {
- if time.Now().After(resultTime.Add(-time.Minute * 60)) {
- isSendMsg = true
- }
- }
- if isSendMsg {
- listEmail, err := models.GetAskEmail()
- if err != nil {
- br.Msg = "提交失败"
- br.ErrMsg = "提交带问失败,Err:" + err.Error()
- return
- }
- var sendMobile string
- for _, v := range listEmail {
- if strings.Index(activityInfo.Host, v.Name) > 0 {
- sendMobile = v.Mobile
- }
- }
- if activityInfo.ChartPermissionId == 31 {
- sendMobile = utils.ActSendMsgMobile
- }
- //获取销售信息
- sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "提交失败"
- br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
- return
- }
- //给研究员发送消息
- if sendMobile != "" {
- openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
- if openIpItem != nil && openIpItem.OpenId != "" {
- if sellerItem != nil {
- //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
- services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
- }
- }
- }
- // 给所属销售发送消息
- if sellerItem != nil {
- openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
- if openIpItem != nil && openIpItem.OpenId != "" {
- //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
- services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
- }
- go services.SendWxCategoryMsgWithAsk(user, activityInfo, content, int(msgId))
- }
- }
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- // 判断是否属于研选类型的活动
- if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.IsResearch = true
- }
- br.Ret = 200
- br.Success = true
- br.Data = resp
- br.Msg = "提交成功"
- }
- // @Title 视频详情
- // @Description 时间线接口
- // @Param VideoId query int true "视频ID"
- // @Success 200 {object} models.IndustryVideoDetailResp
- // @router /detailVideo [get]
- func (this *ActivityController) DetailVideo() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- videoId, _ := this.GetInt("VideoId")
- videoSimple, au, err := services.GetActivityVideoDetailById(user, videoId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
- return
- }
- resp := new(models.ActivityVideoDetailResp)
- resp.VideoDetail = videoSimple
- resp.AuthInfo = au
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 活动、专项调研搜索
- // @Description 活动、专项调研搜索接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
- // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
- // @Success 200 {object} models.GetCygxActivityListRep
- // @router /listSearch [get]
- func (this *ActivityController) ActivityListSearch() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- source, _ := this.GetInt("Source")
- keyWord := this.GetString("KeyWord")
- playBack, _ := this.GetInt("PlayBack")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- //活动可见限制
- conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "3", "", 0, 1, keyWord, playBack, 1)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
- return
- }
- if source == 1 {
- condition += ` AND art.yidong_activity_id = '' `
- }
- //conditionActivity, err := services.ActivityConditioninitSql(user, conditionInit, 0)
- //if err != nil && err.Error() != utils.ErrNoRow() {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
- // return
- //}
- condition += ` AND art.publish_status = 1 ` + conditionActivity
- listActivity, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, playBack, keyWord)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- //return
- //用户权限
- authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
- return
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(models.HomeResourceDataListResp)
- var list []*models.CygxResourceDataResp
- for _, v := range listActivity {
- var item = new(models.CygxResourceDataResp)
- //resp.List = append(resp.List, &models.CygxResourceDataResp{
- item.SourceId = v.ActivityId
- if v.SourceType == 1 {
- item.Source = "activity"
- } else {
- item.Source = "activityspecial"
- }
- item.Title = v.ActivityName
- item.City = v.City
- item.IsSignup = v.IsSignup
- item.SignupType = v.SignupType
- item.ActivityTypeId = v.ActivityTypeId
- item.IsCancelMeetingReminder = v.IsCancelMeetingReminder
- item.IsAppointment = v.IsAppointment
- item.ActiveState = v.ActiveState
- item.ImgUrlText = v.ImgUrlText
- item.ImgUrl = v.ImgUrl
- item.ActivityType = v.ActivityType
- item.IsShowOutboundCall = v.IsShowOutboundCall
- item.IsShowMeetingReminder = v.IsShowMeetingReminder
- item.IsShowHelpSsk = v.IsShowHelpSsk
- item.IsShowSignup = v.IsShowSignup
- item.IsShowAppointment = v.IsShowAppointment
- item.IsShowDetails = v.IsShowDetails
- item.ActivityTimeText = v.ActivityTimeText
- item.Expert = v.Expert
- item.Speaker = v.Speaker
- item.DistinguishedGuest = v.DistinguishedGuest
- item.PublishDate = v.ActivityTime
- item.TripImgLink = v.TripImgLink
- item.TripStatus = 2
- item.ActiveState = v.ActiveState
- item.PublishDate = v.ActivityTime
- item.FileType = v.FileType
- item.IsYidongConduct = v.IsYidongConduct
- item.IsCanOutboundCall = v.IsCanOutboundCall
- item.IsLimitPeople = v.IsLimitPeople
- item.IsResearchPoints = v.IsResearchPoints
- item.SiginupDeadline = v.SiginupDeadline
- item.IsYidongActivity = v.IsYidongActivity
- // 判断是否属于研选类型的活动
- if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- item.IsResearch = true
- if (v.ActivityTypeId == 3 || v.ActivityTypeId == 5) && v.YidongActivityId == "" && strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) && utils.InArrayByStr(permissionArr, utils.CHART_PERMISSION_NAME_MF_YANXUAN) {
- item.IsResearchSpecial = true
- }
- }
- if v.VoiceList != nil || v.VideoDetail != nil {
- item.AudioLink = true
- }
- if v.FileType == 1 {
- if v.VoiceList != nil {
- item.VoiceDetail = v.VoiceList
- }
- } else {
- if v.VideoDetail != nil {
- item.VideoDetail = v.VideoDetail
- }
- }
- au := new(models.UserPermissionAuthInfo)
- au.SellerName = authInfo.SellerName
- au.SellerMobile = authInfo.SellerMobile
- au.HasPermission = authInfo.HasPermission
- au.OperationMode = authInfo.OperationMode
- if au.HasPermission == 1 {
- // 非宏观权限进一步判断是否有权限
- if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
- au.HasPermission = 2
- }
- //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0
- if v.YidongActivityId != "" {
- if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) {
- au.HasPermission = 1
- }
- }
- }
- // 无权限的弹框提示
- if au.HasPermission != 1 {
- if au.OperationMode == services.UserPermissionOperationModeCall {
- if v.FileType == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgCallActivity
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
- }
- } else {
- if v.FileType == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
- }
- }
- }
- item.AuthInfo = au
- list = append(list, item)
- }
- if len(list) == 0 {
- list = make([]*models.CygxResourceDataResp, 0)
- }
- //添加活动搜索记录
- //if keyWord != "" {
- //go services.AddActivitykeyWordSearch(keyWord, user)
- //}
- resp.Paging = page
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 我的日程
- // @Description 我的日程列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.GetCygxActivityListRep
- // @router /scheduleList [get]
- func (this *ActivityController) ScheduleList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- //source, _ := this.GetInt("Source")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- var conditionCount string
- var pars []interface{}
- condition += ` AND art.publish_status = 1 `
- //if source == 1 {
- // condition += ` AND art.yidong_activity_id = '' `
- // conditionCount += ` AND art.yidong_activity_id = '' `
- //}
- total, err := models.GetScheduleCount(conditionCount, uid)
- specialtotal, err := models.GetSpecialScheduleCount(uid)
- page := paging.GetPaging(currentIndex, pageSize, total+specialtotal)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- conditionCount = ` AND art.active_state = 2 `
- totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- var list []*models.ActivityDetail
- //全部都是进行中的活动
- if totalCount > currentIndex*pageSize {
- condition += ` AND art.active_state IN(2) `
- //if source == 1 {
- // condition += ` AND art.yidong_activity_id = '' `
- //}
- listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
- list = listHave
- if errList != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errList.Error()
- return
- }
- } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
- condition = ` AND art.publish_status = 1 AND art.active_state IN(2) `
- //if source == 1 {
- // condition += ` AND art.yidong_activity_id = '' `
- //}
- listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
- list = listHave
- if errList != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errList.Error()
- return
- }
- pageSize = pageSize - len(listHave)
- condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) `
- //if source == 1 {
- // condition += ` AND art.yidong_activity_id = '' `
- //}
- //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
- listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
- if errList != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errList.Error()
- return
- }
- if len(listOther) > 0 {
- for _, v := range listOther {
- list = append(list, v)
- }
- }
- } else {
- condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
- //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
- listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
- list = listOther
- if errList != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errList.Error()
- return
- }
- }
- var isShow bool
- isShow = services.GetShowSustainable()
- detail, err := models.GetConfigByCode("city_img_url")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
- return
- }
- detailChart, err := models.GetConfigByCode("chart_img_url")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
- return
- }
- addressList := strings.Split(detail.ConfigValue, "{|}")
- mapAddress := make(map[string]string)
- chartList := strings.Split(detailChart.ConfigValue, "{|}")
- mapChart := make(map[string]string)
- var cityName string
- var chartName string
- var imgUrl string
- var imgUrlChart string
- var mapActivityId []int
- for _, v := range addressList {
- vslice := strings.Split(v, "_")
- cityName = vslice[0]
- imgUrl = vslice[len(vslice)-1]
- mapAddress[cityName] = imgUrl
- }
- for _, v := range chartList {
- vslice := strings.Split(v, "_")
- chartName = vslice[0]
- imgUrlChart = vslice[len(vslice)-1]
- mapChart[chartName] = imgUrlChart
- }
- for k, v := range list {
- if strings.Contains(v.ActivityName, "【") {
- list[k].IsBrackets = 1
- }
- if v.SignupNum > v.LimitPeopleNum {
- list[k].SignupNum = v.LimitPeopleNum
- }
- //是否展示限免标签
- if isShow && strings.Contains(v.ChartPermissionName, "研选") {
- list[k].IsShowSustainable = true
- }
- if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- list[k].IsResearch = true
- }
- if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
- //list[k].ActivityTypeName = "买方研选电话会"
- //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
- list[k].ImgUrlText = utils.YAN_XUAN_IMG
- }
- if v.ActivityType == 0 && v.SourceType == 1 {
- if mapAddress[v.City] != "" {
- list[k].ImgUrl = mapAddress[v.City]
- } else {
- list[k].ImgUrl = mapAddress["其它"]
- }
- } else {
- if mapChart[v.ChartPermissionName] != "" {
- list[k].ImgUrl = mapChart[v.ChartPermissionName]
- }
- }
- expertTxt, _ := services.GetReportContentTextSub(v.Expert)
- list[k].Expert = expertTxt
- if v.IsHideAppointment == 0 {
- list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
- }
- if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
- list[k].IsCClassMeeting = true
- }
- mapActivityId = append(mapActivityId, v.ActivityId)
- }
- //添加我的日程访问记录
- item := new(models.CygxPageHistoryRecord)
- item.UserId = user.UserId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.PageType = "MySchedule"
- go models.AddCygxPageHistoryRecord(item)
- resp := new(models.GetCygxActivityListRep)
- //处理音频回放
- mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
- return
- }
- //处理视频回放
- mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
- return
- }
- //处理不同的报名方式按钮回显
- mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
- return
- }
- for k, v := range list {
- if mapActivityVoice[v.ActivityId] != nil {
- list[k].FileType = 1
- list[k].AudioLink = true
- list[k].VoiceList = mapActivityVoice[v.ActivityId]
- }
- if mapActivityVideo[v.ActivityId] != nil {
- list[k].FileType = 2
- list[k].AudioLink = true
- list[k].VideoDetail = mapActivityVideo[v.ActivityId]
- }
- v.SignupType = mapActivitySignup[v.ActivityId]
- //处理列表的标签是否展示逻辑
- //resp.List = append(resp.List, services.ActivityButtonShow(v, user, make([]string, 0)))
- }
- resp.List = services.ActivityArrButtonShow(list, user, make([]string, 0))
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 活动报名之前的校验(权限、时间、点数、邮箱)
- // @Description 活动报名之前的校验(权限、时间、点数、邮箱)接口
- // @Param request body models.ActivityIdRep true "type json string"
- // @Success Ret=200 {object} models.SignupStatus
- // @router /check [post]
- func (this *ActivityController) Check() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- var req models.ActivityIdRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- activityId := req.ActivityId
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- //这里的文案顺序提示 权限>时间>研选扣点>邮箱绑定。
- resp := new(models.ActivityCheck)
- resp.CancelPopupMsg, err = services.ActivityCancelDeadlineMsg(activityInfo) //处理取消报名截止时间的弹窗文案
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- hasPermission := 0
- havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
- return
- }
- resp.IsResearchSpecial = isResearchSpecial
- if havePower {
- hasPermission = 1
- resp.CheckPermission = true
- resp.HasPermission = hasPermission
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- if resp.CheckPermission {
- //如果权限通过了校验,那么就来校验时间
- resp.CheckTime, resp.PopupMsg = services.CheckSiginupDeadline(activityInfo)
- }
- if resp.CheckTime {
- // 如果时间通过校验就校验点数
- resp.CheckPoints, resp.PopupMsg, resp.CompanyPoints, resp.ActivityPoints, err = services.CheckActivityPoints(activityInfo, user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "CheckActivityPoints,Err:" + err.Error()
- return
- }
- }
- if resp.CheckPoints {
- //如果通过点数的校验,就来校验邮箱
- resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user)
- }
- // 判断是否属于研选类型的活动
- if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.IsResearch = true
- }
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 记录用户浏览音频回放接口
- // @Description 记录用户浏览音频回放接口
- // @Param request body models.ActivityIdRep true "type json string"
- // @Success Ret=200 {object} models.AppointmentResp
- // @router /voiceHistory/add [post]
- func (this *ActivityController) ActivityVoiceHistoryAdd() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.ActivityIdRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- activityId := req.ActivityId
- playSeconds := req.PlaySeconds
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- var sellerName string
- sellerName, err = models.GetCompanySellerName(user.CompanyId)
- if err != nil {
- br.Msg = "报名失败!"
- br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
- return
- }
- item := models.CygxActivityVoiceHistory{
- ActivityId: activityId,
- UserId: uid,
- CreateTime: time.Now(),
- Mobile: user.Mobile,
- Email: user.Email,
- CompanyId: user.CompanyId,
- CompanyName: user.CompanyName,
- RealName: user.RealName,
- SellerName: sellerName,
- PlaySeconds: strconv.Itoa(req.PlaySeconds),
- ModifyTime: time.Now(),
- }
- if playSeconds != 0 {
- lastItem, err := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,GetLastCygxActivityVoiceHistory Err:" + err.Error()
- return
- }
- err = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,UpdateLastCygxActivityVoiceHistory Err:" + err.Error()
- return
- }
- } else {
- err = models.AddCygxActivityVoiceHistory(&item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- err = models.UpdateCygxActivityVoiceCounts(activityId)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,Err:" + err.Error()
- return
- }
- go services.ActivityVideoUserRmind(user, activityId, 2)
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- return
- }
- // @Title 获取易董活动跳转地址详情
- // @Description 获取易董活动跳转地址详情接口
- // @Param ActivityId query int true "活动ID"
- // @Success Ret=200 {object} models.CygxActivityResp
- // @router /get_yidong_url [get]
- func (this *ActivityController) GetYidongUrl() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- activityId, _ := this.GetInt("ActivityId")
- if activityId < 1 {
- br.Msg = "请输入活动ID"
- return
- }
- resp := new(models.CygxYidongActivityUrlResp)
- activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
- return
- }
- havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
- return
- }
- resp.IsResearchSpecial = isResearchSpecial
- if havePower {
- resp.HasPermission = 1
- if activityInfo.YidongActivityId != "" {
- ydTgc, _ := services.GetYiDongCreateUserInfo(user)
- yidongLongLink, _ := services.GetYiDongOriginalLink(activityInfo)
- if yidongLongLink != "" {
- resp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
- }
- }
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 校验活动带问是否有权限
- // @Description 校验活动带问是否有权限接口
- // @Param request body models.ActivityIdRep true "type json string"
- // @Success Ret=200 {object} models.SignupStatus
- // @router /checkAsk [post]
- func (this *ActivityController) CheckAsk() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- var signupStatus string
- var req models.ActivityIdRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- activityId := req.ActivityId
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- resp := new(models.SignupStatus)
- hasPermission := 0
- havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
- return
- }
- resp.IsResearchSpecial = isResearchSpecial
- if havePower {
- hasPermission = 1
- signupStatus = "Success"
- //限制人数为1人的专家电话会 用户操作时的消息提示
- if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
- resp.HasPermission = hasPermission
- resp.SignupStatus = utils.FULLSTARFFED_MSG
- resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
- br.Ret = 200
- br.Success = true
- br.Msg = ""
- br.Data = resp
- return
- }
- resp.HaqveJurisdiction = true
- resp.HasPermission = hasPermission
- resp.SignupStatus = signupStatus
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- // 判断是否属于研选类型的活动
- if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.IsResearch = true
- }
- resp.ActivityId = activityId
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
|