activity.go 147 KB

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