activity.go 162 KB

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