activity.go 148 KB

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