activity.go 153 KB

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