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