activity.go 136 KB

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