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