activity.go 140 KB

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