activity.go 154 KB

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