activity.go 160 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/medivhzhan/weapp/v2"
  6. "github.com/rdlucklib/rdluck_tools/paging"
  7. "hongze/hongze_cygx/models"
  8. "hongze/hongze_cygx/services"
  9. "hongze/hongze_cygx/utils"
  10. "sort"
  11. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. //活动
  16. type ActivityCoAntroller struct {
  17. BaseAuthController
  18. }
  19. type ActivityABaseController struct {
  20. BaseCommonController
  21. }
  22. // @Title 活动类型列表
  23. // @Description活动类型列表接口
  24. // @Success 200 {object} models.ActivityTypeListResp
  25. // @router /activityTypelist [get]
  26. func (this *ActivityCoAntroller) List() {
  27. br := new(models.BaseResponse).Init()
  28. defer func() {
  29. this.Data["json"] = br
  30. this.ServeJSON()
  31. }()
  32. user := this.User
  33. if user == nil {
  34. br.Msg = "请登录"
  35. br.ErrMsg = "请登录,SysUser Is Empty"
  36. br.Ret = 408
  37. return
  38. }
  39. resp := new(models.ActivityTypeListResp)
  40. list, err := models.GetActivityTypeList()
  41. if err != nil {
  42. br.Msg = "获取失败"
  43. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  44. return
  45. }
  46. resp.List = list
  47. br.Ret = 200
  48. br.Success = true
  49. br.Msg = "获取成功"
  50. br.Data = resp
  51. }
  52. // @Title 活动列表
  53. // @Description 获取活动列表接口
  54. // @Param PageSize query int true "每页数据条数"
  55. // @Param CurrentIndex query int true "当前页页码,从1开始"
  56. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  57. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  58. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  59. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  60. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  61. // @Param IsShowJurisdiction query int false "是否仅展示有权限的,1是,2否 默认为零"
  62. // @Param Label query string false "搜索主题 多个用 , 隔开"
  63. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  64. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  65. // @Success 200 {object} models.GetCygxActivityListRep
  66. // @router /list [get]
  67. func (this *ActivityCoAntroller) ActivityList() {
  68. br := new(models.BaseResponse).Init()
  69. defer func() {
  70. this.Data["json"] = br
  71. this.ServeJSON()
  72. }()
  73. user := this.User
  74. if user == nil {
  75. br.Msg = "请登录"
  76. br.ErrMsg = "请登录,SysUser Is Empty"
  77. return
  78. }
  79. uid := user.UserId
  80. pageSize, _ := this.GetInt("PageSize")
  81. currentIndex, _ := this.GetInt("CurrentIndex")
  82. chartPermissionIds := this.GetString("ChartPermissionIds")
  83. activityTypeIds := this.GetString("ActivityTypeIds")
  84. whichDay := this.GetString("WhichDay")
  85. isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
  86. keyWord := this.GetString("KeyWord")
  87. keyWordSearch := this.GetString("KeyWord")
  88. activeState := this.GetString("ActiveState")
  89. label := this.GetString("Label")
  90. playBack, _ := this.GetInt("PlayBack")
  91. //入参为 undefined 时的处理
  92. if chartPermissionIds == "undefined" {
  93. chartPermissionIds = ""
  94. }
  95. // 查研观向7.4-始终查询宏观的活动
  96. if chartPermissionIds != "" {
  97. chartPermissionIds += ",1"
  98. }
  99. if activityTypeIds == "undefined" {
  100. activityTypeIds = ""
  101. }
  102. if whichDay == "undefined" {
  103. whichDay = ""
  104. }
  105. if activeState == "undefined" {
  106. activeState = ""
  107. }
  108. if label == "undefined" {
  109. label = ""
  110. }
  111. //更新用户的搜索信息
  112. itemSearch := new(models.CygxActivityUserSearchContent)
  113. itemSearch.UserId = uid
  114. itemSearch.CreateTime = time.Now()
  115. itemSearch.Mobile = user.Mobile
  116. itemSearch.Email = user.Email
  117. itemSearch.CompanyId = user.CompanyId
  118. itemSearch.CompanyName = user.CompanyName
  119. itemSearch.ModifyTime = time.Now()
  120. itemSearch.ChartPermissionids = chartPermissionIds
  121. itemSearch.ActivityTypeids = activityTypeIds
  122. itemSearch.ActiveState = activeState
  123. itemSearch.IsShowJurisdiction = isShowJurisdiction
  124. //并发缓存校验
  125. cacheKey := fmt.Sprint("xygx:activity_user_search:add:", uid)
  126. ttlTime := utils.Rc.GetRedisTTL(cacheKey)
  127. _, errSearch := models.AddUserSearchContent(itemSearch, ttlTime)
  128. if errSearch != nil {
  129. br.Msg = "操作失败"
  130. br.ErrMsg = "操作失败,Err:" + errSearch.Error()
  131. return
  132. }
  133. utils.Rc.SetNX(cacheKey, user.Mobile, time.Second*10)
  134. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  135. if isShowJurisdiction == 1 && chartPermissionIds == "" && userType == 4 {
  136. activityTypeIds = "1,3"
  137. }
  138. var startSize int
  139. if pageSize <= 0 {
  140. pageSize = utils.PageSize20
  141. }
  142. if currentIndex <= 0 {
  143. currentIndex = 1
  144. }
  145. startSize = utils.StartIndex(currentIndex, pageSize)
  146. var condition string
  147. var pars []interface{}
  148. //活动可见限制
  149. var sqlExport string
  150. slicePer := strings.Split(permissionStr, ",")
  151. var permissionSqlStr string
  152. for _, v := range slicePer {
  153. if userType == 1 {
  154. //if v != "研选" {
  155. if !strings.Contains(v, "研选") {
  156. permissionSqlStr += "'" + v + "',"
  157. }
  158. } else {
  159. permissionSqlStr += "'" + v + "',"
  160. }
  161. }
  162. permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
  163. permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
  164. permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
  165. permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionSqlStr + `)`
  166. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  167. if userType == 2 {
  168. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  169. }
  170. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  171. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  172. }
  173. sqlExport += `) `
  174. if keyWord != "" {
  175. var mirrorword string
  176. var mirrorwordSql string
  177. slicemirrorword := strings.Split(keyWord, ",")
  178. for _, v := range slicemirrorword {
  179. mirrorwordSql += "'" + v + "'" + ","
  180. }
  181. mirrorwordSql = strings.TrimRight(mirrorwordSql, ",")
  182. total, err := models.GetActivityMirrorWordCount(mirrorwordSql)
  183. if err != nil {
  184. br.Msg = "获取失败"
  185. br.ErrMsg = "获取失败,Err:" + err.Error()
  186. return
  187. }
  188. if total > 0 {
  189. mirrorword, err = models.GetMirrorWord(mirrorwordSql)
  190. if err != nil {
  191. br.Msg = "获取信息失败"
  192. br.ErrMsg = "关系词映射获取失败,Err:" + err.Error()
  193. return
  194. }
  195. }
  196. keyWord = keyWord + "," + mirrorword
  197. slicekeyWord := strings.Split(keyWord, ",")
  198. var sqlKeyOr string
  199. if len(slicekeyWord) >= 2 {
  200. for _, v := range slicekeyWord {
  201. if v != "" {
  202. sqlKeyOr += ` OR art.activity_name LIKE '%` + v + `%' `
  203. }
  204. }
  205. condition += ` AND (art.activity_name LIKE '%` + keyWord + `%' ` + sqlKeyOr + ` )`
  206. } else {
  207. condition += ` AND (art.activity_name LIKE '%` + keyWord + `%' )`
  208. }
  209. }
  210. //主题
  211. if label != "" {
  212. sliceLabel := strings.Split(label, ",")
  213. var labelSqlStr string
  214. for _, v := range sliceLabel {
  215. labelSqlStr += "'" + v + "',"
  216. }
  217. labelSqlStr = strings.TrimRight(labelSqlStr, ",")
  218. condition = ` AND art.label IN (` + labelSqlStr + `)`
  219. }
  220. //行业名称
  221. if len(chartPermissionIds) > 0 {
  222. condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  223. }
  224. if activityTypeIds != "" {
  225. condition += ` AND art.activity_type_id IN (` + activityTypeIds + `)`
  226. }
  227. if whichDay != "" {
  228. var startDate string
  229. var endDate string
  230. if whichDay == "1" {
  231. startDate = time.Now().Format(utils.FormatDate)
  232. endDate = startDate
  233. } else if whichDay == "2" {
  234. startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  235. endDate = startDate
  236. } else {
  237. startDate = time.Now().Format(utils.FormatDate)
  238. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  239. }
  240. condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  241. condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  242. }
  243. if activeState != "" {
  244. condition += ` AND art.active_state IN (` + activeState + `)`
  245. }
  246. condition += ` AND art.publish_status = 1 `
  247. var conditionOr string
  248. // 有专家权限的这几种用户,不做行业权限校验
  249. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  250. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  251. }
  252. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  253. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  254. }
  255. if userType == 1 {
  256. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  257. } else {
  258. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  259. }
  260. //判断客户规模是否属于可见范围的活动
  261. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  262. if err != nil && err.Error() != utils.ErrNoRow() {
  263. br.Msg = "获取信息失败"
  264. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  265. return
  266. }
  267. if companyProduct != nil {
  268. if companyProduct.Scale != "" {
  269. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  270. }
  271. }
  272. condition += ` AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  273. total, err := models.GetActivityCount(condition, playBack, pars)
  274. if err != nil {
  275. br.Msg = "获取失败"
  276. br.ErrMsg = "获取失败,Err:" + err.Error()
  277. return
  278. }
  279. if activeState == "2" || activeState == "3" {
  280. condition += ` ORDER BY art.activity_time DESC `
  281. } else {
  282. condition += ` ORDER BY art.active_state ASC, art.activity_time ASC `
  283. }
  284. list, errList := models.GetActivityListAll(condition, pars, uid, startSize, pageSize, playBack)
  285. if errList != nil {
  286. br.Msg = "获取失败"
  287. br.ErrMsg = "获取失败,Err:" + errList.Error()
  288. return
  289. }
  290. var isShow bool
  291. isShow = services.GetShowSustainable()
  292. detail, err := models.GetConfigByCode("city_img_url")
  293. if err != nil {
  294. br.Msg = "获取数据失败"
  295. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  296. return
  297. }
  298. detailChart, err := models.GetConfigByCode("chart_img_url")
  299. if err != nil {
  300. br.Msg = "获取数据失败"
  301. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  302. return
  303. }
  304. addressList := strings.Split(detail.ConfigValue, "{|}")
  305. mapAddress := make(map[string]string)
  306. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  307. mapChart := make(map[string]string)
  308. var cityName string
  309. var chartName string
  310. var imgUrl string
  311. var imgUrlChart string
  312. var mapActivityId []int
  313. for _, v := range addressList {
  314. vslice := strings.Split(v, "_")
  315. cityName = vslice[0]
  316. imgUrl = vslice[len(vslice)-1]
  317. mapAddress[cityName] = imgUrl
  318. }
  319. for _, v := range chartList {
  320. vslice := strings.Split(v, "_")
  321. chartName = vslice[0]
  322. imgUrlChart = vslice[len(vslice)-1]
  323. mapChart[chartName] = imgUrlChart
  324. }
  325. for k, v := range list {
  326. if strings.Contains(v.ActivityName, "【") {
  327. list[k].IsBrackets = 1
  328. }
  329. if v.SignupNum > v.LimitPeopleNum {
  330. list[k].SignupNum = v.LimitPeopleNum
  331. }
  332. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  333. list[k].IsShowSustainable = true
  334. }
  335. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  336. list[k].ActivityTypeName = "买方研选电话会"
  337. list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  338. }
  339. if v.ActivityType == 0 {
  340. if mapAddress[v.City] != "" {
  341. list[k].ImgUrl = mapAddress[v.City]
  342. } else {
  343. list[k].ImgUrl = mapAddress["其它"]
  344. }
  345. } else {
  346. if mapChart[v.ChartPermissionName] != "" {
  347. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  348. }
  349. }
  350. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  351. list[k].Expert = expertTxt
  352. mapActivityId = append(mapActivityId, v.ActivityId)
  353. }
  354. if keyWordSearch != "" {
  355. keyWordItem := new(models.CygxUserSearchKeyWord)
  356. keyWordItem.UserId = user.UserId
  357. keyWordItem.KeyWord = keyWordSearch
  358. keyWordItem.PageType = "ActivitSearch"
  359. keyWordItem.CreateTime = time.Now()
  360. go models.AddUserSearchKeyWord(keyWordItem)
  361. cacheKey := fmt.Sprint("Search_uid:", user.UserId, "_KeyWord:", keyWordSearch, "_Source:", 6)
  362. isExist := utils.Rc.IsExist(cacheKey)
  363. if !isExist {
  364. setNX := utils.Rc.SetNX(cacheKey, keyWordSearch, time.Minute*1)
  365. if !setNX {
  366. go utils.SendAlarmMsg("记录用户搜索活动关键词失败,设置Redis Key 过期时间失败:key"+cacheKey, 3)
  367. }
  368. go services.AddUserSearchLog(user, keyWordSearch, 6)
  369. }
  370. }
  371. resp := new(models.GetCygxActivityListRep)
  372. //处理音频回放
  373. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  374. if err != nil {
  375. br.Msg = "获取信息失败"
  376. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  377. }
  378. fmt.Println(mapActivityId)
  379. fmt.Println(mapActivityVoice)
  380. //处理列表的标签是否展示逻辑
  381. for k, v := range list {
  382. if mapActivityVoice[v.ActivityId] != nil {
  383. list[k].AudioLink = true
  384. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  385. }
  386. resp.List = append(resp.List, services.ActivityButtonShow(v))
  387. }
  388. page := paging.GetPaging(currentIndex, pageSize, total)
  389. resp.List = list
  390. resp.Paging = page
  391. br.Ret = 200
  392. br.Success = true
  393. br.Msg = "获取成功"
  394. br.Data = resp
  395. }
  396. // @Title 我的日程
  397. // @Description 我的日程列表接口
  398. // @Param PageSize query int true "每页数据条数"
  399. // @Param CurrentIndex query int true "当前页页码,从1开始"
  400. // @Param Source query int false "来源 0:手机 ,1:Pc 默认0"
  401. // @Success 200 {object} models.GetCygxActivityListRep
  402. // @router /scheduleList [get]
  403. func (this *ActivityCoAntroller) ScheduleList() {
  404. br := new(models.BaseResponse).Init()
  405. defer func() {
  406. this.Data["json"] = br
  407. this.ServeJSON()
  408. }()
  409. user := this.User
  410. if user == nil {
  411. br.Msg = "请登录"
  412. br.ErrMsg = "请登录,SysUser Is Empty"
  413. return
  414. }
  415. uid := user.UserId
  416. pageSize, _ := this.GetInt("PageSize")
  417. currentIndex, _ := this.GetInt("CurrentIndex")
  418. source, _ := this.GetInt("Source")
  419. var startSize int
  420. if pageSize <= 0 {
  421. pageSize = utils.PageSize20
  422. }
  423. if currentIndex <= 0 {
  424. currentIndex = 1
  425. }
  426. startSize = utils.StartIndex(currentIndex, pageSize)
  427. var condition string
  428. var conditionCount string
  429. var pars []interface{}
  430. condition += ` AND art.publish_status = 1 `
  431. if source == 1 {
  432. condition += ` AND art.yidong_activity_id = '' `
  433. conditionCount += ` AND art.yidong_activity_id = '' `
  434. }
  435. total, err := models.GetScheduleCount(conditionCount, uid)
  436. page := paging.GetPaging(currentIndex, pageSize, total)
  437. if err != nil {
  438. br.Msg = "获取失败"
  439. br.ErrMsg = "获取失败,Err:" + err.Error()
  440. return
  441. }
  442. conditionCount = ` AND art.active_state = 2 `
  443. totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
  444. if err != nil {
  445. br.Msg = "获取失败"
  446. br.ErrMsg = "获取失败,Err:" + err.Error()
  447. return
  448. }
  449. var list []*models.ActivityDetail
  450. //全部都是进行中的活动
  451. if totalCount > currentIndex*pageSize {
  452. condition += ` AND art.active_state IN(2) `
  453. if source == 1 {
  454. condition += ` AND art.yidong_activity_id = '' `
  455. }
  456. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  457. list = listHave
  458. if errList != nil {
  459. br.Msg = "获取失败"
  460. br.ErrMsg = "获取失败,Err:" + errList.Error()
  461. return
  462. }
  463. } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
  464. condition = ` AND art.publish_status = 1 AND art.active_state IN(2) `
  465. if source == 1 {
  466. condition += ` AND art.yidong_activity_id = '' `
  467. }
  468. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  469. list = listHave
  470. if errList != nil {
  471. br.Msg = "获取失败"
  472. br.ErrMsg = "获取失败,Err:" + errList.Error()
  473. return
  474. }
  475. pageSize = pageSize - len(listHave)
  476. condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) `
  477. if source == 1 {
  478. condition += ` AND art.yidong_activity_id = '' `
  479. }
  480. listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  481. if errList != nil {
  482. br.Msg = "获取失败"
  483. br.ErrMsg = "获取失败,Err:" + errList.Error()
  484. return
  485. }
  486. if len(listOther) > 0 {
  487. for _, v := range listOther {
  488. list = append(list, v)
  489. }
  490. }
  491. } else {
  492. condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
  493. listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  494. list = listOther
  495. if errList != nil {
  496. br.Msg = "获取失败"
  497. br.ErrMsg = "获取失败,Err:" + errList.Error()
  498. return
  499. }
  500. }
  501. var isShow bool
  502. isShow = services.GetShowSustainable()
  503. detail, err := models.GetConfigByCode("city_img_url")
  504. if err != nil {
  505. br.Msg = "获取数据失败"
  506. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  507. return
  508. }
  509. detailChart, err := models.GetConfigByCode("chart_img_url")
  510. if err != nil {
  511. br.Msg = "获取数据失败"
  512. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  513. return
  514. }
  515. addressList := strings.Split(detail.ConfigValue, "{|}")
  516. mapAddress := make(map[string]string)
  517. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  518. mapChart := make(map[string]string)
  519. var cityName string
  520. var chartName string
  521. var imgUrl string
  522. var imgUrlChart string
  523. var mapActivityId []int
  524. for _, v := range addressList {
  525. vslice := strings.Split(v, "_")
  526. cityName = vslice[0]
  527. imgUrl = vslice[len(vslice)-1]
  528. mapAddress[cityName] = imgUrl
  529. }
  530. for _, v := range chartList {
  531. vslice := strings.Split(v, "_")
  532. chartName = vslice[0]
  533. imgUrlChart = vslice[len(vslice)-1]
  534. mapChart[chartName] = imgUrlChart
  535. }
  536. for k, v := range list {
  537. if strings.Contains(v.ActivityName, "【") {
  538. list[k].IsBrackets = 1
  539. }
  540. if v.SignupNum > v.LimitPeopleNum {
  541. list[k].SignupNum = v.LimitPeopleNum
  542. }
  543. //是否展示限免标签
  544. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  545. list[k].IsShowSustainable = true
  546. }
  547. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  548. list[k].ActivityTypeName = "买方研选电话会"
  549. list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  550. }
  551. if v.ActivityType == 0 {
  552. if mapAddress[v.City] != "" {
  553. list[k].ImgUrl = mapAddress[v.City]
  554. } else {
  555. list[k].ImgUrl = mapAddress["其它"]
  556. }
  557. } else {
  558. if mapChart[v.ChartPermissionName] != "" {
  559. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  560. }
  561. }
  562. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  563. list[k].Expert = expertTxt
  564. if v.IsHideAppointment == 0 {
  565. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  566. }
  567. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  568. list[k].IsCClassMeeting = true
  569. }
  570. mapActivityId = append(mapActivityId, v.ActivityId)
  571. }
  572. //添加我的日程访问记录
  573. item := new(models.CygxPageHistoryRecord)
  574. item.UserId = user.UserId
  575. item.CreateTime = time.Now()
  576. item.Mobile = user.Mobile
  577. item.Email = user.Email
  578. item.CompanyId = user.CompanyId
  579. item.CompanyName = user.CompanyName
  580. item.PageType = "MySchedule"
  581. go models.AddCygxPageHistoryRecord(item)
  582. resp := new(models.GetCygxActivityListRep)
  583. //处理音频回放
  584. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  585. if err != nil {
  586. br.Msg = "获取信息失败"
  587. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  588. return
  589. }
  590. for k, v := range list {
  591. if mapActivityVoice[v.ActivityId] != nil {
  592. list[k].AudioLink = true
  593. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  594. }
  595. //处理列表的标签是否展示逻辑
  596. resp.List = append(resp.List, services.ActivityButtonShow(v))
  597. }
  598. resp.Paging = page
  599. br.Ret = 200
  600. br.Success = true
  601. br.Msg = "获取成功"
  602. br.Data = resp
  603. }
  604. // @Title 活动详情
  605. // @Description 获取活动详情接口
  606. // @Param ActivityId query int true "活动ID"
  607. // @Success Ret=200 {object} models.CygxActivityResp
  608. // @router /detail [get]
  609. func (this *ActivityCoAntroller) Detail() {
  610. br := new(models.BaseResponse).Init()
  611. defer func() {
  612. this.Data["json"] = br
  613. this.ServeJSON()
  614. }()
  615. user := this.User
  616. if user == nil {
  617. br.Msg = "请登录"
  618. br.ErrMsg = "请登录,用户信息为空"
  619. br.Ret = 408
  620. return
  621. }
  622. uid := user.UserId
  623. activityId, _ := this.GetInt("ActivityId")
  624. if activityId < 1 {
  625. br.Msg = "请输入活动ID"
  626. return
  627. }
  628. resp := new(models.CygxActivityResp)
  629. hasPermission := 0
  630. var companyDetailStatus string
  631. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  632. if err != nil && err.Error() != utils.ErrNoRow() {
  633. br.Msg = "获取信息失败"
  634. br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
  635. return
  636. }
  637. if activityInfo == nil {
  638. br.Msg = "活动不存在"
  639. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  640. return
  641. }
  642. if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  643. activityInfo.IsCClassMeeting = true
  644. }
  645. applyCount, err := models.GetApplyRecordCount(uid)
  646. if err != nil && err.Error() != utils.ErrNoRow() {
  647. br.Msg = "获取信息失败"
  648. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  649. return
  650. }
  651. //获取FICC销售信息 如果是FICC的客户类型,则默认他申请过
  652. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  653. if err != nil && err.Error() != utils.ErrNoRow() {
  654. br.Msg = "获取信息失败"
  655. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  656. return
  657. }
  658. if user.CompanyId <= 1 {
  659. companyDetailStatus = ""
  660. } else {
  661. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  662. if err != nil {
  663. br.Msg = "获取信息失败"
  664. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  665. return
  666. }
  667. if companyPermission == "" {
  668. if applyCount > 0 {
  669. hasPermission = 4
  670. } else {
  671. if sellerItem != nil {
  672. hasPermission = 5
  673. } else {
  674. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  675. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  676. if err != nil && err.Error() != utils.ErrNoRow() {
  677. br.Msg = "获取信息失败"
  678. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  679. return
  680. }
  681. if sellerItemQy != nil {
  682. hasPermission = 2
  683. resp.SellerMobile = sellerItemQy.Mobile
  684. resp.SellerName = sellerItemQy.RealName
  685. } else {
  686. hasPermission = 3
  687. }
  688. }
  689. }
  690. resp.HasPermission = hasPermission
  691. resp.OperationMode = "Apply"
  692. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  693. br.Ret = 200
  694. br.Success = true
  695. br.Msg = "获取成功"
  696. br.Data = resp
  697. return
  698. }
  699. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  700. if err != nil {
  701. br.Msg = "获取信息失败!"
  702. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  703. return
  704. }
  705. if companyDetail == nil {
  706. br.Msg = "获取信息失败!"
  707. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  708. return
  709. }
  710. companyDetailStatus = companyDetail.Status
  711. }
  712. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  713. if err != nil {
  714. br.Msg = "获取信息失败"
  715. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  716. return
  717. }
  718. if activityInfo.IsLimitPeople > 0 {
  719. noPower, err := services.GetShareNoPowe(activityInfo, permissionStr, userType)
  720. if err != nil {
  721. br.Msg = "获取信息失败"
  722. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  723. return
  724. }
  725. //获取用户的产业规模,判断是否允许可见
  726. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  727. if err != nil && err.Error() != utils.ErrNoRow() {
  728. br.Msg = "获取信息失败"
  729. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  730. return
  731. }
  732. if companyProduct != nil {
  733. if companyProduct.Scale != "" {
  734. if strings.Count(activityInfo.Scale, companyProduct.Scale) > 0 {
  735. noPower = false
  736. }
  737. }
  738. }
  739. if noPower {
  740. br.Msg = "您暂无查看该活动权限"
  741. br.ErrMsg = "被分享客户不可见,获取信息失败"
  742. return
  743. }
  744. }
  745. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  746. br.Msg = "您暂无查看该活动权限"
  747. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  748. return
  749. }
  750. detail, errDetail := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
  751. if errDetail != nil {
  752. br.Msg = "获取信息失败"
  753. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  754. return
  755. }
  756. if activityInfo.IsSignup > 0 {
  757. detail, errDetail := models.GetActivitySignupDetail(activityId, uid)
  758. if errDetail != nil {
  759. br.Msg = "获取信息失败"
  760. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  761. return
  762. }
  763. activityInfo.SignupType = detail.SignupType
  764. }
  765. activityInfo.ShowType = detail.ShowType
  766. //判断是否已经申请过
  767. if user.CompanyId > 1 {
  768. permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
  769. if err != nil {
  770. br.Msg = "获取信息失败"
  771. br.ErrMsg = "获取客户权限信息失败,Err:" + err.Error()
  772. return
  773. }
  774. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  775. //冻结客户
  776. if err != nil {
  777. if err.Error() == utils.ErrNoRow() {
  778. if applyCount > 0 {
  779. hasPermission = 4
  780. } else {
  781. if sellerItem != nil {
  782. hasPermission = 5
  783. } else {
  784. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  785. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  786. if err != nil && err.Error() != utils.ErrNoRow() {
  787. br.Msg = "获取信息失败"
  788. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  789. return
  790. }
  791. if sellerItemQy != nil {
  792. hasPermission = 2
  793. resp.SellerMobile = sellerItemQy.Mobile
  794. resp.SellerName = sellerItemQy.RealName
  795. } else {
  796. hasPermission = 3
  797. }
  798. }
  799. }
  800. resp.HasPermission = hasPermission
  801. resp.OperationMode = "Apply"
  802. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  803. br.Ret = 200
  804. br.Success = true
  805. br.Msg = "获取成功"
  806. br.Data = resp
  807. return
  808. } else {
  809. br.Msg = "获取信息失败"
  810. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  811. return
  812. }
  813. }
  814. havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
  815. if havePower {
  816. hasPermission = 1
  817. resp.HaqveJurisdiction = true
  818. } else {
  819. if permissionStr == "专家" {
  820. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  821. resp.MsgType = "Type"
  822. } else {
  823. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  824. resp.MsgType = "Industry"
  825. }
  826. if companyItem.ProductId == 2 {
  827. resp.SellerMobile = companyItem.Mobile
  828. resp.SellerName = companyItem.SellerName
  829. resp.OperationMode = "Call"
  830. hasPermission = 2
  831. } else {
  832. hasPermission = 5
  833. }
  834. }
  835. } else { //潜在客户
  836. if applyCount > 0 {
  837. hasPermission = 4
  838. } else {
  839. if sellerItem != nil {
  840. hasPermission = 5
  841. } else {
  842. hasPermission = 3
  843. }
  844. }
  845. resp.OperationMode = "Apply"
  846. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  847. }
  848. if hasPermission == 1 {
  849. //是否展示限免标签
  850. if services.GetShowSustainable() && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  851. activityInfo.IsShowSustainable = true
  852. }
  853. configCode := "description_of_research"
  854. detail, err := models.GetConfigByCode(configCode)
  855. if err != nil {
  856. br.Msg = "获取数据失败"
  857. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  858. return
  859. }
  860. activityInfo.Description = detail.ConfigValue
  861. if activityInfo.SignupNum > activityInfo.LimitPeopleNum {
  862. activityInfo.SignupNum = activityInfo.LimitPeopleNum
  863. }
  864. if activityInfo.ChartPermissionNames != "" {
  865. activityInfo.ChartPermissionName = activityInfo.ChartPermissionNames
  866. }
  867. if activityInfo.IsHideAppointment == 0 {
  868. activityInfo.IsShowAppointment = services.IsShowAppointment(activityInfo.ActivityTypeId, activityInfo.ChartPermissionName)
  869. }
  870. if activityInfo.ReportLink != "" {
  871. artList := strings.Split(activityInfo.ReportLink, "{|}")
  872. if len(artList) > 0 {
  873. for _, v := range artList {
  874. artitem := new(models.ActivityArticleResp)
  875. artitem.ReportLink = v
  876. artIdSlice := strings.Split(v, "/")
  877. if len(artIdSlice) > 0 {
  878. articleId, _ := strconv.Atoi(artIdSlice[len(artIdSlice)-1])
  879. artitem.ArticleId = articleId
  880. }
  881. activityInfo.ArticleList = append(activityInfo.ArticleList, artitem)
  882. }
  883. }
  884. } else {
  885. activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
  886. }
  887. activityInfo.ActivityTypeName = strings.Replace(activityInfo.ActivityTypeName, "(C类)", "", -1)
  888. //处理活动关联的产业
  889. industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId)
  890. if err != nil && err.Error() != utils.ErrNoRow() {
  891. br.Msg = "获取信息失败"
  892. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  893. return
  894. }
  895. if activityInfo.TemporaryLabel != "" {
  896. industrialList = make([]*models.IndustrialManagementRep, 0)
  897. item := new(models.IndustrialManagementRep)
  898. item.IndustryName = activityInfo.Label
  899. industrialList = append(industrialList, item)
  900. } else {
  901. industryIds := make([]int, 0)
  902. var industrialManagementId string
  903. for k, v := range industrialList {
  904. if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  905. industrialList[k].IsResearch = true
  906. }
  907. industryIds = append(industryIds, v.IndustrialManagementId)
  908. industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
  909. }
  910. // 查研观向7.4-行业新标签
  911. industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
  912. if e != nil {
  913. br.Msg = "获取信息失败"
  914. br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
  915. return
  916. }
  917. //判断产业下是否有关联的报告,并处理是否跳转
  918. industrialManagementId = strings.TrimRight(industrialManagementId, ",")
  919. if industrialManagementId != "" {
  920. var condition string
  921. condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
  922. listIndustrialGrop, err := models.GetSearchResourceList(condition)
  923. if err != nil && err.Error() != utils.ErrNoRow() {
  924. br.Msg = "获取信息失败"
  925. br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  926. return
  927. }
  928. mapIndustrial := make(map[int]int)
  929. if len(listIndustrialGrop) > 0 {
  930. for _, v := range listIndustrialGrop {
  931. mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId
  932. }
  933. }
  934. for k, v := range industrialList {
  935. if mapIndustrial[v.IndustrialManagementId] > 0 {
  936. industrialList[k].IsJump = true
  937. }
  938. industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
  939. }
  940. }
  941. }
  942. activityInfo.Listndustrial = industrialList
  943. if activityInfo.YidongActivityId != "" {
  944. ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  945. yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
  946. if err != nil {
  947. br.Msg = "获取信息失败"
  948. br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  949. return
  950. }
  951. //yidongKwy := activityInfo.YidongActivityUrl
  952. activityInfo.YidongActivityUrl = yidongLongLink + "?source=11&fromHz=true&tgc=" + ydTgc
  953. }
  954. //处理音频回放
  955. var mapActivityId []int
  956. mapActivityId = append(mapActivityId, activityId)
  957. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  958. if err != nil {
  959. br.Msg = "获取信息失败"
  960. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  961. return
  962. }
  963. if mapActivityVoice[activityId] != nil {
  964. activityInfo.AudioLink = true
  965. activityInfo.VoiceList = mapActivityVoice[activityId]
  966. }
  967. //处理按钮是否展示问题
  968. resp.Detail = services.ActivityButtonShow(activityInfo)
  969. }
  970. resp.HasPermission = hasPermission
  971. br.Ret = 200
  972. br.Success = true
  973. br.Msg = "获取成功"
  974. br.Data = resp
  975. }
  976. // @Title 活动报名
  977. // @Description 活动报名接口
  978. // @Param request body models.ActivitySingnupRep true "type json string"
  979. // @Success Ret=200 {object} models.SignupStatus
  980. // @router /signup/add [post]
  981. func (this *ActivityCoAntroller) SignupAdd() {
  982. br := new(models.BaseResponse).Init()
  983. defer func() {
  984. this.Data["json"] = br
  985. this.ServeJSON()
  986. }()
  987. user := this.User
  988. if user == nil {
  989. br.Msg = "请登录"
  990. br.ErrMsg = "请登录,用户信息为空"
  991. br.Ret = 408
  992. return
  993. }
  994. uid := user.UserId
  995. signupStatus := ""
  996. var req models.ActivitySingnupRep
  997. resp := new(models.SignupStatus)
  998. var total int
  999. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1000. if err != nil {
  1001. br.Msg = "参数解析异常!"
  1002. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1003. return
  1004. }
  1005. activityId := req.ActivityId
  1006. signupType := req.SignupType
  1007. hasPermission := 0
  1008. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1009. resp.GoBindEmail = true
  1010. }
  1011. //判断是否已经申请过
  1012. applyCount, err := models.GetApplyRecordCount(uid)
  1013. if err != nil && err.Error() != utils.ErrNoRow() {
  1014. br.Msg = "获取信息失败"
  1015. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1016. return
  1017. }
  1018. //获取FICC销售信息
  1019. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  1020. if err != nil && err.Error() != utils.ErrNoRow() {
  1021. br.Msg = "申请失败"
  1022. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1023. return
  1024. }
  1025. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1026. if activityInfo == nil {
  1027. br.Msg = "操作失败"
  1028. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1029. return
  1030. }
  1031. if errInfo != nil {
  1032. br.Msg = "操作失败"
  1033. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1034. return
  1035. }
  1036. //SignupStatus "报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1037. //HasPermission "1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
  1038. var companyDetailStatus string
  1039. if user.CompanyId <= 1 {
  1040. companyDetailStatus = ""
  1041. } else {
  1042. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1043. if err != nil {
  1044. br.Msg = "获取信息失败"
  1045. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1046. return
  1047. }
  1048. if companyPermission == "" {
  1049. if applyCount > 0 {
  1050. hasPermission = 4
  1051. } else {
  1052. if sellerItem != nil {
  1053. hasPermission = 5
  1054. } else {
  1055. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  1056. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1057. if err != nil && err.Error() != utils.ErrNoRow() {
  1058. br.Msg = "获取信息失败"
  1059. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1060. return
  1061. }
  1062. if sellerItemQy != nil {
  1063. hasPermission = 2
  1064. resp.SellerMobile = sellerItemQy.Mobile
  1065. resp.SellerName = sellerItemQy.RealName
  1066. } else {
  1067. hasPermission = 3
  1068. }
  1069. }
  1070. }
  1071. resp.HasPermission = hasPermission
  1072. resp.ActivityId = activityId
  1073. resp.OperationMode = "Apply"
  1074. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  1075. br.Ret = 200
  1076. br.Success = true
  1077. br.Msg = "获取成功"
  1078. br.Data = resp
  1079. return
  1080. }
  1081. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1082. if err != nil {
  1083. br.Msg = "获取信息失败!"
  1084. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1085. return
  1086. }
  1087. if companyDetail == nil {
  1088. br.Msg = "获取信息失败!"
  1089. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  1090. return
  1091. }
  1092. companyDetailStatus = companyDetail.Status
  1093. }
  1094. var userType int
  1095. var permissionStr string
  1096. userType, permissionStr, err = services.GetUserType(user.CompanyId)
  1097. if err != nil {
  1098. br.Msg = "获取信息失败!"
  1099. br.ErrMsg = "获取失败,Err:" + err.Error()
  1100. return
  1101. }
  1102. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  1103. br.Msg = "您暂无查看该活动权限"
  1104. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  1105. return
  1106. }
  1107. item := new(models.CygxActivitySignup)
  1108. if user.CompanyId > 1 {
  1109. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  1110. //冻结客户
  1111. if err != nil {
  1112. if err.Error() == utils.ErrNoRow() {
  1113. if applyCount > 0 {
  1114. hasPermission = 4
  1115. } else {
  1116. if sellerItem != nil {
  1117. hasPermission = 5
  1118. } else {
  1119. hasPermission = 3
  1120. }
  1121. }
  1122. resp.ActivityId = activityId
  1123. resp.HasPermission = hasPermission
  1124. resp.OperationMode = "Apply"
  1125. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  1126. br.Ret = 200
  1127. br.Success = true
  1128. br.Msg = "获取成功"
  1129. br.Data = resp
  1130. return
  1131. } else {
  1132. br.Msg = "获取信息失败"
  1133. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  1134. return
  1135. }
  1136. }
  1137. //1专家电话会、2分析师电话会、3公司调研电话会、4公司线下调研、5专家线下沙龙、6分析师线下沙龙
  1138. //OperationMode string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`
  1139. havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
  1140. if err != nil {
  1141. br.Msg = "获取信息失败!"
  1142. br.ErrMsg = "获取失败,Err:" + err.Error()
  1143. return
  1144. }
  1145. if havePower {
  1146. hasPermission = 1
  1147. signupStatus = "Success"
  1148. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1149. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1150. signupStatus = "Overtime"
  1151. resp.SignupType = signupType
  1152. resp.SignupStatus = signupStatus
  1153. resp.HasPermission = hasPermission
  1154. br.Ret = 200
  1155. br.Success = true
  1156. br.Msg = ""
  1157. br.Data = resp
  1158. return
  1159. }
  1160. var sellerName string
  1161. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1162. if err != nil {
  1163. br.Msg = "报名失败!"
  1164. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1165. return
  1166. }
  1167. //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1168. //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
  1169. //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
  1170. if activityInfo.IsLimitPeople == 1 {
  1171. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  1172. totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
  1173. if err != nil {
  1174. br.Msg = "获取信息失败"
  1175. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1176. return
  1177. }
  1178. if totalRestrict >= 1 {
  1179. signupStatus = "BreakPromise"
  1180. item.FailType = 3
  1181. }
  1182. totalSignupCompany, err := models.GetActivitySignupCompanyCount(activityId, user.CompanyId)
  1183. if err != nil {
  1184. br.Msg = "获取信息失败"
  1185. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1186. return
  1187. }
  1188. if totalSignupCompany >= 2 {
  1189. signupStatus = "TwoPeople"
  1190. item.FailType = 2
  1191. }
  1192. totaSignupPeopleNum, err := models.GetActivitySignupSuccessCount(activityId)
  1193. if err != nil {
  1194. br.Msg = "获取信息失败"
  1195. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1196. return
  1197. }
  1198. if totaSignupPeopleNum >= activityInfo.LimitPeopleNum {
  1199. signupStatus = "FullStarffed"
  1200. item.FailType = 1
  1201. }
  1202. totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
  1203. if err != nil {
  1204. br.Msg = "获取失败"
  1205. br.ErrMsg = "获取失败,Err:" + err.Error()
  1206. return
  1207. }
  1208. //解除报名限制之后二次报名相同活动
  1209. if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
  1210. item.UserId = uid
  1211. item.RealName = user.RealName
  1212. item.SellerName = sellerName
  1213. item.ActivityId = activityId
  1214. item.CreateTime = time.Now()
  1215. item.Mobile = user.Mobile
  1216. item.Email = user.Email
  1217. item.CompanyId = user.CompanyId
  1218. item.CompanyName = user.CompanyName
  1219. item.SignupType = signupType
  1220. item.FailType = 0
  1221. item.DoFailType = 0
  1222. _, errSignup := models.AddActivitySignupByRestrict(item)
  1223. if errSignup != nil {
  1224. br.Msg = "操作失败"
  1225. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1226. return
  1227. }
  1228. resp.HaqveJurisdiction = true
  1229. resp.SignupType = signupType
  1230. resp.SignupStatus = "Success"
  1231. resp.HasPermission = hasPermission
  1232. resp.ActivityId = activityId
  1233. total, err = models.GetUserMeetingReminderCount(user.UserId)
  1234. if err != nil {
  1235. br.Msg = "获取信息失败"
  1236. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1237. return
  1238. }
  1239. if total == 0 {
  1240. resp.GoFollow = true
  1241. }
  1242. br.Ret = 200
  1243. br.Success = true
  1244. br.Msg = "操作成功"
  1245. br.Data = resp
  1246. return
  1247. }
  1248. totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
  1249. if err != nil {
  1250. br.Msg = "获取失败"
  1251. br.ErrMsg = "获取失败,Err:" + err.Error()
  1252. return
  1253. }
  1254. if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
  1255. item.UserId = uid
  1256. item.RealName = user.RealName
  1257. item.SellerName = sellerName
  1258. item.ActivityId = activityId
  1259. item.CreateTime = time.Now()
  1260. item.Mobile = user.Mobile
  1261. item.Email = user.Email
  1262. item.CompanyId = user.CompanyId
  1263. item.CompanyName = user.CompanyName
  1264. item.SignupType = signupType
  1265. item.DoFailType = item.FailType
  1266. if user.OutboundMobile != "" {
  1267. item.OutboundMobile = user.OutboundMobile
  1268. if user.OutboundCountryCode == "" {
  1269. item.CountryCode = "86"
  1270. } else {
  1271. item.CountryCode = user.OutboundCountryCode
  1272. }
  1273. } else {
  1274. item.OutboundMobile = user.Mobile
  1275. if user.CountryCode == "" {
  1276. item.CountryCode = "86"
  1277. } else {
  1278. item.CountryCode = user.CountryCode
  1279. }
  1280. }
  1281. //添加报名信息,但是不加入日程
  1282. _, errSignup := models.AddActivitySignupNoSchedule(item)
  1283. if errSignup != nil {
  1284. br.Msg = "操作失败"
  1285. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1286. return
  1287. }
  1288. }
  1289. }
  1290. totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
  1291. if err != nil {
  1292. br.Msg = "获取失败"
  1293. br.ErrMsg = "获取失败,Err:" + err.Error()
  1294. return
  1295. }
  1296. if totalMySuccess > 0 {
  1297. br.Msg = "您已报名这个活动"
  1298. return
  1299. }
  1300. if signupStatus == "Success" && resp.GoBindEmail != true {
  1301. item.UserId = uid
  1302. item.RealName = user.RealName
  1303. item.SellerName = sellerName
  1304. item.ActivityId = activityId
  1305. item.CreateTime = time.Now()
  1306. item.Mobile = user.Mobile
  1307. item.Email = user.Email
  1308. item.CompanyId = user.CompanyId
  1309. item.CompanyName = user.CompanyName
  1310. item.SignupType = signupType
  1311. item.FailType = 0
  1312. item.DoFailType = 0
  1313. item.OutboundMobile = user.Mobile
  1314. if user.OutboundMobile != "" {
  1315. item.OutboundMobile = user.OutboundMobile
  1316. if user.OutboundCountryCode == "" {
  1317. item.CountryCode = "86"
  1318. } else {
  1319. item.CountryCode = user.OutboundCountryCode
  1320. }
  1321. } else {
  1322. item.OutboundMobile = user.Mobile
  1323. if user.CountryCode == "" {
  1324. item.CountryCode = "86"
  1325. } else {
  1326. item.CountryCode = user.CountryCode
  1327. }
  1328. }
  1329. _, errSignup := models.AddActivitySignup(item)
  1330. if errSignup != nil {
  1331. br.Msg = "操作失败"
  1332. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1333. return
  1334. }
  1335. resp.HaqveJurisdiction = true
  1336. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1337. if signupType == 1 {
  1338. go services.ActivityUserRemind(user, activityInfo, 1)
  1339. } else {
  1340. go services.ActivityUserRemind(user, activityInfo, 4)
  1341. }
  1342. }
  1343. } else {
  1344. if companyItem.ProductId == 2 {
  1345. hasPermission = 2
  1346. resp.SellerMobile = companyItem.Mobile
  1347. resp.SellerName = companyItem.SellerName
  1348. resp.MsgType = "Type"
  1349. resp.OperationMode = "Call"
  1350. if permissionStr == "专家" {
  1351. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  1352. resp.MsgType = "Type"
  1353. } else {
  1354. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  1355. resp.MsgType = "Industry"
  1356. }
  1357. } else {
  1358. hasPermission = 5
  1359. }
  1360. }
  1361. } else { //潜在客户
  1362. if applyCount > 0 {
  1363. hasPermission = 4
  1364. } else {
  1365. if sellerItem != nil {
  1366. hasPermission = 5
  1367. } else {
  1368. hasPermission = 3
  1369. }
  1370. }
  1371. resp.OperationMode = "Apply"
  1372. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  1373. }
  1374. if signupType == 1 && user.IsMsgOutboundMobile == 0 {
  1375. resp.GoOutboundMobile = true
  1376. if user.Mobile != "" || user.OutboundMobile != "" {
  1377. go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
  1378. }
  1379. }
  1380. if user.OutboundMobile == "" {
  1381. resp.Mobile = user.Mobile
  1382. if user.CountryCode == "" && len(user.Mobile) == 11 {
  1383. resp.CountryCode = "86"
  1384. } else {
  1385. resp.CountryCode = user.CountryCode
  1386. }
  1387. } else {
  1388. resp.Mobile = user.OutboundMobile
  1389. resp.CountryCode = user.OutboundCountryCode
  1390. }
  1391. //如果用户有绑定手机号,但是没有绑定外呼手机号
  1392. if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
  1393. var countryCode string
  1394. if len(user.Mobile) == 8 {
  1395. countryCode = "852"
  1396. } else if len(user.Mobile) == 9 {
  1397. countryCode = "886"
  1398. } else if len(user.Mobile) == 10 {
  1399. countryCode = "1"
  1400. } else if len(user.Mobile) >= 11 {
  1401. countryCode = "86"
  1402. }
  1403. models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
  1404. }
  1405. resp.SignupType = signupType
  1406. resp.SignupStatus = signupStatus
  1407. resp.HasPermission = hasPermission
  1408. //if signupStatus == "Success" {
  1409. resp.ActivityId = activityId
  1410. //}
  1411. total, err = models.GetUserSignupCount(user.UserId)
  1412. if err != nil {
  1413. br.Msg = "获取信息失败"
  1414. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1415. return
  1416. }
  1417. if total <= 1 {
  1418. resp.GoFollow = true
  1419. }
  1420. br.Ret = 200
  1421. br.Success = true
  1422. br.Msg = "操作成功"
  1423. br.Data = resp
  1424. }
  1425. // @Title 活动取消报名
  1426. // @Description 活动取消报名接口
  1427. // @Param request body models.ActivitySingnupRep true "type json string"
  1428. // @Success Ret=200 {object} models.SignupStatus
  1429. // @router /signup/cancel [post]
  1430. func (this *ActivityCoAntroller) SignupCancel() {
  1431. br := new(models.BaseResponse).Init()
  1432. defer func() {
  1433. this.Data["json"] = br
  1434. this.ServeJSON()
  1435. }()
  1436. user := this.User
  1437. if user == nil {
  1438. br.Msg = "请登录"
  1439. br.ErrMsg = "请登录,用户信息为空"
  1440. br.Ret = 408
  1441. return
  1442. }
  1443. uid := user.UserId
  1444. var req models.ActivitySingnupRep
  1445. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1446. if err != nil {
  1447. br.Msg = "参数解析异常!"
  1448. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1449. return
  1450. }
  1451. activityId := req.ActivityId
  1452. signupType := req.SignupType
  1453. item := new(models.CygxActivitySignup)
  1454. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1455. if activityInfo == nil {
  1456. br.Msg = "操作失败"
  1457. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1458. return
  1459. }
  1460. if errInfo != nil {
  1461. br.Msg = "操作失败"
  1462. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1463. return
  1464. }
  1465. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1466. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1467. if signupType == 1 {
  1468. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  1469. } else {
  1470. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  1471. }
  1472. return
  1473. }
  1474. total, err := models.GetActivitySignupCount(uid, activityId)
  1475. if err != nil {
  1476. br.Msg = "获取失败"
  1477. br.ErrMsg = "获取失败,Err:" + err.Error()
  1478. return
  1479. }
  1480. if total == 0 {
  1481. br.Msg = "您暂未报名这个活动"
  1482. return
  1483. }
  1484. item.UserId = uid
  1485. item.ActivityId = activityId
  1486. item.CreateTime = time.Now()
  1487. item.Mobile = user.Mobile
  1488. item.Email = user.Email
  1489. item.CompanyId = user.CompanyId
  1490. item.CompanyName = user.CompanyName
  1491. resp := new(models.SignupStatus)
  1492. resp.ActivityId = activityId
  1493. _, errSignup := models.CancelActivitySignup(item)
  1494. if errSignup != nil {
  1495. br.Msg = "操作失败"
  1496. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1497. return
  1498. }
  1499. br.Ret = 200
  1500. br.Success = true
  1501. br.Msg = "操作成功"
  1502. br.Data = resp
  1503. }
  1504. // @Title 用户搜索详情
  1505. // @Description 获取用户搜索详情接口
  1506. // @Param IsShowJurisdiction query int true "是否仅展示有权限的,默认为0,1是,2否 "
  1507. // @Success Ret=200 {object} models.ActivityUserSearchContentList
  1508. // @router /getUserSearchContent [get]
  1509. func (this *ActivityCoAntroller) GetUserSearchContent() {
  1510. br := new(models.BaseResponse).Init()
  1511. defer func() {
  1512. this.Data["json"] = br
  1513. this.ServeJSON()
  1514. }()
  1515. user := this.User
  1516. if user == nil {
  1517. br.Msg = "请登录"
  1518. br.ErrMsg = "请登录,用户信息为空"
  1519. br.Ret = 408
  1520. return
  1521. }
  1522. uid := user.UserId
  1523. detailSeearch := new(models.CygxActivityUserSearchContent)
  1524. detailSeearch.IsShowJurisdiction = 0
  1525. detailSeearch.ChartPermissionids = ""
  1526. detailSeearch.ActiveState = ""
  1527. resp := new(models.ActivityUserSearchContentList)
  1528. detail, _ := models.GetUserSearchContentByUid(uid)
  1529. if detail == nil {
  1530. detail = detailSeearch
  1531. }
  1532. isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
  1533. listActivityType, errActivityType := models.GetActivityTypeList()
  1534. if errActivityType != nil {
  1535. br.Msg = "获取失败"
  1536. br.ErrMsg = "获取数据失败,Err:" + errActivityType.Error()
  1537. return
  1538. }
  1539. var listChartPermissionid []*models.ActivityChartPermission
  1540. var errChart error
  1541. if isShowJurisdiction == 1 {
  1542. listChartPermissionidAll, errChartAll := models.GetUserCompanyPermission(user.CompanyId)
  1543. listChartPermissionid = listChartPermissionidAll
  1544. errChart = errChartAll
  1545. } else if isShowJurisdiction == 2 {
  1546. listChartPermissionidAll, errChartAll := models.GetChartPermissionActivity()
  1547. listChartPermissionid = listChartPermissionidAll
  1548. errChart = errChartAll
  1549. } else {
  1550. if detail.IsShowJurisdiction == 1 {
  1551. listChartPermissionidAll, errChartAll := models.GetUserCompanyPermission(user.CompanyId)
  1552. listChartPermissionid = listChartPermissionidAll
  1553. errChart = errChartAll
  1554. } else {
  1555. listChartPermissionidAll, errChartAll := models.GetChartPermissionActivity()
  1556. listChartPermissionid = listChartPermissionidAll
  1557. errChart = errChartAll
  1558. }
  1559. }
  1560. if errChart != nil {
  1561. br.Msg = "获取信息失败"
  1562. br.ErrMsg = "获取品种信息失败,Err:" + errChart.Error()
  1563. return
  1564. }
  1565. if detail.IsShowJurisdiction == 1 {
  1566. resp.IsShowJurisdiction = true
  1567. }
  1568. if isShowJurisdiction == 1 || detail.IsShowJurisdiction == 1 {
  1569. resp.IsShowJurisdiction = true
  1570. for k, _ := range listChartPermissionid {
  1571. listChartPermissionid[k].IsChoose = true
  1572. }
  1573. }
  1574. if isShowJurisdiction == 2 {
  1575. resp.IsShowJurisdiction = false
  1576. }
  1577. activeStateList := []models.ActivityStaus{models.ActivityStaus{Id: 1, StatusName: "未开始", IsChoose: true}, models.ActivityStaus{Id: 2, StatusName: "进行中"}, models.ActivityStaus{Id: 3, StatusName: "已结束"}}
  1578. list2, err := models.GetChartPermissionActivity()
  1579. if err != nil {
  1580. br.Msg = "获取信息失败"
  1581. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1582. return
  1583. }
  1584. if activeStateList[1].IsChoose == activeStateList[2].IsChoose == false {
  1585. activeStateList[0].IsChoose = true
  1586. }
  1587. var userType int
  1588. userType, _, err = services.GetUserType(user.CompanyId)
  1589. if err != nil {
  1590. br.Msg = "获取信息失败!"
  1591. br.ErrMsg = "获取失败,Err:" + err.Error()
  1592. return
  1593. }
  1594. var listChartPermissionidNew2 []*models.ActivityChartPermission
  1595. for _, v := range list2 {
  1596. if userType == 1 {
  1597. //if v.PermissionName != "研选" {
  1598. if !strings.Contains(v.PermissionName, "研选") {
  1599. listChartPermissionidNew2 = append(listChartPermissionidNew2, v)
  1600. }
  1601. } else {
  1602. listChartPermissionidNew2 = append(listChartPermissionidNew2, v)
  1603. }
  1604. }
  1605. resp.ListChartPermission2 = listChartPermissionidNew2
  1606. var listChartPermissionidNew []*models.ActivityChartPermission
  1607. for _, v := range listChartPermissionid {
  1608. if userType == 1 {
  1609. if !strings.Contains(v.PermissionName, "研选") {
  1610. listChartPermissionidNew = append(listChartPermissionidNew, v)
  1611. }
  1612. } else {
  1613. listChartPermissionidNew = append(listChartPermissionidNew, v)
  1614. }
  1615. }
  1616. resp.ListActivityType = listActivityType
  1617. resp.ListChartPermission = listChartPermissionidNew
  1618. resp.ListActivityStaus = activeStateList
  1619. br.Ret = 200
  1620. br.Success = true
  1621. br.Msg = "获取成功"
  1622. br.Data = resp
  1623. }
  1624. // @Title 添加会议提醒
  1625. // @Description 添加会议提醒接口
  1626. // @Param request body models.ActivityIdRep true "type json string"
  1627. // @Success Ret=200 {object} models.SignupStatus
  1628. // @router /meetingReminder/add [post]
  1629. func (this *ActivityCoAntroller) MeetingReminderAdd() {
  1630. br := new(models.BaseResponse).Init()
  1631. defer func() {
  1632. this.Data["json"] = br
  1633. this.ServeJSON()
  1634. }()
  1635. user := this.User
  1636. if user == nil {
  1637. br.Msg = "请登录"
  1638. br.ErrMsg = "请登录,用户信息为空"
  1639. br.Ret = 408
  1640. return
  1641. }
  1642. uid := user.UserId
  1643. //var signupStatus string
  1644. signupStatus := "Success"
  1645. var req models.ActivityIdRep
  1646. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1647. if err != nil {
  1648. br.Msg = "参数解析异常!"
  1649. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1650. return
  1651. }
  1652. activityId := req.ActivityId
  1653. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1654. if activityInfo == nil {
  1655. br.Msg = "操作失败"
  1656. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1657. return
  1658. }
  1659. if errInfo != nil {
  1660. br.Msg = "操作失败"
  1661. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1662. return
  1663. }
  1664. //判断是否已经申请过
  1665. applyCount, err := models.GetApplyRecordCount(uid)
  1666. if err != nil && err.Error() != utils.ErrNoRow() {
  1667. br.Msg = "获取信息失败"
  1668. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1669. return
  1670. }
  1671. //获取销售信息
  1672. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  1673. if err != nil && err.Error() != utils.ErrNoRow() {
  1674. br.Msg = "申请失败"
  1675. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1676. return
  1677. }
  1678. //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1679. item := new(models.CygxActivityMeetingReminder)
  1680. resp := new(models.SignupStatus)
  1681. hasPermission := 0
  1682. var companyDetailStatus string
  1683. if user.CompanyId <= 1 {
  1684. companyDetailStatus = ""
  1685. } else {
  1686. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1687. if err != nil {
  1688. br.Msg = "获取信息失败"
  1689. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1690. return
  1691. }
  1692. if companyPermission == "" {
  1693. if applyCount > 0 {
  1694. hasPermission = 4
  1695. } else {
  1696. if sellerItem != nil {
  1697. hasPermission = 5
  1698. } else {
  1699. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  1700. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1701. if err != nil && err.Error() != utils.ErrNoRow() {
  1702. br.Msg = "获取信息失败"
  1703. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1704. return
  1705. }
  1706. if sellerItemQy != nil {
  1707. hasPermission = 2
  1708. resp.SellerMobile = sellerItemQy.Mobile
  1709. resp.SellerName = sellerItemQy.RealName
  1710. } else {
  1711. hasPermission = 3
  1712. }
  1713. }
  1714. }
  1715. resp.ActivityId = activityId
  1716. resp.HasPermission = hasPermission
  1717. resp.OperationMode = "Apply"
  1718. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  1719. br.Ret = 200
  1720. br.Success = true
  1721. br.Msg = "获取成功"
  1722. br.Data = resp
  1723. return
  1724. }
  1725. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1726. if err != nil {
  1727. br.Msg = "获取信息失败!"
  1728. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1729. return
  1730. }
  1731. if companyDetail == nil {
  1732. br.Msg = "获取信息失败!"
  1733. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  1734. return
  1735. }
  1736. companyDetailStatus = companyDetail.Status
  1737. }
  1738. var userType int
  1739. var permissionStr string
  1740. userType, permissionStr, err = services.GetUserType(user.CompanyId)
  1741. if err != nil {
  1742. br.Msg = "获取信息失败!"
  1743. br.ErrMsg = "获取失败,Err:" + err.Error()
  1744. return
  1745. }
  1746. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  1747. br.Msg = "您暂无查看该活动权限"
  1748. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  1749. return
  1750. }
  1751. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1752. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1753. br.Msg = "活动开始前15分钟无法设置会议提醒"
  1754. return
  1755. }
  1756. if user.CompanyId > 1 {
  1757. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  1758. //冻结客户
  1759. if err != nil {
  1760. if err.Error() == utils.ErrNoRow() {
  1761. //如果是FICC的客户类型,则默认他申请过
  1762. if applyCount > 0 {
  1763. hasPermission = 4
  1764. } else {
  1765. if sellerItem != nil {
  1766. hasPermission = 5
  1767. } else {
  1768. hasPermission = 3
  1769. }
  1770. }
  1771. resp.ActivityId = activityId
  1772. resp.HasPermission = hasPermission
  1773. resp.OperationMode = "Apply"
  1774. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  1775. br.Ret = 200
  1776. br.Success = true
  1777. br.Msg = "获取成功"
  1778. br.Data = resp
  1779. return
  1780. } else {
  1781. br.Msg = "获取信息失败"
  1782. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  1783. return
  1784. }
  1785. }
  1786. havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
  1787. if err != nil {
  1788. br.Msg = "获取信息失败!"
  1789. br.ErrMsg = "获取失败,Err:" + err.Error()
  1790. return
  1791. }
  1792. if havePower {
  1793. hasPermission = 1
  1794. signupStatus = "Success"
  1795. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1796. if errMeeting != nil {
  1797. br.Msg = "获取失败"
  1798. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1799. return
  1800. }
  1801. if totalMeeting > 0 {
  1802. br.Msg = "您已预约,请勿重复预约"
  1803. return
  1804. }
  1805. item.UserId = uid
  1806. item.ActivityId = activityId
  1807. item.CreateTime = time.Now()
  1808. item.Mobile = user.Mobile
  1809. item.Email = user.Email
  1810. item.CompanyId = user.CompanyId
  1811. item.CompanyName = user.CompanyName
  1812. _, errSignup := models.AddActivityMeetingReminder(item)
  1813. if errSignup != nil {
  1814. br.Msg = "操作失败"
  1815. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1816. return
  1817. }
  1818. resp.HaqveJurisdiction = true
  1819. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1820. go services.ActivityUserRemind(user, activityInfo, 2)
  1821. } else {
  1822. if companyItem.ProductId == 2 {
  1823. hasPermission = 2
  1824. resp.SellerMobile = companyItem.Mobile
  1825. resp.SellerName = companyItem.SellerName
  1826. resp.MsgType = "Type"
  1827. resp.OperationMode = "Call"
  1828. if permissionStr == "专家" {
  1829. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  1830. resp.MsgType = "Type"
  1831. } else {
  1832. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  1833. resp.MsgType = "Industry"
  1834. }
  1835. } else {
  1836. hasPermission = 5
  1837. }
  1838. }
  1839. } else { //潜在客户
  1840. if applyCount > 0 {
  1841. hasPermission = 4
  1842. } else {
  1843. if sellerItem != nil {
  1844. hasPermission = 5
  1845. } else {
  1846. hasPermission = 3
  1847. }
  1848. }
  1849. resp.OperationMode = "Apply"
  1850. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  1851. }
  1852. resp.HasPermission = hasPermission
  1853. resp.SignupStatus = signupStatus
  1854. resp.ActivityId = activityId
  1855. var total int
  1856. total, err = models.GetUserActivityMeetingReminderCount(user.UserId)
  1857. if err != nil {
  1858. br.Msg = "获取信息失败"
  1859. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1860. return
  1861. }
  1862. if total <= 1 {
  1863. resp.GoFollow = true
  1864. }
  1865. br.Ret = 200
  1866. br.Success = true
  1867. if hasPermission == 1 {
  1868. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1869. }
  1870. br.Data = resp
  1871. }
  1872. // @Title 取消会议提醒
  1873. // @Description 取消会议提醒接口
  1874. // @Param request body models.ActivityIdRep true "type json string"
  1875. // @Success Ret=200 {object} models.SignupStatus
  1876. // @router /meetingReminder/cancel [post]
  1877. func (this *ActivityCoAntroller) MeetingReminderCancel() {
  1878. br := new(models.BaseResponse).Init()
  1879. defer func() {
  1880. this.Data["json"] = br
  1881. this.ServeJSON()
  1882. }()
  1883. user := this.User
  1884. if user == nil {
  1885. br.Msg = "请登录"
  1886. br.ErrMsg = "请登录,用户信息为空"
  1887. br.Ret = 408
  1888. return
  1889. }
  1890. uid := user.UserId
  1891. var req models.ActivityIdRep
  1892. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1893. if err != nil {
  1894. br.Msg = "参数解析异常!"
  1895. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1896. return
  1897. }
  1898. activityId := req.ActivityId
  1899. signupStatus := "Success"
  1900. item := new(models.CygxActivityMeetingReminder)
  1901. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1902. if activityInfo == nil {
  1903. br.Msg = "操作失败"
  1904. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1905. return
  1906. }
  1907. if errInfo != nil {
  1908. br.Msg = "操作失败"
  1909. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1910. return
  1911. }
  1912. //if signupStatus == "Success" {
  1913. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  1914. if err != nil {
  1915. br.Msg = "获取失败"
  1916. br.ErrMsg = "获取失败,Err:" + err.Error()
  1917. return
  1918. }
  1919. if total == 0 {
  1920. br.Msg = "您暂未添加该活动会议提醒"
  1921. return
  1922. }
  1923. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1924. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1925. br.Msg = "活动开始前15分钟无法取消会议提醒"
  1926. return
  1927. }
  1928. item.UserId = uid
  1929. item.ActivityId = activityId
  1930. item.CreateTime = time.Now()
  1931. item.Mobile = user.Mobile
  1932. item.Email = user.Email
  1933. item.CompanyId = user.CompanyId
  1934. item.CompanyName = user.CompanyName
  1935. _, errSignup := models.CancelActivityMeetingReminder(item)
  1936. if errSignup != nil {
  1937. br.Msg = "操作失败"
  1938. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1939. return
  1940. }
  1941. //}
  1942. resp := new(models.SignupStatus)
  1943. resp.SignupStatus = signupStatus
  1944. resp.ActivityId = activityId
  1945. br.Ret = 200
  1946. br.Success = true
  1947. br.Msg = "会议提醒已取消"
  1948. br.Data = resp
  1949. }
  1950. // @Title 敏捷搜索关键词的列表
  1951. // @Description 获取敏捷搜索关键词的列表接口
  1952. // @Success 200 {object} models.ActivityFastsearchKeywordsListResp
  1953. // @router /fastSearchKeWord [get]
  1954. func (this *ActivityABaseController) FastSearch() {
  1955. br := new(models.BaseResponse).Init()
  1956. defer func() {
  1957. this.Data["json"] = br
  1958. this.ServeJSON()
  1959. }()
  1960. resp := new(models.ActivityFastsearchKeywordsListResp)
  1961. list, err := models.GetActivityFastsearchKeywordsList()
  1962. if err != nil {
  1963. br.Msg = "获取失败"
  1964. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1965. return
  1966. }
  1967. resp.List = list
  1968. br.Ret = 200
  1969. br.Success = true
  1970. br.Msg = "获取成功"
  1971. br.Data = resp
  1972. }
  1973. // @Title 主题列表
  1974. // @Description 获取活动主题列表接口
  1975. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  1976. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  1977. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  1978. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  1979. // @Param Label query string false "搜索主题 多个用 , 隔开 (空为活动主题,非空为更多主题)"
  1980. // @Success 200 {object} models.GetCygxActivityLabelListRep
  1981. // @router /labelList_deltest [get]
  1982. func (this *ActivityCoAntroller) LabelList() {
  1983. br := new(models.BaseResponse).Init()
  1984. defer func() {
  1985. this.Data["json"] = br
  1986. this.ServeJSON()
  1987. }()
  1988. user := this.User
  1989. if user == nil {
  1990. br.Msg = "请登录"
  1991. br.ErrMsg = "请登录,SysUser Is Empty"
  1992. return
  1993. }
  1994. pageSize, _ := this.GetInt("PageSize")
  1995. chartPermissionIds := this.GetString("ChartPermissionIds")
  1996. activityTypeIds := this.GetString("ActivityTypeIds")
  1997. whichDay := this.GetString("WhichDay")
  1998. isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
  1999. activeState := this.GetString("ActiveState")
  2000. label := this.GetString("Label")
  2001. //入参为 undefined 时的处理
  2002. if chartPermissionIds == "undefined" {
  2003. chartPermissionIds = ""
  2004. }
  2005. // 查研观向7.4-始终查询宏观的活动
  2006. if chartPermissionIds != "" {
  2007. chartPermissionIds += ",1"
  2008. }
  2009. if activityTypeIds == "undefined" {
  2010. activityTypeIds = ""
  2011. }
  2012. if whichDay == "undefined" {
  2013. whichDay = ""
  2014. }
  2015. if activeState == "undefined" {
  2016. activeState = ""
  2017. }
  2018. if label == "undefined" {
  2019. label = ""
  2020. }
  2021. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  2022. if err != nil {
  2023. br.Msg = "获取失败"
  2024. br.ErrMsg = "获取失败,Err:" + err.Error()
  2025. return
  2026. }
  2027. if isShowJurisdiction == 1 && chartPermissionIds == "" && userType == 4 {
  2028. activityTypeIds = "1,3"
  2029. }
  2030. var startSize int
  2031. pageSize = 15
  2032. var condition string
  2033. var sortTime string
  2034. var pars []interface{}
  2035. //活动可见限制
  2036. var sqlExport string
  2037. slicePer := strings.Split(permissionStr, ",")
  2038. var permissionSqlStr string
  2039. for _, v := range slicePer {
  2040. if userType == 1 {
  2041. //if v != "研选" {
  2042. if !strings.Contains(v, "研选") {
  2043. permissionSqlStr += "'" + v + "',"
  2044. }
  2045. } else {
  2046. permissionSqlStr += "'" + v + "',"
  2047. }
  2048. }
  2049. permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
  2050. permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
  2051. permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
  2052. permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionSqlStr + `)`
  2053. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  2054. if userType == 2 {
  2055. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  2056. }
  2057. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  2058. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  2059. }
  2060. sqlExport += `) `
  2061. condition += ` AND art.publish_status = 1 AND art.label != '' `
  2062. var conditionOr string
  2063. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  2064. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  2065. }
  2066. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  2067. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  2068. }
  2069. if userType == 1 {
  2070. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  2071. } else {
  2072. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  2073. }
  2074. condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  2075. resp := new(models.GetCygxActivityLabelListRep)
  2076. //主题
  2077. if label != "" {
  2078. sortTime = ` timesort DESC `
  2079. listAll, errList := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, 32)
  2080. if errList != nil {
  2081. br.Msg = "获取失败"
  2082. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2083. return
  2084. }
  2085. sortTime = ` mintimesort ASC `
  2086. condition += ` AND art.active_state = 1 `
  2087. list1, errList := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, 16)
  2088. if errList != nil {
  2089. br.Msg = "获取失败"
  2090. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2091. return
  2092. }
  2093. for _, v := range listAll {
  2094. var isHAve bool
  2095. for _, v2 := range list1 {
  2096. if v2.KeyWord == v.KeyWord {
  2097. isHAve = true
  2098. }
  2099. }
  2100. if !isHAve {
  2101. resp.List = append(resp.List, v)
  2102. }
  2103. }
  2104. resp.Label = label
  2105. resp.ImgUrl = ""
  2106. br.Ret = 200
  2107. br.Success = true
  2108. br.Msg = "获取成功"
  2109. br.Data = resp
  2110. return
  2111. } else {
  2112. //行业名称
  2113. condition = ` AND art.publish_status = 1 AND art.label != '' `
  2114. if len(chartPermissionIds) > 0 {
  2115. condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  2116. }
  2117. if activityTypeIds != "" {
  2118. condition += ` AND art.activity_type_id IN (` + activityTypeIds + `)`
  2119. }
  2120. var conditionOr string
  2121. if whichDay != "" {
  2122. var startDate string
  2123. var endDate string
  2124. if whichDay == "1" {
  2125. startDate = time.Now().Format(utils.FormatDate)
  2126. endDate = startDate
  2127. } else if whichDay == "2" {
  2128. startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  2129. endDate = startDate
  2130. } else {
  2131. startDate = time.Now().Format(utils.FormatDate)
  2132. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  2133. }
  2134. condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  2135. condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  2136. }
  2137. if activeState != "" {
  2138. condition += ` AND art.active_state IN (` + activeState + `)`
  2139. } else {
  2140. condition += ` AND art.active_state IN (1)`
  2141. }
  2142. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  2143. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  2144. }
  2145. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  2146. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  2147. }
  2148. if userType == 1 {
  2149. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  2150. } else {
  2151. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  2152. }
  2153. condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  2154. }
  2155. sortTime = ` mintimesort ASC `
  2156. list, errList := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  2157. if errList != nil {
  2158. br.Msg = "获取失败"
  2159. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2160. return
  2161. }
  2162. resp.List = list
  2163. br.Ret = 200
  2164. br.Success = true
  2165. br.Msg = "获取成功"
  2166. br.Data = resp
  2167. }
  2168. // @Title 活动带问
  2169. // @Description 新增活动带问接口
  2170. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  2171. // @Success Ret=200 新增成功
  2172. // @router /askAdd [post]
  2173. func (this *ActivityCoAntroller) AskAdd() {
  2174. br := new(models.BaseResponse).Init()
  2175. defer func() {
  2176. this.Data["json"] = br
  2177. this.ServeJSON()
  2178. }()
  2179. user := this.User
  2180. if user == nil {
  2181. br.Msg = "请登录"
  2182. br.ErrMsg = "请登录,SysUser Is Empty"
  2183. br.Ret = 408
  2184. return
  2185. }
  2186. var req models.CygxActivityHelpAsk
  2187. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2188. if err != nil {
  2189. br.Msg = "参数解析异常!"
  2190. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2191. return
  2192. }
  2193. if req.Content == "" {
  2194. br.Msg = "建议内容不可为空"
  2195. return
  2196. }
  2197. content := req.Content
  2198. itemToken, err := services.WxGetToken()
  2199. if err != nil {
  2200. br.Msg = "GetWxAccessToken Err:" + err.Error()
  2201. return
  2202. }
  2203. if itemToken.AccessToken == "" {
  2204. br.Msg = "accessToken is empty"
  2205. return
  2206. }
  2207. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  2208. if err != nil {
  2209. br.Msg = "内容校验失败!"
  2210. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  2211. return
  2212. }
  2213. if commerr.ErrCode != 0 {
  2214. br.Msg = "内容违规,请重新提交!"
  2215. br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
  2216. return
  2217. }
  2218. activityId := req.ActivityId
  2219. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2220. if activityInfo == nil {
  2221. br.Msg = "操作失败"
  2222. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2223. return
  2224. }
  2225. if errInfo != nil {
  2226. br.Msg = "操作失败"
  2227. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2228. return
  2229. }
  2230. //resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  2231. //if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  2232. // if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  2233. // br.Msg = "活动开始前15分钟内无法提交问题"
  2234. // return
  2235. // }
  2236. //} else {
  2237. // if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  2238. // br.Msg = "活动开始前1小时内无法提交问题"
  2239. // return
  2240. // }
  2241. //}
  2242. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  2243. if err != nil {
  2244. br.Msg = "提交失败!"
  2245. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  2246. return
  2247. }
  2248. if companyDetail == nil {
  2249. br.Msg = "提交失败!"
  2250. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  2251. return
  2252. }
  2253. item := new(models.CygxActivityHelpAsk)
  2254. item.UserId = user.UserId
  2255. item.ActivityId = req.ActivityId
  2256. item.CompanyId = user.CompanyId
  2257. item.CompanyName = companyDetail.CompanyName
  2258. item.CreateTime = time.Now()
  2259. item.Mobile = user.Mobile
  2260. item.Email = user.Email
  2261. item.Content = content
  2262. _, err = models.AddActivityHelpAsk(item)
  2263. if err != nil {
  2264. br.Msg = "提交失败"
  2265. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  2266. return
  2267. }
  2268. var isSendMsg bool
  2269. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  2270. if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  2271. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  2272. isSendMsg = true
  2273. }
  2274. } else {
  2275. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  2276. isSendMsg = true
  2277. }
  2278. }
  2279. if isSendMsg {
  2280. listEmail, err := models.GetAskEmail()
  2281. if err != nil {
  2282. br.Msg = "提交失败"
  2283. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  2284. return
  2285. }
  2286. var sendMobile string
  2287. for _, v := range listEmail {
  2288. if strings.Index(activityInfo.Host, v.Name) > 0 {
  2289. sendMobile = v.Mobile
  2290. }
  2291. }
  2292. if activityInfo.ChartPermissionId == 31 {
  2293. sendMobile = utils.ActSendMsgMobile
  2294. }
  2295. //获取销售信息
  2296. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  2297. if err != nil && err.Error() != utils.ErrNoRow() {
  2298. br.Msg = "提交失败"
  2299. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2300. return
  2301. }
  2302. //给研究员发送消息
  2303. if sendMobile != "" {
  2304. openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
  2305. if openIpItem != nil && openIpItem.OpenId != "" {
  2306. if sellerItem != nil {
  2307. //services.SendActivityAskApplyTemplateMsg(user.RealName+"——"+user.CompanyName+"(所属销售:"+sellerItem.RealName+")", time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, activityInfo.ActivityId, openIpItem)
  2308. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  2309. }
  2310. }
  2311. }
  2312. // 给所属销售发送消息
  2313. if sellerItem != nil {
  2314. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  2315. if openIpItem != nil && openIpItem.OpenId != "" {
  2316. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  2317. }
  2318. }
  2319. }
  2320. br.Ret = 200
  2321. br.Success = true
  2322. br.Msg = "提交成功"
  2323. }
  2324. // @Title 活动类型下的主题列表(4.3版本)
  2325. // @Description 获取活动类型下的主题列表接口(4.3版本)
  2326. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  2327. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  2328. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  2329. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  2330. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  2331. // @Success 200 {object} models.ActivityTypeListHomeResp
  2332. // @router /labelTypeList_deltest [get]
  2333. func (this *ActivityCoAntroller) LabelTypeList() {
  2334. br := new(models.BaseResponse).Init()
  2335. defer func() {
  2336. this.Data["json"] = br
  2337. this.ServeJSON()
  2338. }()
  2339. user := this.User
  2340. if user == nil {
  2341. br.Msg = "请登录"
  2342. br.ErrMsg = "请登录,SysUser Is Empty"
  2343. return
  2344. }
  2345. pageSize, _ := this.GetInt("PageSize")
  2346. isPower, _ := this.GetInt("IsPower")
  2347. //currentIndex, _ := this.GetInt("CurrentIndex")
  2348. chartPermissionIds := this.GetString("ChartPermissionIds")
  2349. //activityTypeIds := this.GetString("ActivityTypeIds")
  2350. whichDay := this.GetString("WhichDay")
  2351. activeState := this.GetString("ActiveState")
  2352. //入参为 undefined 时的处理
  2353. if chartPermissionIds == "undefined" {
  2354. chartPermissionIds = ""
  2355. }
  2356. // 查研观向7.4-始终查询宏观的活动
  2357. if chartPermissionIds != "" {
  2358. chartPermissionIds += ",1"
  2359. }
  2360. if whichDay == "undefined" {
  2361. whichDay = ""
  2362. }
  2363. if activeState == "undefined" || activeState == "" {
  2364. activeState = "1"
  2365. }
  2366. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  2367. if err != nil {
  2368. br.Msg = "获取失败"
  2369. br.ErrMsg = "获取失败,Err:" + err.Error()
  2370. return
  2371. }
  2372. var startSize int
  2373. pageSize = 40
  2374. var sortTime string
  2375. var pars []interface{}
  2376. //活动可见限制
  2377. slicePer := strings.Split(permissionStr, ",")
  2378. var permissionSqlStr string
  2379. var permissionNameStr string
  2380. for _, v := range slicePer {
  2381. if userType == 1 {
  2382. //if v != "研选" {
  2383. if !strings.Contains(v, "研选") {
  2384. permissionNameStr += "'" + v + "',"
  2385. }
  2386. } else {
  2387. permissionNameStr += "'" + v + "',"
  2388. }
  2389. }
  2390. permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
  2391. permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
  2392. permissionNameStr = strings.TrimRight(permissionNameStr, ",")
  2393. list, err := models.GetActivityTypeHomeList()
  2394. if err != nil {
  2395. br.Msg = "获取失败"
  2396. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  2397. return
  2398. }
  2399. resp := new(models.ActivityTypeListHomeResp)
  2400. for k, v := range list {
  2401. var sqlExport string
  2402. var condition string
  2403. permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionNameStr + `)`
  2404. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  2405. if userType == 2 {
  2406. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  2407. }
  2408. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  2409. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  2410. }
  2411. sqlExport += `) `
  2412. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.activity_type_id = ` + strconv.Itoa(v.ActivityTypeId)
  2413. if isPower == 1 {
  2414. condition += permissionSqlStr
  2415. }
  2416. //行业名称
  2417. if len(chartPermissionIds) > 0 {
  2418. condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  2419. }
  2420. var conditionOr string
  2421. if whichDay != "" {
  2422. var startDate string
  2423. var endDate string
  2424. if whichDay == "1" {
  2425. startDate = time.Now().Format(utils.FormatDate)
  2426. endDate = startDate
  2427. } else if whichDay == "2" {
  2428. startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  2429. endDate = startDate
  2430. } else {
  2431. startDate = time.Now().Format(utils.FormatDate)
  2432. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  2433. }
  2434. condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  2435. condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  2436. }
  2437. if activeState != "" {
  2438. condition += ` AND art.active_state IN (` + activeState + `)`
  2439. } else {
  2440. condition += ` AND art.active_state IN (1)`
  2441. }
  2442. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  2443. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  2444. }
  2445. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  2446. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  2447. }
  2448. if userType == 1 {
  2449. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  2450. } else {
  2451. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  2452. }
  2453. //判断客户规模是否属于可见范围的活动
  2454. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  2455. if err != nil && err.Error() != utils.ErrNoRow() {
  2456. br.Msg = "获取信息失败"
  2457. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2458. return
  2459. }
  2460. if companyProduct != nil {
  2461. if companyProduct.Scale != "" {
  2462. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  2463. }
  2464. }
  2465. condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  2466. sortTime = ` mintimesort ASC `
  2467. labelList, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  2468. if err != nil {
  2469. br.Msg = "获取失败"
  2470. br.ErrMsg = "获取失败,Err:" + err.Error()
  2471. return
  2472. }
  2473. //标签字段关联的产业与标签处理
  2474. for k2, v2 := range labelList {
  2475. labelList[k2].KeyWord = services.LabelStr(v2.KeyWord)
  2476. labelList[k2].ImgUrlBg = v.ImgUrlBgs
  2477. }
  2478. list[k].List = labelList
  2479. }
  2480. //获取对应活动的数量并排序
  2481. intArr := make([]int, 0)
  2482. var items []*models.ActivityTypeHome
  2483. for _, v := range list {
  2484. item := new(models.ActivityTypeHome)
  2485. if len(v.List) > 0 {
  2486. item.List = v.List
  2487. item.ActivityTypeName = v.ActivityTypeName
  2488. item.ActivityTypeId = v.ActivityTypeId
  2489. item.ImgUrlBg = v.ImgUrlBg
  2490. item.ImgUrl = v.ImgUrl
  2491. items = append(items, item)
  2492. intArr = append(intArr, len(v.List))
  2493. }
  2494. }
  2495. sort.Sort(sort.Reverse(sort.IntSlice(intArr)))
  2496. var itemsNew []*models.ActivityTypeHome
  2497. activityMap := make(map[int]int)
  2498. for _, v := range intArr {
  2499. for _, v2 := range items {
  2500. item := new(models.ActivityTypeHome)
  2501. if len(v2.List) > 0 && v == len(v2.List) && activityMap[v2.ActivityTypeId] == 0 {
  2502. item.List = v2.List
  2503. item.ActivityTypeName = v2.ActivityTypeName
  2504. item.ActivityTypeId = v2.ActivityTypeId
  2505. item.ImgUrlBg = v2.ImgUrlBg
  2506. item.ImgUrl = v2.ImgUrl
  2507. itemsNew = append(itemsNew, item)
  2508. activityMap[v2.ActivityTypeId] = len(v2.List)
  2509. }
  2510. }
  2511. }
  2512. //如果第三个活动数量比第四个多,则两者调换
  2513. if len(itemsNew) > 3 {
  2514. if len(itemsNew[2].List) > len(itemsNew[3].List) {
  2515. var itemsNewCopy []*models.ActivityTypeHome
  2516. for _, v := range itemsNew {
  2517. itemsNewCopy = append(itemsNewCopy, v)
  2518. }
  2519. itemsNew[2] = itemsNewCopy[3]
  2520. itemsNew[3] = itemsNewCopy[2]
  2521. }
  2522. }
  2523. //记录用户搜索的筛选条件
  2524. item := new(models.CygxActivitySearchHistory)
  2525. item.UserId = user.UserId
  2526. item.Mobile = user.Mobile
  2527. item.CompanyId = user.CompanyId
  2528. item.CompanyName = user.CompanyName
  2529. item.CreateTime = time.Now()
  2530. item.ChartPermissionIds = chartPermissionIds
  2531. item.IsPower = isPower
  2532. item.WhichDay = whichDay
  2533. go models.AddCygxActivitySearchHistory(item)
  2534. resp.List = itemsNew
  2535. br.Ret = 200
  2536. br.Success = true
  2537. br.Msg = "获取成功"
  2538. br.Data = resp
  2539. }
  2540. // @Title 更多主题列表(4.3版本)
  2541. // @Description 获取活动更多主题列表接口(4.3版本)
  2542. // @Success 200 {object} models.GetCygxActivityLabelListRep
  2543. // @router /labelMoreList [get]
  2544. func (this *ActivityCoAntroller) LabelMoreList() {
  2545. br := new(models.BaseResponse).Init()
  2546. defer func() {
  2547. this.Data["json"] = br
  2548. this.ServeJSON()
  2549. }()
  2550. user := this.User
  2551. if user == nil {
  2552. br.Msg = "请登录"
  2553. br.ErrMsg = "请登录,SysUser Is Empty"
  2554. return
  2555. }
  2556. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  2557. if err != nil {
  2558. br.Msg = "获取失败"
  2559. br.ErrMsg = "获取失败,Err:" + err.Error()
  2560. return
  2561. }
  2562. var startSize, pageSize int
  2563. pageSize = 24
  2564. var condition string
  2565. var sortTime string
  2566. //var conditionStatus string
  2567. var pars []interface{}
  2568. //活动可见限制
  2569. var sqlExport string
  2570. resp := new(models.GetCygxActivityLabelListRep)
  2571. slicePer := strings.Split(permissionStr, ",")
  2572. var permissionSqlStr string
  2573. for _, v := range slicePer {
  2574. if userType == 1 {
  2575. //if v != "研选" {
  2576. if !strings.Contains(v, "研选") {
  2577. permissionSqlStr += "'" + v + "',"
  2578. }
  2579. } else {
  2580. permissionSqlStr += "'" + v + "',"
  2581. }
  2582. }
  2583. permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
  2584. permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
  2585. permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
  2586. permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionSqlStr + `)`
  2587. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  2588. if userType == 2 {
  2589. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  2590. }
  2591. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  2592. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  2593. }
  2594. sqlExport += `) `
  2595. //进行中的活动
  2596. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.active_state = 2 `
  2597. var conditionOr string
  2598. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  2599. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  2600. }
  2601. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  2602. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  2603. }
  2604. if userType == 1 {
  2605. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  2606. } else {
  2607. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  2608. }
  2609. //判断客户规模是否属于可见范围的活动
  2610. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  2611. if err != nil && err.Error() != utils.ErrNoRow() {
  2612. br.Msg = "获取信息失败"
  2613. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2614. return
  2615. }
  2616. if companyProduct != nil {
  2617. if companyProduct.Scale != "" {
  2618. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  2619. }
  2620. }
  2621. condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  2622. //进行中的活动
  2623. sortTime = ` mintimesort ASC `
  2624. list, errList := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  2625. if errList != nil {
  2626. br.Msg = "获取失败"
  2627. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2628. return
  2629. }
  2630. //已结束的活动
  2631. conditionOr = ""
  2632. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.active_state = 3 `
  2633. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  2634. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  2635. }
  2636. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  2637. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  2638. }
  2639. if userType == 1 {
  2640. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  2641. } else {
  2642. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  2643. }
  2644. condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  2645. startSize = 0
  2646. pageSize = 24 - len(list)
  2647. //已结束的活动
  2648. sortTime = ` timesort DESC `
  2649. listEnd, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  2650. if err != nil {
  2651. br.Msg = "获取失败"
  2652. br.ErrMsg = "获取失败,Err:" + err.Error()
  2653. return
  2654. }
  2655. for _, v := range listEnd {
  2656. list = append(list, v)
  2657. }
  2658. //标签字段关联的产业与标签处理
  2659. for k, v := range list {
  2660. list[k].KeyWord = services.LabelStr(v.KeyWord)
  2661. }
  2662. //添加更多主题访问记录
  2663. item := new(models.CygxPageHistoryRecord)
  2664. item.UserId = user.UserId
  2665. item.CreateTime = time.Now()
  2666. item.Mobile = user.Mobile
  2667. item.Email = user.Email
  2668. item.CompanyId = user.CompanyId
  2669. item.CompanyName = user.CompanyName
  2670. item.PageType = "LabelMore"
  2671. go models.AddCygxPageHistoryRecord(item)
  2672. resp.List = list
  2673. br.Ret = 200
  2674. br.Success = true
  2675. br.Msg = "获取成功"
  2676. br.Data = resp
  2677. }
  2678. // @Title 活动列表(4.3版本)
  2679. // @Description 获取活动列表接口(4.3版本)
  2680. // @Param PageSize query int true "每页数据条数"
  2681. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2682. // @Param Label query string false "搜索主题 多个用 , 隔开"
  2683. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  2684. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  2685. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  2686. // @Param ActivityTypeId query string false "活动类型id 多个用 , 隔开"
  2687. // @Param Source query int false "来源 0手机 ,1Pc 默认0"
  2688. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  2689. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  2690. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  2691. // @Success 200 {object} models.GetCygxActivityListRep
  2692. // @router /listNew [get]
  2693. func (this *ActivityCoAntroller) ActivityListNew() {
  2694. br := new(models.BaseResponse).Init()
  2695. defer func() {
  2696. this.Data["json"] = br
  2697. this.ServeJSON()
  2698. }()
  2699. user := this.User
  2700. if user == nil {
  2701. br.Msg = "请登录"
  2702. br.ErrMsg = "请登录,SysUser Is Empty"
  2703. return
  2704. }
  2705. uid := user.UserId
  2706. pageSize, _ := this.GetInt("PageSize")
  2707. currentIndex, _ := this.GetInt("CurrentIndex")
  2708. source, _ := this.GetInt("Source")
  2709. label := this.GetString("Label")
  2710. chartPermissionIds := this.GetString("ChartPermissionIds")
  2711. whichDay := this.GetString("WhichDay")
  2712. activeState := this.GetString("ActiveState")
  2713. activityTypeId := this.GetString("ActivityTypeId")
  2714. keyWord := this.GetString("KeyWord")
  2715. playBack, _ := this.GetInt("PlayBack")
  2716. if label == "undefined" {
  2717. label = ""
  2718. }
  2719. if chartPermissionIds == "undefined" {
  2720. chartPermissionIds = ""
  2721. }
  2722. // 查研观向7.4-始终查询宏观的活动
  2723. if chartPermissionIds != "" {
  2724. chartPermissionIds += ",1"
  2725. }
  2726. if whichDay == "undefined" {
  2727. whichDay = ""
  2728. }
  2729. if activeState == "undefined" {
  2730. activeState = ""
  2731. }
  2732. if activityTypeId == "undefined" {
  2733. activityTypeId = ""
  2734. }
  2735. var startSize int
  2736. if pageSize <= 0 {
  2737. pageSize = utils.PageSize20
  2738. }
  2739. if currentIndex <= 0 {
  2740. currentIndex = 1
  2741. }
  2742. startSize = utils.StartIndex(currentIndex, pageSize)
  2743. //userType, permissionStr, err := services.GetUserType(user.CompanyId)
  2744. var condition string
  2745. var pars []interface{}
  2746. var activityList []*models.ActivityDetail
  2747. mapDingActivityId := make(map[int]int)
  2748. //进行中的活动拍在最上面
  2749. if keyWord != "" {
  2750. conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, strconv.Itoa(2), label, 0, source, keyWord)
  2751. if err != nil && err.Error() != utils.ErrNoRow() {
  2752. br.Msg = "获取失败"
  2753. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  2754. return
  2755. }
  2756. if source == 1 {
  2757. condition += ` AND art.yidong_activity_id = '' `
  2758. }
  2759. condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
  2760. condition += ` ORDER BY art.activity_time ASC `
  2761. listDing, err := models.GetActivityListAll(condition, pars, uid, startSize, pageSize, playBack)
  2762. if err != nil && err.Error() != utils.ErrNoRow() {
  2763. br.Msg = "获取失败"
  2764. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  2765. return
  2766. }
  2767. if len(listDing) > 0 {
  2768. for _, v := range listDing {
  2769. activityList = append(activityList, v)
  2770. mapDingActivityId[v.ActivityId] = v.ActivityId
  2771. }
  2772. }
  2773. }
  2774. condition = ""
  2775. //活动可见限制
  2776. conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord)
  2777. if err != nil && err.Error() != utils.ErrNoRow() {
  2778. br.Msg = "获取失败"
  2779. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  2780. return
  2781. }
  2782. if source == 1 {
  2783. condition += ` AND art.yidong_activity_id = '' `
  2784. }
  2785. condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
  2786. total, err := models.GetActivityCount(condition, playBack, pars)
  2787. if err != nil {
  2788. br.Msg = "获取失败"
  2789. br.ErrMsg = "获取失败,Err:" + err.Error()
  2790. return
  2791. }
  2792. var conditionOrder string
  2793. if activeState == "2" || activeState == "3" {
  2794. conditionOrder = ` ORDER BY art.activity_time DESC `
  2795. } else if activeState == "2,3" {
  2796. conditionOrder = ` ORDER BY art.active_state ASC, art.activity_time DESC `
  2797. } else {
  2798. conditionOrder = ` ORDER BY art.activity_time DESC , art.active_state ASC `
  2799. }
  2800. if label != "" && activeState == "1" {
  2801. conditionOrder = ` ORDER BY art.activity_time ASC `
  2802. }
  2803. if activeState == "1" {
  2804. conditionOrder = ` ORDER BY art.activity_time ASC `
  2805. }
  2806. condition += conditionOrder
  2807. list, errList := models.GetActivityListAll(condition, pars, uid, startSize, pageSize, playBack)
  2808. if errList != nil {
  2809. br.Msg = "获取失败"
  2810. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2811. return
  2812. }
  2813. var isShow bool
  2814. isShow = services.GetShowSustainable()
  2815. detail, err := models.GetConfigByCode("city_img_url")
  2816. if err != nil {
  2817. br.Msg = "获取数据失败"
  2818. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  2819. return
  2820. }
  2821. detailChart, err := models.GetConfigByCode("chart_img_url")
  2822. if err != nil {
  2823. br.Msg = "获取数据失败"
  2824. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  2825. return
  2826. }
  2827. addressList := strings.Split(detail.ConfigValue, "{|}")
  2828. mapAddress := make(map[string]string)
  2829. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  2830. mapChart := make(map[string]string)
  2831. var cityName string
  2832. var chartName string
  2833. var imgUrl string
  2834. var imgUrlChart string
  2835. var mapActivityId []int
  2836. for _, v := range addressList {
  2837. vslice := strings.Split(v, "_")
  2838. cityName = vslice[0]
  2839. imgUrl = vslice[len(vslice)-1]
  2840. mapAddress[cityName] = imgUrl
  2841. }
  2842. for _, v := range chartList {
  2843. vslice := strings.Split(v, "_")
  2844. chartName = vslice[0]
  2845. imgUrlChart = vslice[len(vslice)-1]
  2846. mapChart[chartName] = imgUrlChart
  2847. }
  2848. for k, v := range list {
  2849. if strings.Contains(v.ActivityName, "【") {
  2850. list[k].IsBrackets = 1
  2851. }
  2852. if v.SignupNum > v.LimitPeopleNum {
  2853. list[k].SignupNum = v.LimitPeopleNum
  2854. }
  2855. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  2856. list[k].IsShowSustainable = true
  2857. }
  2858. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  2859. list[k].ActivityTypeName = "买方研选电话会"
  2860. list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  2861. }
  2862. if v.ActivityType == 0 {
  2863. if mapAddress[v.City] != "" {
  2864. list[k].ImgUrl = mapAddress[v.City]
  2865. } else {
  2866. list[k].ImgUrl = mapAddress["其它"]
  2867. }
  2868. } else {
  2869. if mapChart[v.ChartPermissionName] != "" {
  2870. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  2871. }
  2872. }
  2873. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  2874. list[k].Expert = expertTxt
  2875. if v.IsHideAppointment == 0 {
  2876. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  2877. }
  2878. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  2879. list[k].IsCClassMeeting = true
  2880. }
  2881. mapActivityId = append(mapActivityId, v.ActivityId)
  2882. }
  2883. page := paging.GetPaging(currentIndex, pageSize, total)
  2884. resp := new(models.GetCygxActivityListRep)
  2885. resp.Label = label
  2886. if activityTypeId != "" {
  2887. activityTypeIdint, err := strconv.Atoi(activityTypeId)
  2888. if err == nil {
  2889. detail, errDetail := models.GetActivityTypeDetailById(activityTypeIdint)
  2890. if errDetail != nil {
  2891. br.Msg = "获取信息失败"
  2892. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  2893. return
  2894. }
  2895. resp.ImgUrl = detail.OnlineIco
  2896. resp.Label = detail.ActivityTypeName
  2897. }
  2898. }
  2899. //处理音频回放
  2900. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  2901. if err != nil {
  2902. br.Msg = "获取信息失败"
  2903. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  2904. return
  2905. }
  2906. for _, v := range list {
  2907. if mapDingActivityId[v.ActivityId] == 0 {
  2908. activityList = append(activityList, v)
  2909. }
  2910. }
  2911. for _, v := range activityList {
  2912. if v.ActivityType == 0 {
  2913. if mapAddress[v.City] != "" {
  2914. v.ImgUrl = mapAddress[v.City]
  2915. } else {
  2916. v.ImgUrl = mapAddress["其它"]
  2917. }
  2918. } else {
  2919. if mapChart[v.ChartPermissionName] != "" {
  2920. v.ImgUrl = mapChart[v.ChartPermissionName]
  2921. }
  2922. }
  2923. if mapActivityVoice[v.ActivityId] != nil {
  2924. v.AudioLink = true
  2925. v.VoiceList = mapActivityVoice[v.ActivityId]
  2926. }
  2927. resp.List = append(resp.List, services.ActivityButtonShow(v))
  2928. }
  2929. // 查研观向7.4-判断标签是否为产业, 为产业时是否跳转资源包
  2930. if label != "" {
  2931. sourceIndustry, e := models.GetSourceIndustryByName(label)
  2932. if e != nil && e.Error() != utils.ErrNoRow() {
  2933. br.Msg = "获取信息失败"
  2934. br.ErrMsg = "获取标签产业资源包失败, Err:" + e.Error()
  2935. return
  2936. }
  2937. if sourceIndustry != nil {
  2938. resp.IndustrialManagementId = sourceIndustry.IndustrialManagementId
  2939. resp.IsJump = true
  2940. // 研选产业不跳资源包
  2941. if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  2942. resp.IsJump = false
  2943. }
  2944. // 产业新标签
  2945. industryIds := []int{sourceIndustry.IndustrialManagementId}
  2946. industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
  2947. if e != nil {
  2948. br.Msg = "获取信息失败"
  2949. br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
  2950. return
  2951. }
  2952. resp.IndustryNewLabel = industryNewMap[sourceIndustry.IndustrialManagementId]
  2953. }
  2954. }
  2955. //添加活动搜索记录
  2956. if keyWord != "" {
  2957. go services.AddActivitykeyWordSearch(keyWord, user)
  2958. }
  2959. resp.Paging = page
  2960. br.Ret = 200
  2961. br.Success = true
  2962. br.Msg = "获取成功"
  2963. br.Data = resp
  2964. }
  2965. // @Title 活动类型下的主题列表Pc端
  2966. // @Description 获取活动类型下的主题列表接口Pc端
  2967. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  2968. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  2969. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  2970. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  2971. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  2972. // @Success 200 {object} models.ActivityTypeListHomeRespPc
  2973. // @router /labelTypeListPc_deltest [get]
  2974. func (this *ActivityCoAntroller) LabelTypeListPc() {
  2975. br := new(models.BaseResponse).Init()
  2976. defer func() {
  2977. this.Data["json"] = br
  2978. this.ServeJSON()
  2979. }()
  2980. user := this.User
  2981. if user == nil {
  2982. br.Msg = "请登录"
  2983. br.ErrMsg = "请登录,SysUser Is Empty"
  2984. return
  2985. }
  2986. pageSize, _ := this.GetInt("PageSize")
  2987. isPower, _ := this.GetInt("IsPower")
  2988. //currentIndex, _ := this.GetInt("CurrentIndex")
  2989. chartPermissionIds := this.GetString("ChartPermissionIds")
  2990. //activityTypeIds := this.GetString("ActivityTypeIds")
  2991. whichDay := this.GetString("WhichDay")
  2992. activeState := this.GetString("ActiveState")
  2993. //入参为 undefined 时的处理
  2994. if chartPermissionIds == "undefined" {
  2995. chartPermissionIds = ""
  2996. }
  2997. // 查研观向7.4-始终查询宏观的活动
  2998. if chartPermissionIds != "" {
  2999. chartPermissionIds += ",1"
  3000. }
  3001. if whichDay == "undefined" {
  3002. whichDay = ""
  3003. }
  3004. if activeState == "undefined" || activeState == "" {
  3005. activeState = "1"
  3006. }
  3007. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  3008. if err != nil {
  3009. br.Msg = "获取失败"
  3010. br.ErrMsg = "获取失败,Err:" + err.Error()
  3011. return
  3012. }
  3013. var startSize int
  3014. pageSize = 8
  3015. var sortTime string
  3016. var pars []interface{}
  3017. //活动可见限制
  3018. slicePer := strings.Split(permissionStr, ",")
  3019. var permissionSqlStr string
  3020. var permissionNameStr string
  3021. for _, v := range slicePer {
  3022. if userType == 1 {
  3023. //if v != "研选" {
  3024. if !strings.Contains(v, "研选") {
  3025. permissionNameStr += "'" + v + "',"
  3026. }
  3027. } else {
  3028. permissionNameStr += "'" + v + "',"
  3029. }
  3030. }
  3031. permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
  3032. permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
  3033. permissionNameStr = strings.TrimRight(permissionNameStr, ",")
  3034. list, err := models.GetActivityTypeHomeListPc()
  3035. if err != nil {
  3036. br.Msg = "获取失败"
  3037. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  3038. return
  3039. }
  3040. resp := new(models.ActivityTypeListHomeRespPc)
  3041. for k, v := range list {
  3042. var sqlExport string
  3043. var condition string
  3044. permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionNameStr + `)`
  3045. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  3046. if userType == 2 {
  3047. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  3048. }
  3049. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  3050. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  3051. }
  3052. sqlExport += `) `
  3053. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.activity_type_id = ` + strconv.Itoa(v.ActivityTypeId)
  3054. if isPower == 1 {
  3055. condition += permissionSqlStr
  3056. }
  3057. //行业名称
  3058. if len(chartPermissionIds) > 0 {
  3059. condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  3060. }
  3061. var conditionOr string
  3062. if whichDay != "" {
  3063. var startDate string
  3064. var endDate string
  3065. if whichDay == "1" {
  3066. startDate = time.Now().Format(utils.FormatDate)
  3067. endDate = startDate
  3068. } else if whichDay == "2" {
  3069. startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  3070. endDate = startDate
  3071. } else {
  3072. startDate = time.Now().Format(utils.FormatDate)
  3073. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  3074. }
  3075. condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  3076. condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  3077. }
  3078. if activeState != "" {
  3079. // 默认查看未开始跟进行中
  3080. if activeState == "1" {
  3081. condition += ` AND art.active_state IN (1,2)`
  3082. } else {
  3083. condition += ` AND art.active_state IN (` + activeState + `)`
  3084. }
  3085. } else {
  3086. condition += ` AND art.active_state IN (1)`
  3087. }
  3088. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  3089. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  3090. }
  3091. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  3092. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  3093. }
  3094. if userType == 1 {
  3095. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  3096. } else {
  3097. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  3098. }
  3099. //判断客户规模是否属于可见范围的活动
  3100. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  3101. if err != nil && err.Error() != utils.ErrNoRow() {
  3102. br.Msg = "获取信息失败"
  3103. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  3104. return
  3105. }
  3106. if companyProduct != nil {
  3107. if companyProduct.Scale != "" {
  3108. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  3109. }
  3110. }
  3111. condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  3112. sortTime = ` mintimesort ASC `
  3113. labelList, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  3114. if err != nil {
  3115. br.Msg = "获取失败"
  3116. br.ErrMsg = "获取失败,Err:" + err.Error()
  3117. return
  3118. }
  3119. //标签字段关联的产业与标签处理
  3120. for k2, v2 := range labelList {
  3121. labelList[k2].KeyWord = services.LabelStr(v2.KeyWord)
  3122. }
  3123. list[k].List = labelList
  3124. }
  3125. //记录用户搜索的筛选条件
  3126. item := new(models.CygxActivitySearchHistory)
  3127. item.UserId = user.UserId
  3128. item.Mobile = user.Mobile
  3129. item.CompanyId = user.CompanyId
  3130. item.CompanyName = user.CompanyName
  3131. item.CreateTime = time.Now()
  3132. item.ChartPermissionIds = chartPermissionIds
  3133. item.IsPower = isPower
  3134. item.WhichDay = whichDay
  3135. go models.AddCygxActivitySearchHistory(item)
  3136. resp.List = list
  3137. br.Ret = 200
  3138. br.Success = true
  3139. br.Msg = "获取成功"
  3140. br.Data = resp
  3141. }
  3142. // @Title 校验活动带问是否有权限
  3143. // @Description 校验活动带问是否有权限接口
  3144. // @Param request body models.ActivityIdRep true "type json string"
  3145. // @Success Ret=200 {object} models.SignupStatus
  3146. // @router /checkAsk [post]
  3147. func (this *ActivityCoAntroller) CheckAsk() {
  3148. br := new(models.BaseResponse).Init()
  3149. defer func() {
  3150. this.Data["json"] = br
  3151. this.ServeJSON()
  3152. }()
  3153. user := this.User
  3154. if user == nil {
  3155. br.Msg = "请登录"
  3156. br.ErrMsg = "请登录,用户信息为空"
  3157. br.Ret = 408
  3158. return
  3159. }
  3160. uid := user.UserId
  3161. signupStatus := "Success"
  3162. var req models.ActivityIdRep
  3163. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3164. if err != nil {
  3165. br.Msg = "参数解析异常!"
  3166. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3167. return
  3168. }
  3169. activityId := req.ActivityId
  3170. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  3171. if activityInfo == nil {
  3172. br.Msg = "操作失败"
  3173. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  3174. return
  3175. }
  3176. if errInfo != nil {
  3177. br.Msg = "操作失败"
  3178. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3179. return
  3180. }
  3181. //判断是否已经申请过
  3182. applyCount, err := models.GetApplyRecordCount(uid)
  3183. if err != nil && err.Error() != utils.ErrNoRow() {
  3184. br.Msg = "获取信息失败"
  3185. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  3186. return
  3187. }
  3188. //获取销售信息
  3189. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  3190. if err != nil && err.Error() != utils.ErrNoRow() {
  3191. br.Msg = "申请失败"
  3192. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  3193. return
  3194. }
  3195. resp := new(models.SignupStatus)
  3196. hasPermission := 0
  3197. var companyDetailStatus string
  3198. if user.CompanyId <= 1 {
  3199. companyDetailStatus = ""
  3200. } else {
  3201. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  3202. if err != nil {
  3203. br.Msg = "获取信息失败"
  3204. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3205. return
  3206. }
  3207. if companyPermission == "" {
  3208. if applyCount > 0 {
  3209. hasPermission = 4
  3210. } else {
  3211. if sellerItem != nil {
  3212. hasPermission = 5
  3213. } else {
  3214. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  3215. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  3216. if err != nil && err.Error() != utils.ErrNoRow() {
  3217. br.Msg = "获取信息失败"
  3218. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  3219. return
  3220. }
  3221. if sellerItemQy != nil {
  3222. hasPermission = 2
  3223. resp.SellerMobile = sellerItemQy.Mobile
  3224. resp.SellerName = sellerItemQy.RealName
  3225. } else {
  3226. hasPermission = 3
  3227. }
  3228. }
  3229. }
  3230. resp.ActivityId = activityId
  3231. resp.HasPermission = hasPermission
  3232. resp.OperationMode = "Apply"
  3233. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  3234. br.Ret = 200
  3235. br.Success = true
  3236. br.Msg = "获取成功"
  3237. br.Data = resp
  3238. return
  3239. }
  3240. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  3241. if err != nil {
  3242. br.Msg = "获取信息失败!"
  3243. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3244. return
  3245. }
  3246. if companyDetail == nil {
  3247. br.Msg = "获取信息失败!"
  3248. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  3249. return
  3250. }
  3251. companyDetailStatus = companyDetail.Status
  3252. }
  3253. var userType int
  3254. var permissionStr string
  3255. userType, permissionStr, err = services.GetUserType(user.CompanyId)
  3256. if err != nil {
  3257. br.Msg = "获取信息失败!"
  3258. br.ErrMsg = "获取失败,Err:" + err.Error()
  3259. return
  3260. }
  3261. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  3262. br.Msg = "您暂无查看该活动权限"
  3263. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  3264. return
  3265. }
  3266. if user.CompanyId > 1 {
  3267. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  3268. //冻结客户
  3269. if err != nil {
  3270. if err.Error() == utils.ErrNoRow() {
  3271. if applyCount > 0 {
  3272. hasPermission = 4
  3273. } else {
  3274. if sellerItem != nil {
  3275. hasPermission = 5
  3276. } else {
  3277. hasPermission = 3
  3278. }
  3279. }
  3280. resp.ActivityId = activityId
  3281. resp.HasPermission = hasPermission
  3282. resp.OperationMode = "Apply"
  3283. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  3284. br.Ret = 200
  3285. br.Success = true
  3286. br.Msg = "获取成功"
  3287. br.Data = resp
  3288. return
  3289. } else {
  3290. br.Msg = "获取信息失败"
  3291. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  3292. return
  3293. }
  3294. }
  3295. havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
  3296. if err != nil {
  3297. br.Msg = "获取信息失败!"
  3298. br.ErrMsg = "获取失败,Err:" + err.Error()
  3299. return
  3300. }
  3301. if havePower {
  3302. hasPermission = 1
  3303. signupStatus = "Success"
  3304. resp.HaqveJurisdiction = true
  3305. } else {
  3306. if companyItem.ProductId == 2 {
  3307. hasPermission = 2
  3308. resp.SellerMobile = companyItem.Mobile
  3309. resp.SellerName = companyItem.SellerName
  3310. resp.MsgType = "Type"
  3311. resp.OperationMode = "Call"
  3312. if permissionStr == "专家" {
  3313. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  3314. resp.MsgType = "Type"
  3315. } else {
  3316. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  3317. resp.MsgType = "Industry"
  3318. }
  3319. } else {
  3320. hasPermission = 5
  3321. }
  3322. }
  3323. } else { //潜在客户
  3324. if applyCount > 0 {
  3325. hasPermission = 4
  3326. } else {
  3327. if sellerItem != nil {
  3328. hasPermission = 5
  3329. } else {
  3330. hasPermission = 3
  3331. }
  3332. }
  3333. resp.OperationMode = "Apply"
  3334. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  3335. }
  3336. resp.HasPermission = hasPermission
  3337. resp.SignupStatus = signupStatus
  3338. resp.ActivityId = activityId
  3339. br.Ret = 200
  3340. br.Success = true
  3341. br.Data = resp
  3342. }
  3343. // @Title 活动类型下的主题列表(5.3版本)
  3344. // @Description 获取活动类型下的主题列表接口(5.3版本)
  3345. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  3346. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  3347. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  3348. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  3349. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  3350. // @Success 200 {object} models.ActivityTypeListHomeResp
  3351. // @router /labelTypeListV5 [get]
  3352. func (this *ActivityCoAntroller) LabelTypeListV5() {
  3353. br := new(models.BaseResponse).Init()
  3354. defer func() {
  3355. this.Data["json"] = br
  3356. this.ServeJSON()
  3357. }()
  3358. user := this.User
  3359. if user == nil {
  3360. br.Msg = "请登录"
  3361. br.ErrMsg = "请登录,SysUser Is Empty"
  3362. return
  3363. }
  3364. pageSize, _ := this.GetInt("PageSize")
  3365. isPower, _ := this.GetInt("IsPower")
  3366. chartPermissionIds := this.GetString("ChartPermissionIds")
  3367. whichDay := this.GetString("WhichDay")
  3368. activeState := this.GetString("ActiveState")
  3369. //入参为 undefined 时的处理
  3370. if chartPermissionIds == "undefined" {
  3371. chartPermissionIds = ""
  3372. }
  3373. if whichDay == "undefined" {
  3374. whichDay = ""
  3375. }
  3376. if activeState == "undefined" || activeState == "" {
  3377. activeState = "1"
  3378. }
  3379. // 查研观向7.4-始终查询宏观的活动
  3380. if chartPermissionIds != "" {
  3381. chartPermissionIds += ",1"
  3382. }
  3383. //adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
  3384. //if err != nil {
  3385. // br.Msg = "获取失败"
  3386. // br.ErrMsg = "获取本组下的销售失败,Err:" + err.Error()
  3387. // return
  3388. //}
  3389. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  3390. if err != nil {
  3391. br.Msg = "获取失败"
  3392. br.ErrMsg = "获取失败,Err:" + err.Error()
  3393. return
  3394. }
  3395. var startSize int
  3396. pageSize = 8
  3397. var sortTime string
  3398. var pars []interface{}
  3399. //活动可见限制
  3400. slicePer := strings.Split(permissionStr, ",")
  3401. var permissionSqlStr string
  3402. var permissionNameStr string
  3403. for _, v := range slicePer {
  3404. if userType == 1 {
  3405. //if v != "研选" {
  3406. if !strings.Contains(v, "研选") {
  3407. permissionNameStr += "'" + v + "',"
  3408. }
  3409. } else {
  3410. permissionNameStr += "'" + v + "',"
  3411. }
  3412. }
  3413. permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
  3414. permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
  3415. permissionNameStr = strings.TrimRight(permissionNameStr, ",")
  3416. // 查研观向7.4-始终查询宏观的权限(无论是否有权限)
  3417. if permissionNameStr == `` {
  3418. permissionNameStr = `'宏观'`
  3419. } else {
  3420. permissionNameStr += `, '宏观'`
  3421. }
  3422. list, err := models.GetActivityTypeHomeList()
  3423. if err != nil {
  3424. br.Msg = "获取失败"
  3425. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  3426. return
  3427. }
  3428. //判断客户规模是否属于可见范围的活动
  3429. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  3430. if err != nil && err.Error() != utils.ErrNoRow() {
  3431. br.Msg = "获取信息失败"
  3432. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  3433. return
  3434. }
  3435. //isMaker := user.IsMaker
  3436. var sqlExport string
  3437. resp := new(models.ActivityTypeListHomeResp)
  3438. for k, v := range list {
  3439. // 如果是C类电话会就不展示内容,且合并到分析师电话会
  3440. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  3441. continue
  3442. }
  3443. var condition string
  3444. conditionActivity, err := services.GetActivityonditionList(user, strconv.Itoa(v.ActivityTypeId), chartPermissionIds, whichDay, activeState, "", isPower, 0, "")
  3445. if err != nil && err.Error() != utils.ErrNoRow() {
  3446. br.Msg = "获取失败"
  3447. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  3448. return
  3449. }
  3450. condition += `AND art.is_limit_people = 1 ` + conditionActivity
  3451. sortTime = ` mintimesort ASC `
  3452. labelList, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  3453. if err != nil {
  3454. br.Msg = "获取失败"
  3455. br.ErrMsg = "获取失败,Err:" + err.Error()
  3456. return
  3457. }
  3458. //标签字段关联的产业与标签处理
  3459. for k2, v2 := range labelList {
  3460. labelList[k2].KeyWord = services.LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
  3461. labelList[k2].ImgUrlBg = v.ImgUrlBgs
  3462. }
  3463. list[k].List = labelList
  3464. list[k].Resource = 1
  3465. }
  3466. //userType = 1
  3467. //查询专项产业调研展示权限
  3468. if whichDay == "" {
  3469. var condition string
  3470. condition = ` AND art.publish_status = 1 AND art.label != '' `
  3471. if isPower == 1 {
  3472. condition += permissionSqlStr
  3473. }
  3474. //行业名称
  3475. if len(chartPermissionIds) > 0 {
  3476. condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  3477. }
  3478. var conditionOr string
  3479. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  3480. conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  3481. }
  3482. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  3483. conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  3484. }
  3485. if userType == 1 {
  3486. conditionOr += ` OR (1=1 ` + condition + permissionSqlStr + `) `
  3487. }
  3488. if companyProduct != nil {
  3489. if companyProduct.Scale != "" {
  3490. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  3491. }
  3492. }
  3493. condition += sqlExport + conditionOr
  3494. specialList, err := models.GetActivityLabelSpecialListAll(condition, pars, startSize, 8)
  3495. if err != nil {
  3496. br.Msg = "获取失败"
  3497. br.ErrMsg = "获取失败,Err:" + err.Error()
  3498. return
  3499. }
  3500. for k2, v2 := range specialList {
  3501. specialList[k2].KeyWord = services.LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
  3502. specialList[k2].ImgUrlBg = "https://hzstatic.hzinsights.com/static/temp/20220426202204/20220426/XDLLsjC9XAAy8LIzQr7GsjrBbtX6.png"
  3503. specialList[k2].ImgUrlBg = utils.ACTIVITY_ZXDY_ImgUrl3
  3504. }
  3505. itemList := new(models.ActivityTypeHome)
  3506. itemList.ActivityTypeName = "专项产业调研"
  3507. itemList.Resource = 2
  3508. itemList.List = specialList
  3509. itemList.ActivityTypeId = 7
  3510. //itemList.ImgUrl = "https://hzstatic.hzinsights.com/static/temp/20220427202204/20220427/b2Bj3fGakP16iJRFKisQohCWnCNl.png"
  3511. itemList.ImgUrl = utils.ACTIVITY_ZXDY_ImgUrl1
  3512. //itemList.ImgUrlBg = "https://hzstatic.hzinsights.com/static/temp/20220427202204/20220427/OkunjfKEgo5KRLifzwwLX8cDZnnN.png"
  3513. itemList.ImgUrlBg = utils.ACTIVITY_ZXDY_ImgUrl2
  3514. list = append(list, itemList)
  3515. }
  3516. //获取对应活动的数量并排序
  3517. activityIds := make([]int, 0) // 用于查询活动【新】标签Map
  3518. intArr := make([]int, 0)
  3519. var items []*models.ActivityTypeHome
  3520. for _, v := range list {
  3521. item := new(models.ActivityTypeHome)
  3522. if len(v.List) > 0 {
  3523. for i := range v.List {
  3524. activityIds = append(activityIds, v.List[i].ActivityId)
  3525. }
  3526. item.List = v.List
  3527. item.ActivityTypeName = v.ActivityTypeName
  3528. item.ActivityTypeId = v.ActivityTypeId
  3529. item.ImgUrlBg = v.ImgUrlBg
  3530. item.ImgUrl = v.ImgUrl
  3531. item.Resource = v.Resource
  3532. items = append(items, item)
  3533. intArr = append(intArr, len(v.List))
  3534. }
  3535. }
  3536. sort.Sort(sort.Reverse(sort.IntSlice(intArr)))
  3537. // 活动【新】标签Map
  3538. newLabelMap, _, e := services.GetActivityNewLabelMap(activityIds)
  3539. if e != nil {
  3540. br.Msg = "获取失败"
  3541. br.ErrMsg = "获取活动【新】标签Map失败, Err: " + e.Error()
  3542. return
  3543. }
  3544. for k := range list {
  3545. for k2 := range list[k].List {
  3546. list[k].List[k2].IsNew = newLabelMap[list[k].List[k2].ActivityId]
  3547. }
  3548. }
  3549. var itemsNew []*models.ActivityTypeHome
  3550. activityMap := make(map[int]int)
  3551. for _, v := range intArr {
  3552. for _, v2 := range items {
  3553. item := new(models.ActivityTypeHome)
  3554. if len(v2.List) > 0 && v == len(v2.List) && activityMap[v2.ActivityTypeId] == 0 {
  3555. item.List = v2.List
  3556. item.ActivityTypeName = v2.ActivityTypeName
  3557. item.ActivityTypeId = v2.ActivityTypeId
  3558. item.ImgUrlBg = v2.ImgUrlBg
  3559. item.ImgUrl = v2.ImgUrl
  3560. item.Resource = v2.Resource
  3561. itemsNew = append(itemsNew, item)
  3562. activityMap[v2.ActivityTypeId] = len(v2.List)
  3563. }
  3564. }
  3565. }
  3566. //按照像素进行排序
  3567. rowHeight := 83 //每一行的行高
  3568. basicsHeight := 178 // 基础高度
  3569. position := 1 // 初始化位置 ,1,左边, 2 右边
  3570. var leftPx, rightPx int
  3571. for k, v := range itemsNew {
  3572. if leftPx <= rightPx {
  3573. position = 1
  3574. } else {
  3575. position = 2
  3576. }
  3577. itemsNew[k].Position = position
  3578. if position == 1 {
  3579. leftPx += basicsHeight + rowHeight*len(v.List)
  3580. } else {
  3581. rightPx += basicsHeight + rowHeight*len(v.List)
  3582. }
  3583. }
  3584. //记录用户搜索的筛选条件
  3585. item := new(models.CygxActivitySearchHistory)
  3586. item.UserId = user.UserId
  3587. item.Mobile = user.Mobile
  3588. item.CompanyId = user.CompanyId
  3589. item.CompanyName = user.CompanyName
  3590. item.CreateTime = time.Now()
  3591. item.ChartPermissionIds = chartPermissionIds
  3592. item.IsPower = isPower
  3593. item.WhichDay = whichDay
  3594. go models.AddCygxActivitySearchHistory(item)
  3595. resp.List = itemsNew
  3596. br.Ret = 200
  3597. br.Success = true
  3598. br.Msg = "获取成功"
  3599. br.Data = resp
  3600. }
  3601. // @Title 专项产业调研列表
  3602. // @Description 获取专项产业调研列表接口
  3603. // @Param PageSize query int true "每页数据条数"
  3604. // @Param CurrentIndex query int true "当前页页码,从1开始"
  3605. // @Success 200 {object} models.GetCygxActivitySpecialDetailListResp
  3606. // @router /special/list [get]
  3607. func (this *ActivityCoAntroller) SpecialList() {
  3608. br := new(models.BaseResponse).Init()
  3609. defer func() {
  3610. this.Data["json"] = br
  3611. this.ServeJSON()
  3612. }()
  3613. user := this.User
  3614. if user == nil {
  3615. br.Msg = "请登录"
  3616. br.ErrMsg = "请登录,SysUser Is Empty"
  3617. return
  3618. }
  3619. uid := user.UserId
  3620. pageSize, _ := this.GetInt("PageSize")
  3621. currentIndex, _ := this.GetInt("CurrentIndex")
  3622. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  3623. var startSize int
  3624. if pageSize <= 0 {
  3625. pageSize = utils.PageSize20
  3626. }
  3627. if currentIndex <= 0 {
  3628. currentIndex = 1
  3629. }
  3630. startSize = utils.StartIndex(currentIndex, pageSize)
  3631. var condition string
  3632. var pars []interface{}
  3633. //活动可见限制
  3634. var sqlExport string
  3635. slicePer := strings.Split(permissionStr, ",")
  3636. var permissionSqlStr string
  3637. for _, v := range slicePer {
  3638. if userType == 1 {
  3639. //if v != "研选" {
  3640. if !strings.Contains(v, "研选") {
  3641. permissionSqlStr += "'" + v + "',"
  3642. }
  3643. } else {
  3644. permissionSqlStr += "'" + v + "',"
  3645. }
  3646. }
  3647. //判断客户规模是否属于可见范围的活动
  3648. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  3649. if err != nil && err.Error() != utils.ErrNoRow() {
  3650. br.Msg = "获取信息失败"
  3651. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  3652. return
  3653. }
  3654. permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
  3655. permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
  3656. permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
  3657. permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionSqlStr + `)`
  3658. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  3659. if userType == 2 {
  3660. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  3661. }
  3662. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  3663. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  3664. }
  3665. sqlExport += `) `
  3666. condition += ` AND art.publish_status = 1 `
  3667. condition = ` AND art.publish_status = 1 AND art.label != '' `
  3668. var conditionOr string
  3669. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  3670. conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  3671. }
  3672. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  3673. conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  3674. }
  3675. if userType == 1 {
  3676. conditionOr += ` OR ( 1=1` + condition + permissionSqlStr + `) `
  3677. }
  3678. if companyProduct != nil {
  3679. if companyProduct.Scale != "" {
  3680. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  3681. }
  3682. }
  3683. if companyProduct != nil {
  3684. if companyProduct.Scale != "" {
  3685. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  3686. }
  3687. }
  3688. condition += sqlExport + conditionOr
  3689. total, err := models.GetActivitySpecialCount(condition, pars)
  3690. if err != nil {
  3691. br.Msg = "获取失败"
  3692. br.ErrMsg = "获取失败,Err:" + err.Error()
  3693. return
  3694. }
  3695. list, errList := models.GetCygxActivitySpecialDetailList(condition, pars, uid, startSize, pageSize)
  3696. if errList != nil {
  3697. br.Msg = "获取失败"
  3698. br.ErrMsg = "获取失败,Err:" + errList.Error()
  3699. return
  3700. }
  3701. detail, err := models.GetConfigByCode("city_img_url")
  3702. if err != nil {
  3703. br.Msg = "获取数据失败"
  3704. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  3705. return
  3706. }
  3707. detailChart, err := models.GetConfigByCode("chart_img_url")
  3708. if err != nil {
  3709. br.Msg = "获取数据失败"
  3710. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  3711. return
  3712. }
  3713. addressList := strings.Split(detail.ConfigValue, "{|}")
  3714. mapAddress := make(map[string]string)
  3715. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  3716. mapChart := make(map[string]string)
  3717. var cityName string
  3718. var chartName string
  3719. var imgUrl string
  3720. var imgUrlChart string
  3721. for _, v := range addressList {
  3722. vslice := strings.Split(v, "_")
  3723. cityName = vslice[0]
  3724. imgUrl = vslice[len(vslice)-1]
  3725. mapAddress[cityName] = imgUrl
  3726. }
  3727. for _, v := range chartList {
  3728. vslice := strings.Split(v, "_")
  3729. chartName = vslice[0]
  3730. imgUrlChart = vslice[len(vslice)-1]
  3731. mapChart[chartName] = imgUrlChart
  3732. }
  3733. for k, v := range list {
  3734. list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  3735. if mapChart[v.ChartPermissionName] != "" {
  3736. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  3737. }
  3738. list[k].ActivityTypeName = "专项调研"
  3739. }
  3740. page := paging.GetPaging(currentIndex, pageSize, total)
  3741. resp := new(models.GetCygxActivitySpecialDetailListResp)
  3742. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  3743. if err != nil {
  3744. br.Msg = "获取数据失败!"
  3745. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3746. return
  3747. }
  3748. if count == 1 && user.UserId > 0 {
  3749. resp.IsFollow = true
  3750. }
  3751. if user.Mobile != "" {
  3752. resp.IsBindingMobile = true
  3753. }
  3754. resp.List = list
  3755. resp.Paging = page
  3756. br.Ret = 200
  3757. br.Success = true
  3758. br.Msg = "获取成功"
  3759. br.Data = resp
  3760. }
  3761. // @Title 专项产业调研详情
  3762. // @Description 获取专项产业调研详情接口
  3763. // @Param ActivityId query int true "活动ID"
  3764. // @Success Ret=200 {object} models.CygxActivitySpecialResp
  3765. // @router /special/detail [get]
  3766. func (this *ActivityCoAntroller) SpecialDetail() {
  3767. br := new(models.BaseResponse).Init()
  3768. defer func() {
  3769. this.Data["json"] = br
  3770. this.ServeJSON()
  3771. }()
  3772. user := this.User
  3773. if user == nil {
  3774. br.Msg = "请登录"
  3775. br.ErrMsg = "请登录,用户信息为空"
  3776. br.Ret = 408
  3777. return
  3778. }
  3779. uid := user.UserId
  3780. activityId, _ := this.GetInt("ActivityId")
  3781. if activityId < 1 {
  3782. br.Msg = "请输入活动ID"
  3783. return
  3784. }
  3785. resp := new(models.CygxActivitySpecialResp)
  3786. hasPermission := 0
  3787. activityInfo, err := models.GetCygxActivitySpecialDetailById(uid, activityId)
  3788. if err != nil && err.Error() != utils.ErrNoRow() {
  3789. br.Msg = "获取信息失败"
  3790. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  3791. return
  3792. }
  3793. if activityInfo == nil {
  3794. br.Msg = "活动不存在"
  3795. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  3796. return
  3797. }
  3798. applyCount, err := models.GetApplyRecordCount(uid)
  3799. if err != nil && err.Error() != utils.ErrNoRow() {
  3800. br.Msg = "获取信息失败"
  3801. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  3802. return
  3803. }
  3804. //获取FICC销售信息 如果是FICC的客户类型,则默认他申请过
  3805. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  3806. if err != nil && err.Error() != utils.ErrNoRow() {
  3807. br.Msg = "获取信息失败"
  3808. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  3809. return
  3810. }
  3811. if user.CompanyId <= 1 {
  3812. //companyDetailStatus = ""
  3813. } else {
  3814. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  3815. if err != nil {
  3816. br.Msg = "获取信息失败"
  3817. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3818. return
  3819. }
  3820. if companyPermission == "" {
  3821. if applyCount > 0 {
  3822. hasPermission = 4
  3823. } else {
  3824. if sellerItem != nil {
  3825. hasPermission = 5
  3826. } else {
  3827. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  3828. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  3829. if err != nil && err.Error() != utils.ErrNoRow() {
  3830. br.Msg = "获取信息失败"
  3831. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  3832. return
  3833. }
  3834. if sellerItemQy != nil {
  3835. hasPermission = 2
  3836. resp.SellerMobile = sellerItemQy.Mobile
  3837. resp.SellerName = sellerItemQy.RealName
  3838. } else {
  3839. hasPermission = 3
  3840. }
  3841. }
  3842. }
  3843. resp.HasPermission = hasPermission
  3844. resp.OperationMode = "Apply"
  3845. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  3846. br.Ret = 200
  3847. br.Success = true
  3848. br.Msg = "获取成功"
  3849. br.Data = resp
  3850. return
  3851. }
  3852. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  3853. if err != nil {
  3854. br.Msg = "获取信息失败!"
  3855. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3856. return
  3857. }
  3858. if companyDetail == nil {
  3859. br.Msg = "获取信息失败!"
  3860. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  3861. return
  3862. }
  3863. }
  3864. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  3865. if err != nil {
  3866. br.Msg = "获取信息失败"
  3867. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  3868. return
  3869. }
  3870. itemAct := new(models.ActivityDetail)
  3871. itemAct.CustomerTypeIds = activityInfo.CustomerTypeIds
  3872. noPower, err := services.GetShareNoPowe(itemAct, permissionStr, userType)
  3873. if err != nil {
  3874. br.Msg = "获取信息失败"
  3875. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  3876. return
  3877. }
  3878. //获取用户的产业规模,判断是否允许可见
  3879. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  3880. if err != nil && err.Error() != utils.ErrNoRow() {
  3881. br.Msg = "获取信息失败"
  3882. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  3883. return
  3884. }
  3885. if companyProduct != nil {
  3886. if companyProduct.Scale != "" {
  3887. if strings.Count(activityInfo.Scale, companyProduct.Scale) > 0 {
  3888. noPower = false
  3889. }
  3890. }
  3891. }
  3892. if noPower {
  3893. br.Msg = "您暂无查看该活动权限"
  3894. br.ErrMsg = "被分享客户不可见,获取信息失败"
  3895. br.IsSendEmail = false
  3896. return
  3897. }
  3898. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  3899. br.Msg = "您暂无查看该活动权限"
  3900. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  3901. return
  3902. }
  3903. //判断是否已经申请过
  3904. if user.CompanyId > 1 {
  3905. permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
  3906. if err != nil {
  3907. br.Msg = "获取信息失败"
  3908. br.ErrMsg = "获取客户权限信息失败,Err:" + err.Error()
  3909. return
  3910. }
  3911. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  3912. //冻结客户
  3913. if err != nil {
  3914. if err.Error() == utils.ErrNoRow() {
  3915. if applyCount > 0 {
  3916. hasPermission = 4
  3917. } else {
  3918. if sellerItem != nil {
  3919. hasPermission = 5
  3920. } else {
  3921. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  3922. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  3923. if err != nil && err.Error() != utils.ErrNoRow() {
  3924. br.Msg = "获取信息失败"
  3925. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  3926. return
  3927. }
  3928. if sellerItemQy != nil {
  3929. hasPermission = 2
  3930. resp.SellerMobile = sellerItemQy.Mobile
  3931. resp.SellerName = sellerItemQy.RealName
  3932. } else {
  3933. hasPermission = 3
  3934. }
  3935. }
  3936. }
  3937. resp.HasPermission = hasPermission
  3938. resp.OperationMode = "Apply"
  3939. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  3940. br.Ret = 200
  3941. br.Success = true
  3942. br.Msg = "获取成功"
  3943. br.Data = resp
  3944. return
  3945. } else {
  3946. br.Msg = "获取信息失败"
  3947. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  3948. return
  3949. }
  3950. }
  3951. var havePower bool
  3952. if strings.Contains(permissionStr, activityInfo.ActivityTypeName) {
  3953. havePower = true
  3954. }
  3955. if havePower {
  3956. hasPermission = 1
  3957. resp.HaqveJurisdiction = true
  3958. } else {
  3959. if permissionStr == "专家" {
  3960. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  3961. resp.MsgType = "Type"
  3962. } else {
  3963. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  3964. resp.MsgType = "Industry"
  3965. }
  3966. if companyItem.ProductId == 2 {
  3967. resp.SellerMobile = companyItem.Mobile
  3968. resp.SellerName = companyItem.SellerName
  3969. resp.OperationMode = "Call"
  3970. hasPermission = 2
  3971. } else {
  3972. hasPermission = 5
  3973. }
  3974. }
  3975. } else { //潜在客户
  3976. if applyCount > 0 {
  3977. hasPermission = 4
  3978. } else {
  3979. if sellerItem != nil {
  3980. hasPermission = 5
  3981. } else {
  3982. hasPermission = 3
  3983. }
  3984. }
  3985. resp.OperationMode = "Apply"
  3986. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  3987. }
  3988. if hasPermission == 1 {
  3989. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  3990. if err != nil {
  3991. br.Msg = "获取数据失败!"
  3992. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3993. return
  3994. }
  3995. if count == 1 {
  3996. resp.IsFollow = true
  3997. }
  3998. activityInfo.ActivityTypeName = "专项调研"
  3999. resp.Detail = activityInfo
  4000. }
  4001. resp.HasPermission = hasPermission
  4002. br.Ret = 200
  4003. br.Success = true
  4004. br.Msg = "获取成功"
  4005. br.Data = resp
  4006. }
  4007. // @Title 感兴趣、不感兴趣
  4008. // @Description 感兴趣、不感兴趣接口
  4009. // @Param request body models.ActivityIdRep true "type json string"
  4010. // @Success Ret=200 {object} models.SignupSpecialStatus
  4011. // @router /special/signup/add [post]
  4012. func (this *ActivityCoAntroller) SpecialSignupAdd() {
  4013. br := new(models.BaseResponse).Init()
  4014. defer func() {
  4015. this.Data["json"] = br
  4016. this.ServeJSON()
  4017. }()
  4018. user := this.User
  4019. if user == nil {
  4020. br.Msg = "请登录"
  4021. br.ErrMsg = "请登录,用户信息为空"
  4022. br.Ret = 408
  4023. return
  4024. }
  4025. uid := user.UserId
  4026. var req models.ActivityIdRep
  4027. resp := new(models.SignupSpecialStatus)
  4028. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  4029. if err != nil {
  4030. br.Msg = "参数解析异常!"
  4031. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  4032. return
  4033. }
  4034. activityId := req.ActivityId
  4035. hasPermission := 0
  4036. //判断是否已经申请过
  4037. applyCount, err := models.GetApplyRecordCount(uid)
  4038. if err != nil && err.Error() != utils.ErrNoRow() {
  4039. br.Msg = "获取信息失败"
  4040. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  4041. return
  4042. }
  4043. //获取FICC销售信息
  4044. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  4045. if err != nil && err.Error() != utils.ErrNoRow() {
  4046. br.Msg = "申请失败"
  4047. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  4048. return
  4049. }
  4050. activityInfo, errInfo := models.GetCygxActivitySpecialDetail(activityId)
  4051. if activityInfo == nil {
  4052. br.Msg = "操作失败"
  4053. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  4054. return
  4055. }
  4056. if errInfo != nil {
  4057. br.Msg = "操作失败"
  4058. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  4059. return
  4060. }
  4061. //HasPermission "1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
  4062. //var companyDetailStatus string
  4063. if user.CompanyId > 1 {
  4064. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  4065. if err != nil {
  4066. br.Msg = "获取信息失败"
  4067. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  4068. return
  4069. }
  4070. if companyPermission == "" {
  4071. if applyCount > 0 {
  4072. hasPermission = 4
  4073. } else {
  4074. if sellerItem != nil {
  4075. hasPermission = 5
  4076. } else {
  4077. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  4078. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  4079. if err != nil && err.Error() != utils.ErrNoRow() {
  4080. br.Msg = "获取信息失败"
  4081. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  4082. return
  4083. }
  4084. if sellerItemQy != nil {
  4085. hasPermission = 2
  4086. resp.SellerMobile = sellerItemQy.Mobile
  4087. resp.SellerName = sellerItemQy.RealName
  4088. } else {
  4089. hasPermission = 3
  4090. }
  4091. }
  4092. }
  4093. resp.HasPermission = hasPermission
  4094. resp.ActivityId = activityId
  4095. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  4096. br.Ret = 200
  4097. br.Success = true
  4098. br.Msg = "获取成功"
  4099. br.Data = resp
  4100. return
  4101. }
  4102. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  4103. if err != nil {
  4104. br.Msg = "获取信息失败!"
  4105. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  4106. return
  4107. }
  4108. if companyDetail == nil {
  4109. br.Msg = "获取信息失败!"
  4110. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  4111. return
  4112. }
  4113. }
  4114. var userType int
  4115. var permissionStr string
  4116. userType, permissionStr, err = services.GetUserType(user.CompanyId)
  4117. if err != nil {
  4118. br.Msg = "获取信息失败!"
  4119. br.ErrMsg = "获取失败,Err:" + err.Error()
  4120. return
  4121. }
  4122. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  4123. br.Msg = "您暂无查看该活动权限"
  4124. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  4125. return
  4126. }
  4127. if user.CompanyId > 1 {
  4128. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  4129. //冻结客户
  4130. if err != nil {
  4131. if err.Error() == utils.ErrNoRow() {
  4132. if applyCount > 0 {
  4133. hasPermission = 4
  4134. } else {
  4135. if sellerItem != nil {
  4136. hasPermission = 5
  4137. } else {
  4138. hasPermission = 3
  4139. }
  4140. }
  4141. resp.ActivityId = activityId
  4142. resp.HasPermission = hasPermission
  4143. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  4144. br.Ret = 200
  4145. br.Success = true
  4146. br.Msg = "获取成功"
  4147. br.Data = resp
  4148. return
  4149. } else {
  4150. br.Msg = "获取信息失败"
  4151. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  4152. return
  4153. }
  4154. }
  4155. //判断是否有权限
  4156. var havePower bool
  4157. if strings.Contains(permissionStr, activityInfo.ActivityTypeName) {
  4158. havePower = true
  4159. }
  4160. if havePower {
  4161. hasPermission = 1
  4162. } else {
  4163. if companyItem.ProductId == 2 {
  4164. hasPermission = 2
  4165. resp.SellerMobile = companyItem.Mobile
  4166. resp.SellerName = companyItem.SellerName
  4167. if permissionStr == "专家" {
  4168. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  4169. } else {
  4170. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  4171. }
  4172. } else {
  4173. hasPermission = 5
  4174. }
  4175. }
  4176. } else { //潜在客户
  4177. if applyCount > 0 {
  4178. hasPermission = 4
  4179. } else {
  4180. if sellerItem != nil {
  4181. hasPermission = 5
  4182. } else {
  4183. hasPermission = 3
  4184. }
  4185. }
  4186. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  4187. }
  4188. resp.HasPermission = hasPermission
  4189. resp.ActivityId = activityId
  4190. if hasPermission == 1 {
  4191. total, err := models.GetUserCygxActivitySpecialSignup(user.UserId, activityId)
  4192. if err != nil {
  4193. br.Msg = "获取信息失败"
  4194. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  4195. return
  4196. }
  4197. //判断是删除还是添加
  4198. if total == 0 {
  4199. //获取销售信息
  4200. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  4201. if err != nil {
  4202. br.Msg = "操作失败"
  4203. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  4204. return
  4205. }
  4206. item := new(models.CygxActivitySpecialSignup)
  4207. item.UserId = uid
  4208. item.RealName = user.RealName
  4209. item.ActivityId = activityId
  4210. item.CreateTime = time.Now()
  4211. item.Mobile = user.Mobile
  4212. item.Email = user.Email
  4213. item.CompanyId = user.CompanyId
  4214. item.CompanyName = user.CompanyName
  4215. if sellerItem != nil {
  4216. item.SellerName = sellerItem.RealName
  4217. }
  4218. err = models.AddCygxActivitySpecialSignup(item)
  4219. if err != nil {
  4220. br.Msg = "操作失败"
  4221. br.ErrMsg = "操作失败,Err:" + err.Error()
  4222. return
  4223. }
  4224. resp.Status = 1
  4225. ////给所属销售发送消息
  4226. if sellerItem.Mobile != "" {
  4227. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  4228. if openIpItem != nil && openIpItem.OpenId != "" {
  4229. if sellerItem != nil {
  4230. go services.SendSpecialTemplateMsg(user.RealName+"【"+user.CompanyName+"】", time.Now().Format(utils.FormatDateTime), user.Mobile, activityInfo.ResearchTheme, "sale", openIpItem)
  4231. }
  4232. }
  4233. }
  4234. // 给芳姐发消息
  4235. cnf, _ := models.GetConfigByCode("tpl_msg")
  4236. if cnf != nil {
  4237. openIpItem, _ := models.GetUserRecordByMobile(4, cnf.ConfigValue)
  4238. if openIpItem != nil && openIpItem.OpenId != "" {
  4239. actList, _ := models.GetActivityListSpecialAll(activityId)
  4240. if len(actList) == 5 {
  4241. var companyName string
  4242. for _, v := range actList {
  4243. companyName += "【" + v.CompanyName + "】"
  4244. }
  4245. go services.SendSpecialTemplateMsg(companyName, "", "", activityInfo.ResearchTheme, "", openIpItem)
  4246. }
  4247. }
  4248. }
  4249. //用户专项调研操作行为,模板消息推送
  4250. go services.SpecialActivityUserRemind(user, activityInfo, 1)
  4251. } else {
  4252. err = models.DeleteCygxActivitySpecialSignup(user.UserId, activityId)
  4253. if err != nil {
  4254. br.Msg = "操作失败"
  4255. br.ErrMsg = "操作失败,Err:" + err.Error()
  4256. return
  4257. }
  4258. resp.Status = 2
  4259. }
  4260. }
  4261. br.Ret = 200
  4262. br.Success = true
  4263. br.Msg = "操作成功"
  4264. br.Data = resp
  4265. }
  4266. // @Title 新调研通知取消跟添加
  4267. // @Description 新调研通知取消跟添加接口
  4268. // @Param request body models.ArticleCollectResp true "type json string"
  4269. // @Success 200
  4270. // @router /special/follow [post]
  4271. func (this *ActivityCoAntroller) SpecialMsg() {
  4272. br := new(models.BaseResponse).Init()
  4273. defer func() {
  4274. this.Data["json"] = br
  4275. this.ServeJSON()
  4276. }()
  4277. user := this.User
  4278. if user == nil {
  4279. br.Msg = "请重新登录"
  4280. br.Ret = 408
  4281. return
  4282. }
  4283. resp := new(models.ArticleCollectResp)
  4284. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  4285. if err != nil {
  4286. br.Msg = "获取数据失败!"
  4287. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  4288. return
  4289. }
  4290. if count == 0 {
  4291. item := new(models.CygxUserFollowSpecial)
  4292. item.UserId = user.UserId
  4293. item.RealName = user.RealName
  4294. item.CreateTime = time.Now()
  4295. item.Mobile = user.Mobile
  4296. item.Email = user.Email
  4297. item.CompanyId = user.CompanyId
  4298. item.CompanyName = user.CompanyName
  4299. item.CreateTime = time.Now()
  4300. err := models.AddUserFollowSpecial(item)
  4301. if err != nil {
  4302. br.Msg = "操作失败!"
  4303. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  4304. return
  4305. }
  4306. resp.Status = 1
  4307. } else {
  4308. err := models.DeleteCygxUserFollowSpecial(user.UserId)
  4309. if err != nil {
  4310. br.Msg = "操作失败!"
  4311. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  4312. return
  4313. }
  4314. resp.Status = 2
  4315. }
  4316. br.Ret = 200
  4317. br.Data = resp
  4318. br.Success = true
  4319. br.Msg = "操作成功!"
  4320. }
  4321. // @Title 活动类型下的主题列表(6.0Pc版本)
  4322. // @Description 获取活动类型下的主题列表接口(6.0Pc版本)
  4323. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  4324. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  4325. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  4326. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  4327. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  4328. // @Success 200 {object} models.ActivityTypeListHomeRespPc
  4329. // @router /labelTypeListV6Pc [get]
  4330. func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
  4331. br := new(models.BaseResponse).Init()
  4332. defer func() {
  4333. this.Data["json"] = br
  4334. this.ServeJSON()
  4335. }()
  4336. user := this.User
  4337. if user == nil {
  4338. br.Msg = "请登录"
  4339. br.ErrMsg = "请登录,SysUser Is Empty"
  4340. return
  4341. }
  4342. pageSize, _ := this.GetInt("PageSize")
  4343. isPower, _ := this.GetInt("IsPower")
  4344. //currentIndex, _ := this.GetInt("CurrentIndex")
  4345. chartPermissionIds := this.GetString("ChartPermissionIds")
  4346. //activityTypeIds := this.GetString("ActivityTypeIds")
  4347. whichDay := this.GetString("WhichDay")
  4348. activeState := this.GetString("ActiveState")
  4349. //入参为 undefined 时的处理
  4350. if chartPermissionIds == "undefined" {
  4351. chartPermissionIds = ""
  4352. }
  4353. // 查研观向7.4-始终查询宏观的活动
  4354. if chartPermissionIds != "" {
  4355. chartPermissionIds += ",1"
  4356. }
  4357. if whichDay == "undefined" {
  4358. whichDay = ""
  4359. }
  4360. if activeState == "undefined" || activeState == "" || activeState == "1" {
  4361. activeState = "1,2"
  4362. }
  4363. //adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
  4364. //if err != nil {
  4365. // br.Msg = "获取失败"
  4366. // br.ErrMsg = "获取本组下的销售失败,Err:" + err.Error()
  4367. // return
  4368. //}
  4369. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  4370. if err != nil {
  4371. br.Msg = "获取失败"
  4372. br.ErrMsg = "获取失败,Err:" + err.Error()
  4373. return
  4374. }
  4375. //isMaker := user.IsMaker
  4376. var startSize int
  4377. pageSize = 8
  4378. var sortTime string
  4379. var pars []interface{}
  4380. //活动可见限制
  4381. slicePer := strings.Split(permissionStr, ",")
  4382. var permissionSqlStr string
  4383. var permissionNameStr string
  4384. for _, v := range slicePer {
  4385. if userType == 1 {
  4386. //if v != "研选" {
  4387. if !strings.Contains(v, "研选") {
  4388. permissionNameStr += "'" + v + "',"
  4389. }
  4390. } else {
  4391. permissionNameStr += "'" + v + "',"
  4392. }
  4393. }
  4394. permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
  4395. permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
  4396. permissionNameStr = strings.TrimRight(permissionNameStr, ",")
  4397. // 查研观向7.4-始终查询宏观的权限(无论是否有权限)
  4398. if permissionNameStr == `` {
  4399. permissionNameStr = `'宏观'`
  4400. } else {
  4401. permissionNameStr += `, '宏观'`
  4402. }
  4403. list, err := models.GetActivityTypeHomeListPc()
  4404. if err != nil {
  4405. br.Msg = "获取失败"
  4406. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  4407. return
  4408. }
  4409. //判断客户规模是否属于可见范围的活动
  4410. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  4411. if err != nil && err.Error() != utils.ErrNoRow() {
  4412. br.Msg = "获取信息失败"
  4413. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  4414. return
  4415. }
  4416. var sqlExport string
  4417. //处理专家权限的查询
  4418. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  4419. if userType == 2 {
  4420. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  4421. }
  4422. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  4423. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  4424. }
  4425. sqlExport += `) `
  4426. resp := new(models.ActivityTypeListHomeRespPc)
  4427. for k, v := range list {
  4428. // 如果是C类电话会就不展示内容,且合并到分析师电话会
  4429. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  4430. continue
  4431. }
  4432. var condition string
  4433. conditionActivity, err := services.GetActivityonditionList(user, strconv.Itoa(v.ActivityTypeId), chartPermissionIds, whichDay, activeState, "", isPower, 1, "")
  4434. if err != nil && err.Error() != utils.ErrNoRow() {
  4435. br.Msg = "获取失败"
  4436. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  4437. return
  4438. }
  4439. //condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  4440. condition += `AND art.is_limit_people = 1 AND art.yidong_activity_id = '' ` + conditionActivity
  4441. sortTime = ` mintimesort ASC `
  4442. labelList, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  4443. if err != nil {
  4444. br.Msg = "获取失败"
  4445. br.ErrMsg = "获取失败,Err:" + err.Error()
  4446. return
  4447. }
  4448. //标签字段关联的产业与标签处理
  4449. for k2, v2 := range labelList {
  4450. labelList[k2].KeyWord = services.LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
  4451. labelList[k2].Resource = 1
  4452. }
  4453. list[k].List = labelList
  4454. list[k].Resource = 1
  4455. }
  4456. if whichDay == "" {
  4457. //查询专项产业调研展示权限
  4458. var condition string
  4459. condition = ` AND art.publish_status = 1 AND art.label != '' `
  4460. if isPower == 1 {
  4461. condition += permissionSqlStr
  4462. }
  4463. //行业名称
  4464. if len(chartPermissionIds) > 0 {
  4465. condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  4466. }
  4467. var conditionOr string
  4468. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  4469. conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  4470. }
  4471. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  4472. conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  4473. }
  4474. if userType == 1 {
  4475. conditionOr += ` OR (1=1 ` + condition + permissionSqlStr + `) `
  4476. }
  4477. if companyProduct != nil {
  4478. if companyProduct.Scale != "" {
  4479. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  4480. }
  4481. }
  4482. condition += sqlExport + conditionOr
  4483. specialList, err := models.GetActivityLabelSpecialListAll(condition, pars, startSize, 8)
  4484. if err != nil {
  4485. br.Msg = "获取失败"
  4486. br.ErrMsg = "获取失败,Err:" + err.Error()
  4487. return
  4488. }
  4489. for k2, v2 := range specialList {
  4490. specialList[k2].KeyWord = services.LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
  4491. specialList[k2].Resource = 2
  4492. }
  4493. itemList := new(models.ActivityTypeHomePc)
  4494. itemList.ActivityTypeName = "专项产业调研"
  4495. itemList.Resource = 2
  4496. itemList.List = specialList
  4497. itemList.ActivityTypeId = 7
  4498. itemList.OnlineIco = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/0H4md6VgZMuIttggMUnJxgrlayxC.png"
  4499. itemList.ImgUrlBgPc = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/rFwAM1c4fIMJM0EGoUkUYl25XH9L.png"
  4500. list = append(list, itemList)
  4501. }
  4502. // 查研观向7.4-活动【新】标签
  4503. activityIds := make([]int, 0)
  4504. for _, v := range list {
  4505. if len(v.List) > 0 {
  4506. for i := range v.List {
  4507. activityIds = append(activityIds, v.List[i].ActivityId)
  4508. }
  4509. }
  4510. }
  4511. newLabelMap, _, e := services.GetActivityNewLabelMap(activityIds)
  4512. if e != nil {
  4513. br.Msg = "获取失败"
  4514. br.ErrMsg = "获取活动【新】标签Map失败, Err: " + e.Error()
  4515. return
  4516. }
  4517. for k := range list {
  4518. for k2 := range list[k].List {
  4519. list[k].List[k2].IsNew = newLabelMap[list[k].List[k2].ActivityId]
  4520. }
  4521. }
  4522. //记录用户搜索的筛选条件
  4523. {
  4524. item := new(models.CygxActivitySearchHistory)
  4525. item.UserId = user.UserId
  4526. item.Mobile = user.Mobile
  4527. item.CompanyId = user.CompanyId
  4528. item.CompanyName = user.CompanyName
  4529. item.CreateTime = time.Now()
  4530. item.ChartPermissionIds = chartPermissionIds
  4531. item.IsPower = isPower
  4532. item.WhichDay = whichDay
  4533. go models.AddCygxActivitySearchHistory(item)
  4534. }
  4535. resp.List = list
  4536. br.Ret = 200
  4537. br.Success = true
  4538. br.Msg = "获取成功"
  4539. br.Data = resp
  4540. }
  4541. // @Title 预约纪要
  4542. // @Description 预约纪要接口
  4543. // @Param request body models.ActivityIdRep true "type json string"
  4544. // @Success Ret=200 {object} models.AppointmentResp
  4545. // @router /appointment/add [post]
  4546. func (this *ActivityCoAntroller) ActivityAppointmentAdd() {
  4547. br := new(models.BaseResponse).Init()
  4548. defer func() {
  4549. this.Data["json"] = br
  4550. this.ServeJSON()
  4551. }()
  4552. user := this.User
  4553. if user == nil {
  4554. br.Msg = "请登录"
  4555. br.ErrMsg = "请登录,用户信息为空"
  4556. br.Ret = 408
  4557. return
  4558. }
  4559. uid := user.UserId
  4560. signupStatus := "Success"
  4561. var req models.ActivityIdRep
  4562. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  4563. if err != nil {
  4564. br.Msg = "参数解析异常!"
  4565. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  4566. return
  4567. }
  4568. activityId := req.ActivityId
  4569. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  4570. if activityInfo == nil {
  4571. br.Msg = "操作失败"
  4572. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  4573. return
  4574. }
  4575. if errInfo != nil {
  4576. br.Msg = "操作失败"
  4577. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  4578. return
  4579. }
  4580. //判断是否已经预约过
  4581. totalAppointment, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  4582. if err != nil {
  4583. br.Msg = "获取失败"
  4584. br.ErrMsg = "获取失败,Err:" + err.Error()
  4585. return
  4586. }
  4587. if totalAppointment > 0 {
  4588. br.Msg = "您已预约!"
  4589. return
  4590. }
  4591. //判断是否已经申请过
  4592. applyCount, err := models.GetApplyRecordCount(uid)
  4593. if err != nil && err.Error() != utils.ErrNoRow() {
  4594. br.Msg = "获取信息失败"
  4595. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  4596. return
  4597. }
  4598. //获取销售信息
  4599. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  4600. if err != nil && err.Error() != utils.ErrNoRow() {
  4601. br.Msg = "申请失败"
  4602. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  4603. return
  4604. }
  4605. //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  4606. item := new(models.CygxActivityAppointment)
  4607. resp := new(models.SignupStatus)
  4608. hasPermission := 0
  4609. var companyDetailStatus string
  4610. if user.CompanyId <= 1 {
  4611. companyDetailStatus = ""
  4612. } else {
  4613. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  4614. if err != nil {
  4615. br.Msg = "获取信息失败"
  4616. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  4617. return
  4618. }
  4619. if companyPermission == "" {
  4620. if applyCount > 0 {
  4621. hasPermission = 4
  4622. } else {
  4623. if sellerItem != nil {
  4624. hasPermission = 5
  4625. } else {
  4626. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  4627. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  4628. if err != nil && err.Error() != utils.ErrNoRow() {
  4629. br.Msg = "获取信息失败"
  4630. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  4631. return
  4632. }
  4633. if sellerItemQy != nil {
  4634. hasPermission = 2
  4635. resp.SellerMobile = sellerItemQy.Mobile
  4636. resp.SellerName = sellerItemQy.RealName
  4637. } else {
  4638. hasPermission = 3
  4639. }
  4640. }
  4641. }
  4642. resp.ActivityId = activityId
  4643. resp.HasPermission = hasPermission
  4644. resp.OperationMode = "Apply"
  4645. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  4646. br.Ret = 200
  4647. br.Success = true
  4648. br.Msg = "获取成功"
  4649. br.Data = resp
  4650. return
  4651. }
  4652. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  4653. if err != nil {
  4654. br.Msg = "获取信息失败!"
  4655. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  4656. return
  4657. }
  4658. if companyDetail == nil {
  4659. br.Msg = "获取信息失败!"
  4660. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  4661. return
  4662. }
  4663. companyDetailStatus = companyDetail.Status
  4664. }
  4665. var userType int
  4666. var permissionStr string
  4667. userType, permissionStr, err = services.GetUserType(user.CompanyId)
  4668. if err != nil {
  4669. br.Msg = "获取信息失败!"
  4670. br.ErrMsg = "获取失败,Err:" + err.Error()
  4671. return
  4672. }
  4673. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  4674. br.Msg = "您暂无查看该活动权限"
  4675. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  4676. return
  4677. }
  4678. if user.CompanyId > 1 {
  4679. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  4680. //冻结客户
  4681. if err != nil {
  4682. if err.Error() == utils.ErrNoRow() {
  4683. //如果是FICC的客户类型,则默认他申请过
  4684. if applyCount > 0 {
  4685. hasPermission = 4
  4686. } else {
  4687. if sellerItem != nil {
  4688. hasPermission = 5
  4689. } else {
  4690. hasPermission = 3
  4691. }
  4692. }
  4693. resp.ActivityId = activityId
  4694. resp.HasPermission = hasPermission
  4695. resp.OperationMode = "Apply"
  4696. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  4697. br.Ret = 200
  4698. br.Success = true
  4699. br.Msg = "获取成功"
  4700. br.Data = resp
  4701. return
  4702. } else {
  4703. br.Msg = "获取信息失败"
  4704. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  4705. return
  4706. }
  4707. }
  4708. havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
  4709. if err != nil {
  4710. br.Msg = "获取信息失败!"
  4711. br.ErrMsg = "获取失败,Err:" + err.Error()
  4712. return
  4713. }
  4714. if havePower {
  4715. hasPermission = 1
  4716. signupStatus = "Success"
  4717. totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  4718. if errMeeting != nil {
  4719. br.Msg = "获取失败"
  4720. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  4721. return
  4722. }
  4723. if totalMeeting > 0 {
  4724. br.Msg = "您已预约,请勿重复预约"
  4725. return
  4726. }
  4727. var sellerName string
  4728. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  4729. if err != nil {
  4730. br.Msg = "报名失败!"
  4731. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  4732. return
  4733. }
  4734. item.UserId = uid
  4735. item.ActivityId = activityId
  4736. item.CreateTime = time.Now()
  4737. item.Mobile = user.Mobile
  4738. item.Email = user.Email
  4739. item.CompanyId = user.CompanyId
  4740. item.CompanyName = user.CompanyName
  4741. item.SellerName = sellerName
  4742. item.RealName = user.RealName
  4743. err = models.AddCygxActivityAppointment(item)
  4744. if err != nil {
  4745. br.Msg = "操作失败"
  4746. br.ErrMsg = "操作失败,Err:" + err.Error()
  4747. return
  4748. }
  4749. resp.HaqveJurisdiction = true
  4750. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  4751. go services.ActivityUserRemind(user, activityInfo, 3)
  4752. } else {
  4753. if companyItem.ProductId == 2 {
  4754. hasPermission = 2
  4755. resp.SellerMobile = companyItem.Mobile
  4756. resp.SellerName = companyItem.SellerName
  4757. resp.MsgType = "Type"
  4758. resp.OperationMode = "Call"
  4759. if permissionStr == "专家" {
  4760. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  4761. resp.MsgType = "Type"
  4762. } else {
  4763. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  4764. resp.MsgType = "Industry"
  4765. }
  4766. } else {
  4767. hasPermission = 5
  4768. }
  4769. }
  4770. } else { //潜在客户
  4771. if applyCount > 0 {
  4772. hasPermission = 4
  4773. } else {
  4774. if sellerItem != nil {
  4775. hasPermission = 5
  4776. } else {
  4777. hasPermission = 3
  4778. }
  4779. }
  4780. resp.OperationMode = "Apply"
  4781. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  4782. }
  4783. resp.HasPermission = hasPermission
  4784. resp.SignupStatus = signupStatus
  4785. resp.ActivityId = activityId
  4786. var total int
  4787. total, err = models.GetUserCygxActivityAppointmentCountByUid(user.UserId)
  4788. if err != nil {
  4789. br.Msg = "获取信息失败"
  4790. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  4791. return
  4792. }
  4793. if total <= 1 {
  4794. resp.GoFollow = true
  4795. }
  4796. br.Ret = 200
  4797. br.Success = true
  4798. if hasPermission == 1 {
  4799. br.Msg = "请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
  4800. }
  4801. br.Data = resp
  4802. }
  4803. // @Title 取消预约纪要
  4804. // @Description 取消预约纪要接口
  4805. // @Param request body models.ActivityIdRep true "type json string"
  4806. // @Success Ret=200 {object} models.SignupStatus
  4807. // @router /appointment/cancel [post]
  4808. func (this *ActivityCoAntroller) ActivityAppointmentCancel() {
  4809. br := new(models.BaseResponse).Init()
  4810. defer func() {
  4811. this.Data["json"] = br
  4812. this.ServeJSON()
  4813. }()
  4814. user := this.User
  4815. if user == nil {
  4816. br.Msg = "请登录"
  4817. br.ErrMsg = "请登录,用户信息为空"
  4818. br.Ret = 408
  4819. return
  4820. }
  4821. uid := user.UserId
  4822. var req models.ActivityIdRep
  4823. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  4824. if err != nil {
  4825. br.Msg = "参数解析异常!"
  4826. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  4827. return
  4828. }
  4829. activityId := req.ActivityId
  4830. signupStatus := "Success"
  4831. item := new(models.CygxActivityAppointment)
  4832. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  4833. if activityInfo == nil {
  4834. br.Msg = "操作失败"
  4835. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  4836. return
  4837. }
  4838. if errInfo != nil {
  4839. br.Msg = "操作失败"
  4840. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  4841. return
  4842. }
  4843. total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  4844. if err != nil {
  4845. br.Msg = "获取失败"
  4846. br.ErrMsg = "获取失败,Err:" + err.Error()
  4847. return
  4848. }
  4849. if total == 0 {
  4850. br.Msg = "您暂未预约该纪要"
  4851. return
  4852. }
  4853. item.UserId = uid
  4854. item.ActivityId = activityId
  4855. item.CreateTime = time.Now()
  4856. item.Mobile = user.Mobile
  4857. item.Email = user.Email
  4858. item.CompanyId = user.CompanyId
  4859. item.CompanyName = user.CompanyName
  4860. _, errSignup := models.CancelcygxActivityAppointment(item)
  4861. if errSignup != nil {
  4862. br.Msg = "操作失败"
  4863. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  4864. return
  4865. }
  4866. resp := new(models.SignupStatus)
  4867. resp.SignupStatus = signupStatus
  4868. resp.ActivityId = activityId
  4869. br.Ret = 200
  4870. br.Success = true
  4871. br.Msg = "已取消"
  4872. br.Data = resp
  4873. }
  4874. // @Title 记录用户浏览音频回放接口
  4875. // @Description 记录用户浏览音频回放接口
  4876. // @Param request body models.ActivityIdRep true "type json string"
  4877. // @Success Ret=200 {object} models.AppointmentResp
  4878. // @router /voiceHistory/add [post]
  4879. func (this *ActivityCoAntroller) ActivityVoiceHistoryAdd() {
  4880. br := new(models.BaseResponse).Init()
  4881. defer func() {
  4882. this.Data["json"] = br
  4883. this.ServeJSON()
  4884. }()
  4885. user := this.User
  4886. if user == nil {
  4887. br.Msg = "请登录"
  4888. br.ErrMsg = "请登录,用户信息为空"
  4889. br.Ret = 408
  4890. return
  4891. }
  4892. uid := user.UserId
  4893. var req models.ActivityIdRep
  4894. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  4895. if err != nil {
  4896. br.Msg = "参数解析异常!"
  4897. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  4898. return
  4899. }
  4900. activityId := req.ActivityId
  4901. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  4902. if activityInfo == nil {
  4903. br.Msg = "操作失败"
  4904. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  4905. return
  4906. }
  4907. if errInfo != nil {
  4908. br.Msg = "操作失败"
  4909. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  4910. return
  4911. }
  4912. var sellerName string
  4913. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  4914. if err != nil {
  4915. br.Msg = "报名失败!"
  4916. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  4917. return
  4918. }
  4919. item := new(models.CygxActivityVoiceHistory)
  4920. item.UserId = uid
  4921. item.ActivityId = activityId
  4922. item.CreateTime = time.Now()
  4923. item.Mobile = user.Mobile
  4924. item.Email = user.Email
  4925. item.CompanyId = user.CompanyId
  4926. item.CompanyName = user.CompanyName
  4927. item.SellerName = sellerName
  4928. item.RealName = user.RealName
  4929. err = models.AddCygxActivityVoiceHistory(item)
  4930. if err != nil {
  4931. br.Msg = "操作失败"
  4932. br.ErrMsg = "操作失败,Err:" + err.Error()
  4933. return
  4934. }
  4935. br.Ret = 200
  4936. br.Success = true
  4937. br.Msg = "操作成功"
  4938. return
  4939. }