activity.go 131 KB

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