activity.go 132 KB

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