activity.go 122 KB

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