activity.go 136 KB

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