activity.go 137 KB

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