123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164 |
- 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.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
- }
|