activity.go 136 KB

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