activity.go 148 KB

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