report.go 150 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/medivhzhan/weapp/v2"
  6. "github.com/rdlucklib/rdluck_tools/paging"
  7. "hongze/hongze_cygx/models"
  8. "hongze/hongze_cygx/services"
  9. "hongze/hongze_cygx/utils"
  10. "html"
  11. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. // 报告
  16. type ReportController struct {
  17. BaseAuthController
  18. }
  19. type ReportCommonController struct {
  20. BaseCommonController
  21. }
  22. // @Title 行业报告分类列表接口
  23. // @Description 获取行业报告分类列表接口
  24. // @Param ChartPermissionId query int true "分类ID"
  25. // @Success 200 {object} models.IndustrialManagementList
  26. // @router /home/tradeList [get]
  27. func (this *ReportController) TradeList() {
  28. br := new(models.BaseResponse).Init()
  29. defer func() {
  30. this.Data["json"] = br
  31. this.ServeJSON()
  32. }()
  33. user := this.User
  34. if user == nil {
  35. br.Msg = "请重新登录"
  36. br.Ret = 408
  37. return
  38. }
  39. //uid := user.UserId
  40. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  41. if ChartPermissionId < 1 {
  42. br.Msg = "请输入分类ID"
  43. return
  44. }
  45. listCategory, err := models.GetTradeArticleAndProductInterior(ChartPermissionId)
  46. if err != nil {
  47. br.Msg = "获取信息失败"
  48. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  49. return
  50. }
  51. var list []*models.TradeReportMapping
  52. categoryMap := make(map[int]int)
  53. for _, v := range listCategory {
  54. if categoryMap[v.CategoryId] > 0 {
  55. continue
  56. }
  57. categoryMap[v.CategoryId] = v.CategoryId
  58. list = append(list, v)
  59. }
  60. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  61. //if ChartPermissionId == utils.KE_JI_ID {
  62. // list = append(list, &models.TradeReportMapping{MatchTypeName: "AI前沿", CategoryId: utils.ACTEGORY_ID_AI_QY})
  63. //}
  64. //var condition string
  65. //var pars []interface{}
  66. for k, v := range list {
  67. //if v.PolymerizationId != "" {
  68. // condition = ` AND a.category_id IN(` + v.PolymerizationId + `)`
  69. //} else {
  70. // condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
  71. //}
  72. pageSize := 1
  73. var listArticle []*models.ReportArticle
  74. if v.CategoryId == utils.ACTEGORY_ID_AI_QY {
  75. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  76. listArticle, _, err = services.GetAiQianYanArtilceList(0, pageSize)
  77. if err != nil && err.Error() != utils.ErrNoRow() {
  78. br.Msg = "获取信息失败"
  79. br.Msg = "GetHomeList,Err:" + err.Error()
  80. return
  81. }
  82. //for _, vAi := range listArticleAi {
  83. // listArticle = append(listArticle, &models.ReportArticle{
  84. // CategoryId: vAi.CategoryId,
  85. // PublishDate: vAi.PublishDate,
  86. // })
  87. //}
  88. } else {
  89. listArticle, _, err = models.GetReportAndproductIndustrylList(v.CategoryId, 0, pageSize)
  90. if err != nil && err.Error() != utils.ErrNoRow() {
  91. br.Msg = "获取信息失败"
  92. br.Msg = "GetHomeList,Err:" + err.Error()
  93. return
  94. }
  95. }
  96. //listArticle, _, err := models.GetReportAndproductIndustrylList(v.CategoryId, 0, 1)
  97. if len(listArticle) > 0 {
  98. list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式 }
  99. }
  100. }
  101. resp := new(models.TradeReportMappingResp)
  102. resp.List = list
  103. br.Ret = 200
  104. br.Success = true
  105. br.Msg = "获取成功"
  106. br.Data = resp
  107. }
  108. // @Title 产业报告分类列表接口
  109. // @Description 获取产业报告分类列表接口
  110. // @Param ChartPermissionId query int true "分类ID"
  111. // @Param IsNewLabel query string true "是否属于新标签,1是,0否"
  112. // @Param IsDeepLabel query string true "是否属于深标签,1是,0否"
  113. // @Param KeyWord query string true "搜索关键词"
  114. // @Param OrderColumn query int true "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
  115. // @Param DeepCover query int false "深度覆盖:0-否;1-是"
  116. // @Param RecommendFocus query int false "推荐关注:0-否;1-是"
  117. // @Param IsOpen query int true "是否展开:0-否;1-是,默认0"
  118. // @Param PageSize query int true "每页数据条数"
  119. // @Param CurrentIndex query int true "当前页页码,从1开始"
  120. // @Success 200 {object} models.IndustrialManagementList
  121. // @router /home/industryList [get]
  122. func (this *ReportController) IndustryList() {
  123. br := new(models.BaseResponse).Init()
  124. defer func() {
  125. this.Data["json"] = br
  126. this.ServeJSON()
  127. }()
  128. user := this.User
  129. if user == nil {
  130. br.Msg = "请重新登录"
  131. br.Ret = 408
  132. return
  133. }
  134. uid := user.UserId
  135. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  136. orderColumn := this.GetString("OrderColumn")
  137. orderColumnNew := this.GetString("OrderColumn")
  138. isNewLabel := this.GetString("IsNewLabel")
  139. isDeepLabel := this.GetString("IsDeepLabel")
  140. keyWord := this.GetString("KeyWord")
  141. pageSize, _ := this.GetInt("PageSize")
  142. currentIndex, _ := this.GetInt("CurrentIndex")
  143. deepCover, _ := this.GetInt("DeepCover")
  144. recommendFocus, _ := this.GetInt("RecommendFocus")
  145. isOpen, _ := this.GetInt("IsOpen")
  146. var orderSrt string
  147. var condition string
  148. var startSize int
  149. resp := new(models.IndustrialManagementList)
  150. if pageSize <= 0 {
  151. pageSize = utils.PageSize20
  152. }
  153. if currentIndex <= 0 {
  154. currentIndex = 1
  155. }
  156. startSize = paging.StartIndex(currentIndex, pageSize)
  157. if isNewLabel == "1" {
  158. condition += ` AND is_new_label = ` + isNewLabel
  159. }
  160. if isDeepLabel == "1" {
  161. condition += ` AND is_deep_label = ` + isDeepLabel
  162. }
  163. if keyWord != "" {
  164. condition += ` AND subject_names LIKE '%` + keyWord + `%'`
  165. }
  166. var sqlChartPermissionId string
  167. if ChartPermissionId > 0 {
  168. sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
  169. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  170. }
  171. // 深度覆盖
  172. if deepCover == 1 {
  173. // 查询深标签产业报告数
  174. var deepCondition string
  175. var deepPars []interface{}
  176. deepCondition += ` AND man.is_deep_label = 1`
  177. if ChartPermissionId > 0 {
  178. deepCondition += ` AND man.chart_permission_id = ?`
  179. deepPars = append(deepPars, ChartPermissionId)
  180. }
  181. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  182. if e != nil {
  183. br.Msg = "获取信息失败"
  184. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  185. return
  186. }
  187. deepIdArr := make([]string, 0)
  188. for i := range industryCountList {
  189. if industryCountList[i].ArtNum > 10 {
  190. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  191. }
  192. }
  193. deepIds := strings.Join(deepIdArr, ",")
  194. if deepIds != "" {
  195. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  196. }
  197. }
  198. // 推荐关注
  199. if recommendFocus == 1 {
  200. condition += ` AND man.recommended_index >= 80`
  201. }
  202. var industrialFollow []string //重点关注ID
  203. var industrialUninterested []string //重点关注ID
  204. followTypeMap := services.GetCygxIndustryFllowListTypeMapByMobile(user.Mobile) // 关注的对应状态
  205. for k, v := range followTypeMap {
  206. if v == 1 {
  207. industrialFollow = append(industrialFollow, strconv.Itoa(k))
  208. }
  209. if v == 3 {
  210. industrialUninterested = append(industrialUninterested, strconv.Itoa(k))
  211. }
  212. }
  213. industrialUninterested = append(industrialUninterested, "0")
  214. //是否展开,展开部分仅展示,不感兴趣的
  215. if isOpen == 0 {
  216. condition += ` AND man.industrial_management_id NOT IN (` + strings.Join(industrialUninterested, ",") + `) `
  217. } else {
  218. condition += ` AND man.industrial_management_id IN (` + strings.Join(industrialUninterested, ",") + `) `
  219. }
  220. // 列表总数据量
  221. var list []*models.IndustrialManagement
  222. total, err := models.GetIndustrialManagementAllCount(condition)
  223. if err != nil {
  224. br.Msg = "获取信息失败"
  225. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  226. return
  227. }
  228. page := paging.GetPaging(currentIndex, pageSize, total)
  229. if orderColumn == "" {
  230. orderColumn = "NewTime"
  231. }
  232. if orderColumn == "NewTime" {
  233. orderSrt = "update_time DESC"
  234. } else {
  235. orderSrt = "man.recommended_index DESC,update_time DESC"
  236. }
  237. if ChartPermissionId == 0 {
  238. ChartPermissionId = 20
  239. }
  240. // 阅读第三的产业详情
  241. //detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
  242. //if err != nil {
  243. // br.Msg = "获取信息失败"
  244. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  245. // return
  246. //}
  247. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
  248. if err != nil {
  249. br.Msg = "获取信息失败"
  250. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  251. return
  252. }
  253. // 获取近一个月产业报告阅读次数最多的产业
  254. var topCond string
  255. var topPars []interface{}
  256. //topReadIndustryId := 0
  257. if ChartPermissionId > 0 {
  258. topCond += ` AND chart_permission_id = ?`
  259. topPars = append(topPars, ChartPermissionId)
  260. }
  261. list, err = services.HandleIndustryList(list, user)
  262. if orderColumnNew != "" {
  263. item := new(models.CygxReportIndustrialSeaarchHistory)
  264. item.UserId = user.UserId
  265. item.Mobile = user.Mobile
  266. item.CompanyId = user.CompanyId
  267. item.CompanyName = user.CompanyName
  268. item.CreateTime = time.Now()
  269. item.IsDeepLabel = isDeepLabel
  270. item.IsNewLabel = isNewLabel
  271. item.ChartPermissionId = ChartPermissionId
  272. if orderColumnNew == "NewTime" {
  273. item.OrderColumn = "0"
  274. } else {
  275. item.OrderColumn = "1"
  276. }
  277. go models.AddCygxReportIndustrialSeaarchHistory(item)
  278. }
  279. if len(list) == 0 {
  280. list = make([]*models.IndustrialManagement, 0)
  281. }
  282. resp.List = list
  283. resp.Paging = page
  284. //如果不感兴趣有值,而且展开按钮没有展开,就放出展开按钮
  285. if len(industrialUninterested) > 0 && isOpen == 0 {
  286. resp.IsShowOpen = true
  287. }
  288. if isOpen == 0 {
  289. resp.IsInterested = true
  290. }
  291. br.Ret = 200
  292. br.Success = true
  293. br.Msg = "获取成功"
  294. br.Data = resp
  295. }
  296. // @Title 产业下所关联的文章分类列表
  297. // @Description 产业下所关联的文章分类列表接口
  298. // @Param IndustrialManagementId query int true "产业ID"
  299. // @Param ShowTimeLine query int true "是否展示时间线 0不展示,1展示"
  300. // @Param IsSendWx query int false "是否是通过微信模版进来的 1是,其它否"
  301. // @Param ChapterId query int false "晨会精华段落ID"
  302. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  303. // @router /toArticleCategoryList [get]
  304. func (this *ReportController) ArticleCategoryList() {
  305. br := new(models.BaseResponse).Init()
  306. defer func() {
  307. this.Data["json"] = br
  308. this.ServeJSON()
  309. }()
  310. user := this.User
  311. if user == nil {
  312. br.Msg = "请重新登录"
  313. br.Ret = 408
  314. return
  315. }
  316. //uid := user.UserId
  317. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  318. if industrialManagementId < 1 {
  319. br.Msg = "请输入分类ID"
  320. return
  321. }
  322. showTimeLine, _ := this.GetInt("ShowTimeLine", 0)
  323. isSendWx, _ := this.GetInt("IsSendWx")
  324. chapterId, _ := this.GetInt("ChapterId")
  325. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  326. if err != nil {
  327. br.Msg = "获取信息失败"
  328. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  329. return
  330. }
  331. listCategory, err := models.IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId)
  332. if err != nil {
  333. br.Msg = "获取信息失败"
  334. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  335. return
  336. }
  337. var list []*models.IndustrialToArticleCategoryRep
  338. categoryMap := make(map[int]int)
  339. for _, v := range listCategory {
  340. if categoryMap[v.CategoryId] > 0 {
  341. continue
  342. }
  343. categoryMap[v.CategoryId] = v.CategoryId
  344. list = append(list, v)
  345. }
  346. // 用户权限
  347. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  348. if e != nil {
  349. br.Msg = "获取失败"
  350. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  351. return
  352. }
  353. videoSimple := new(models.MicroVideoSimpleInfo)
  354. // 权限
  355. var au *models.UserPermissionAuthInfo
  356. video, err := models.GetMicroRoadshowVideoByIndustryId(industrialManagementId)
  357. if err != nil {
  358. if err.Error() != utils.ErrNoRow() {
  359. br.Msg = "获取产业视频失败"
  360. br.ErrMsg = "获取产业视频失败,Err:" + err.Error()
  361. return
  362. }
  363. } else {
  364. videoSimple.Id = video.VideoId
  365. videoSimple.Title = "5min逻辑【" + video.IndustryName + "】解析"
  366. videoSimple.BackgroundImg = video.ImgUrl
  367. videoSimple.DetailImgUrl = video.DetailImgUrl
  368. if videoSimple.BackgroundImg == "" {
  369. // 获取默认图配置
  370. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  371. if e != nil {
  372. br.Msg = "获取视频默认配置图失败"
  373. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  374. return
  375. }
  376. videoSimple.BackgroundImg = videoMap[video.ChartPermissionId]
  377. }
  378. videoSimple.PlaySeconds = video.VideoDuration
  379. videoSimple.ResourceUrl = video.VideoUrl
  380. au = new(models.UserPermissionAuthInfo)
  381. au.SellerName = authInfo.SellerName
  382. au.SellerMobile = authInfo.SellerMobile
  383. au.HasPermission = authInfo.HasPermission
  384. au.OperationMode = authInfo.OperationMode
  385. if au.HasPermission == 1 {
  386. // 非宏观权限进一步判断是否有权限
  387. if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  388. au.HasPermission = 2
  389. }
  390. }
  391. // 无权限的弹框提示
  392. if au.HasPermission != 1 {
  393. if au.OperationMode == services.UserPermissionOperationModeCall {
  394. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  395. } else {
  396. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  397. }
  398. videoSimple.ResourceUrl = ""
  399. }
  400. }
  401. //时间线
  402. if showTimeLine == 1 {
  403. timeLineItem := models.IndustrialToArticleCategoryRep{
  404. CategoryId: 99999,
  405. MatchTypeName: "时间线",
  406. }
  407. timeLineList, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, 0, 30)
  408. if err != nil {
  409. br.Msg = "获取信息失败"
  410. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  411. return
  412. }
  413. //查询用户今天是否看过时间线
  414. //haveMorningMeeting := false
  415. //var morningMeetingTime string
  416. //count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  417. //if err != nil {
  418. // br.Msg = "查询浏览记录数量失败"
  419. // br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  420. // return
  421. //}
  422. //var recordItem *models.CygxPageHistoryRecord
  423. //if count > 1 {
  424. // recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  425. // if err != nil {
  426. // br.Msg = "查询浏览记录失败"
  427. // br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  428. // return
  429. // }
  430. //}
  431. for _, v := range timeLineList {
  432. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
  433. if v.SubCategoryName == "时间线" {
  434. //haveMorningMeeting = true
  435. //morningMeetingTime = v.PublishTime
  436. continue
  437. }
  438. timeLineItem.IsRed = true
  439. }
  440. }
  441. //因为无法记录用户是否看过晨会点评,所以用用户今天是否看过时间线来判断是否显示小红点,这里是判断分类的小红点
  442. //timeLineRed := false
  443. //if count < 2 {
  444. // timeLineRed = true
  445. //} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(morningMeetingTime)) {
  446. // timeLineRed = true
  447. //}
  448. //if !timeLineItem.IsRed && timeLineRed && haveMorningMeeting {
  449. // timeLineItem.IsRed = true
  450. //}
  451. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  452. if chapterId > 0 && isSendWx == 1 {
  453. go services.AddCygxMorningMeetingReviewChapterHistory(user, chapterId, "微信")
  454. }
  455. }
  456. resp := new(models.IndustrialToArticleCategoryListRep)
  457. resp.List = list
  458. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  459. resp.IndustryName = detail.IndustryName
  460. resp.IndustrialManagementId = industrialManagementId
  461. resp.AuthInfo = au
  462. if videoSimple.Id > 0 {
  463. resp.IndustryVideo = videoSimple
  464. }
  465. if isSendWx == 1 {
  466. industryUserFollowMap, err := services.GetIndustryUserFollowMap(user)
  467. if err != nil {
  468. br.Msg = "获取信息失败"
  469. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  470. return
  471. }
  472. resp.IsFollowButton = industryUserFollowMap[industrialManagementId]
  473. resp.IsShowFollowButton = true
  474. }
  475. br.Ret = 200
  476. br.Success = true
  477. br.Msg = "获取成功"
  478. br.Data = resp
  479. }
  480. // @Title 产业文章列表接口
  481. // @Description 获取产业文章列表接口
  482. // @Param PageSize query int true "每页数据条数"
  483. // @Param CurrentIndex query int true "当前页页码,从1开始"
  484. // @Param CategoryId query int true "分类ID"
  485. // @Param IndustrialManagementId query int true "产业ID"
  486. // @Success 200 {object} models.TacticsListResp
  487. // @router /industry/ArticleList [get]
  488. func (this *ReportController) List() {
  489. br := new(models.BaseResponse).Init()
  490. defer func() {
  491. this.Data["json"] = br
  492. this.ServeJSON()
  493. }()
  494. user := this.User
  495. if user == nil {
  496. br.Msg = "请重新登录"
  497. br.Ret = 408
  498. return
  499. }
  500. uid := user.UserId
  501. pageSize, _ := this.GetInt("PageSize")
  502. currentIndex, _ := this.GetInt("CurrentIndex")
  503. categoryId, _ := this.GetInt("CategoryId")
  504. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  505. var startSize int
  506. if pageSize <= 0 {
  507. pageSize = utils.PageSize20
  508. }
  509. if currentIndex <= 0 {
  510. currentIndex = 1
  511. }
  512. startSize = paging.StartIndex(currentIndex, pageSize)
  513. var pars []interface{}
  514. var total int
  515. page := paging.GetPaging(currentIndex, pageSize, total)
  516. if categoryId < 1 {
  517. br.Msg = "请输入分类ID"
  518. return
  519. }
  520. if industrialManagementId < 1 {
  521. br.Msg = "请输入产业ID"
  522. return
  523. }
  524. if categoryId != 99999 {
  525. resp := new(models.TacticsListResp)
  526. list, total, err := models.GetReportAndproductInteriorIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  527. if err != nil {
  528. br.Msg = "获取信息失败"
  529. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  530. return
  531. }
  532. page = paging.GetPaging(currentIndex, pageSize, total)
  533. //对应分类的所图片
  534. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  535. if err != nil {
  536. br.Msg = "获取数据失败"
  537. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  538. return
  539. }
  540. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  541. mapCategoryUrl := make(map[string]string)
  542. var categoryIdStr string
  543. var imgUrlChart string
  544. for _, v := range categoryUrlList {
  545. vslice := strings.Split(v, "_")
  546. categoryIdStr = vslice[0]
  547. imgUrlChart = vslice[len(vslice)-1]
  548. mapCategoryUrl[categoryIdStr] = imgUrlChart
  549. }
  550. var articleIds []int
  551. lenList := len(list)
  552. for i := 0; i < lenList; i++ {
  553. item := list[i]
  554. list[i].Body, _ = services.GetReportContentTextSub(item.Body)
  555. //list[i].Abstract = html.UnescapeString(item.Abstract)
  556. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  557. if item.Resource == 1 {
  558. articleIds = append(articleIds, item.ArticleId)
  559. }
  560. }
  561. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  562. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  563. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  564. for k, v := range list {
  565. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  566. list[k].IsRed = true
  567. }
  568. if v.VideoUrl != "" {
  569. list[k].IsHaveVideo = true
  570. }
  571. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  572. if v.Resource == 1 {
  573. v.Pv = articleMapPv[v.ArticleId]
  574. v.IsCollect = articleCollectMap[v.ArticleId]
  575. v.CollectNum = articleCollectNumMap[v.ArticleId]
  576. }
  577. if v.Resource == 2 {
  578. v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  579. }
  580. }
  581. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  582. //resp.ChartPermissionId = detail.ChartPermissionId
  583. resp.List = list
  584. resp.Paging = page
  585. br.Ret = 200
  586. br.Success = true
  587. br.Msg = "获取成功"
  588. br.Data = resp
  589. } else {
  590. //获取该产业下所对应的行业图片
  591. //因为时间线不属于数据表里的二级分类,所以图片Id用产业id查到的list中的任意一个categoryId取到的图片替代
  592. categoryList, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
  593. if err != nil {
  594. br.Msg = "获取信息失败"
  595. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  596. return
  597. }
  598. var timeLineCategoryId int
  599. if len(categoryList) > 0 {
  600. timeLineCategoryId = categoryList[0].CategoryId
  601. }
  602. var detail *models.ReportMapping
  603. var errCategory error
  604. if timeLineCategoryId > 0 {
  605. detail, errCategory = models.GetdetailByCategoryIdOne(timeLineCategoryId)
  606. if errCategory != nil {
  607. br.Msg = "获取信息失败"
  608. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  609. return
  610. }
  611. }
  612. //对应行业的图片
  613. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  614. if err != nil {
  615. br.Msg = "获取数据失败"
  616. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  617. return
  618. }
  619. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  620. mapChartPermission := make(map[string]string)
  621. var permissionName string
  622. var imgUrlChartPermission string
  623. for _, v := range chartPermissionUrlList {
  624. vslice := strings.Split(v, "_")
  625. permissionName = vslice[0]
  626. imgUrlChartPermission = vslice[len(vslice)-1]
  627. mapChartPermission[permissionName] = imgUrlChartPermission
  628. }
  629. total, err := models.GetTimeLineReportIndustrialCount(industrialManagementId)
  630. if err != nil {
  631. br.Msg = "获取信息失败"
  632. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  633. return
  634. }
  635. page = paging.GetPaging(currentIndex, pageSize, total)
  636. list, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, startSize, pageSize)
  637. if err != nil {
  638. br.Msg = "获取信息失败"
  639. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  640. return
  641. }
  642. //处理晨会精华关联的标的,以及要跳转的文章ID
  643. var meetingreviewchaptIds []int
  644. var articleIds []int
  645. mapchaptIdAndArticleId := make(map[int]int) // 晨会精华ID与跳转文章ID的映射关系
  646. mapchaptIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 晨会精华ID与标的列表的映射关系
  647. mapArticleIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 报告ID与标的列表的映射关系
  648. for _, v := range list {
  649. if v.Resource == 3 {
  650. meetingreviewchaptIds = append(meetingreviewchaptIds, v.Id)
  651. v.Content = services.AnnotationHtml(v.Content)
  652. }
  653. if v.Resource == 1 {
  654. articleIds = append(articleIds, v.Id)
  655. }
  656. }
  657. if len(meetingreviewchaptIds) > 0 {
  658. listMeet, err := services.GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
  659. if err != nil {
  660. br.Msg = "获取失败"
  661. br.ErrMsg = "GetCygxMorningMeetingReviewChapterListByIds,Err:" + err.Error()
  662. }
  663. for _, v := range listMeet {
  664. mapchaptIdAndArticleId[v.Id] = v.LinkArticleId
  665. mapchaptIdListSubject[v.Id] = v.ListSubject
  666. }
  667. }
  668. if len(articleIds) > 0 {
  669. mapArticleIdListSubject = services.GetArticleGroupSubjectMapByIndustrialManagementId(articleIds, industrialManagementId)
  670. }
  671. //对应分类的所图片
  672. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  673. if err != nil {
  674. br.Msg = "获取数据失败"
  675. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  676. return
  677. }
  678. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  679. mapCategoryUrl := make(map[string]string)
  680. var categoryIdStr string
  681. var imgUrlChart string
  682. for _, v := range categoryUrlList {
  683. vslice := strings.Split(v, "_")
  684. categoryIdStr = vslice[0]
  685. imgUrlChart = vslice[len(vslice)-1]
  686. mapCategoryUrl[categoryIdStr] = imgUrlChart
  687. }
  688. //lenList := len(list)
  689. //for i := 0; i < lenList; i++ {
  690. // item := list[i]
  691. // list[i].Content, _ = services.GetReportContentTextSub(item.Content)
  692. // //list[i].Abstract = html.UnescapeString(item.Abstract)
  693. // //list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  694. //}
  695. //查询用户今天是否看过时间线
  696. //count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  697. //if err != nil {
  698. // br.Msg = "查询浏览记录数量失败"
  699. // br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  700. // return
  701. //}
  702. //var recordItem *models.CygxPageHistoryRecord
  703. //if count > 1 {
  704. // recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  705. // if err != nil {
  706. // br.Msg = "查询浏览记录失败"
  707. // br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  708. // return
  709. // }
  710. //}
  711. for k, v := range list {
  712. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
  713. list[k].IsRed = true
  714. }
  715. //timeLineRed := false
  716. //if count < 2 && v.SubCategoryName == "时间线" {
  717. // timeLineRed = true
  718. //} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishTime)) {
  719. // timeLineRed = true
  720. //}
  721. //if v.SubCategoryName == "时间线" && timeLineRed {
  722. list[k].IsRed = true
  723. //}
  724. if v.VideoUrl != "" {
  725. list[k].IsHaveVideo = true
  726. }
  727. id := strconv.Itoa(timeLineCategoryId)
  728. list[k].ImgUrlPc = mapCategoryUrl[id]
  729. if mapCategoryUrl[id] == "" {
  730. if detail != nil {
  731. if detail.ChartPermissionId == utils.YI_YAO_ID {
  732. list[k].ImgUrlPc = utils.YI_YAO_QI_TA
  733. }
  734. }
  735. }
  736. if v.Resource == 3 {
  737. v.LinkArticleId = mapchaptIdAndArticleId[v.Id]
  738. v.ListSubject = mapchaptIdListSubject[v.Id]
  739. }
  740. if v.Resource == 1 {
  741. v.ListSubject = mapArticleIdListSubject[v.Id]
  742. }
  743. }
  744. resp := new(models.TimeLineReportListResp)
  745. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  746. go services.AddCygxTimelineLog(user, industrialManagementId)
  747. resp.List = list
  748. resp.Paging = page
  749. br.Ret = 200
  750. br.Success = true
  751. br.Msg = "获取成功"
  752. br.Data = resp
  753. }
  754. }
  755. // @Title 置顶/取消置顶
  756. // @Description 置顶
  757. // @Param request body models.CygxIndustryTopRep true "type json string"
  758. // @Success 200
  759. // @router /top [post]
  760. func (this *ReportController) ArticleCollect() {
  761. br := new(models.BaseResponse).Init()
  762. defer func() {
  763. this.Data["json"] = br
  764. this.ServeJSON()
  765. }()
  766. user := this.User
  767. if user == nil {
  768. br.Msg = "请重新登录"
  769. br.Ret = 408
  770. return
  771. }
  772. uid := user.UserId
  773. var req models.CygxIndustryTopRep
  774. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  775. if err != nil {
  776. br.Msg = "参数解析异常!"
  777. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  778. return
  779. }
  780. industrialManagementId := req.IndustrialManagementId
  781. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  782. if err != nil {
  783. br.Msg = "获取数据失败!"
  784. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  785. return
  786. }
  787. if countIndustrial == 0 {
  788. br.Msg = "产业不存在!"
  789. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  790. return
  791. }
  792. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  793. if err != nil {
  794. br.Msg = "获取数据失败!"
  795. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  796. return
  797. }
  798. resp := new(models.ArticleCollectResp)
  799. if count <= 0 {
  800. item := new(models.CygxIndustryTop)
  801. item.IndustrialManagementId = req.IndustrialManagementId
  802. item.UserId = uid
  803. item.CreateTime = time.Now()
  804. _, err = models.AddCygxIndustryTop(item)
  805. if err != nil {
  806. br.Msg = "置顶失败"
  807. br.ErrMsg = "置顶失败,Err:" + err.Error()
  808. return
  809. }
  810. br.Msg = "置顶成功"
  811. resp.Status = 1
  812. } else {
  813. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  814. if err != nil {
  815. br.Msg = "取消置顶失败"
  816. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  817. return
  818. }
  819. br.Msg = "已取消置顶"
  820. resp.Status = 2
  821. }
  822. br.Ret = 200
  823. br.Success = true
  824. br.Data = resp
  825. }
  826. // @Title 关注/取消关注产业
  827. // @Description 关注/取消关注 接口
  828. // @Param request body models.CygxIndustryFllowRep true "type json string"
  829. // @Success 200
  830. // @router /fllow [post]
  831. func (this *ReportController) Fllow() {
  832. br := new(models.BaseResponse).Init()
  833. defer func() {
  834. this.Data["json"] = br
  835. this.ServeJSON()
  836. }()
  837. user := this.User
  838. if user == nil {
  839. br.Msg = "请重新登录"
  840. br.Ret = 408
  841. return
  842. }
  843. uid := user.UserId
  844. var req models.CygxIndustryFllowRep
  845. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  846. if err != nil {
  847. br.Msg = "参数解析异常!"
  848. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  849. return
  850. }
  851. industrialManagementId := req.IndustrialManagementId
  852. followType := req.FollowType
  853. var condition string
  854. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  855. if err != nil {
  856. br.Msg = "获取数据失败!"
  857. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  858. return
  859. }
  860. if countIndustrial == 0 {
  861. br.Msg = "产业不存在!"
  862. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  863. return
  864. }
  865. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  866. if err != nil {
  867. br.Msg = "获取数据失败!"
  868. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  869. return
  870. }
  871. resp := new(models.CygxIndustryFllowResp)
  872. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  873. if countUser == 0 {
  874. resp.GoFollow = true
  875. }
  876. item := new(models.CygxIndustryFllow)
  877. item.IndustrialManagementId = industrialManagementId
  878. item.FollowType = followType
  879. item.UserId = uid
  880. item.Email = user.Email
  881. item.Mobile = user.Mobile
  882. item.RealName = user.RealName
  883. item.Source = utils.REGISTER_PLATFORM
  884. item.CompanyId = user.CompanyId
  885. item.CompanyName = user.CompanyName
  886. if followType == 3 {
  887. item.FollowTypeOrder = -1
  888. } else {
  889. item.FollowTypeOrder = followType
  890. }
  891. //if count == 0 {
  892. item.Type = 1
  893. item.CreateTime = time.Now()
  894. item.ModifyTime = time.Now()
  895. _, err = models.AddCygxIndustryFllow(item)
  896. if err != nil {
  897. br.Msg = "操作失败"
  898. br.ErrMsg = "操作失败,Err:" + err.Error()
  899. return
  900. }
  901. resp.Status = followType
  902. br.Msg = "操作成功"
  903. //go services.IndustryFllowWithTrack(industrialManagementId, count, uid) //处理是否关注全部赛道字段
  904. go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
  905. go services.AddCygxIndustryFllowLog(item) //添加操作日志记录
  906. br.Msg = "操作成功"
  907. br.Ret = 200
  908. br.Success = true
  909. br.Data = resp
  910. }
  911. // @Title 产业报告分类关联作者列表接口
  912. // @Description 获取产业报告分类关联作者列表接口
  913. // @Param ChartPermissionId query int true "分类ID"
  914. // @Param PageSize query int true "每页数据条数"
  915. // @Param CurrentIndex query int true "当前页页码,从1开始"
  916. // @Success 200 {object} models.CygxArticleDepartmentList
  917. // @router /industryListByDepartment [get]
  918. func (this *ReportController) IndustryListByDepartment() {
  919. br := new(models.BaseResponse).Init()
  920. defer func() {
  921. this.Data["json"] = br
  922. this.ServeJSON()
  923. }()
  924. user := this.User
  925. if user == nil {
  926. br.Msg = "请重新登录"
  927. br.Ret = 408
  928. return
  929. }
  930. uid := user.UserId
  931. pageSize, _ := this.GetInt("PageSize")
  932. currentIndex, _ := this.GetInt("CurrentIndex")
  933. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  934. var startSize int
  935. var condition string
  936. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  937. condition = ` AND a.publish_status=1 `
  938. if pageSize <= 0 {
  939. pageSize = utils.PageSize20
  940. }
  941. if currentIndex <= 0 {
  942. currentIndex = 1
  943. }
  944. startSize = paging.StartIndex(currentIndex, pageSize)
  945. total, err := models.GetArticleDepartmentCount(condition)
  946. page := paging.GetPaging(currentIndex, pageSize, total)
  947. resp := new(models.CygxArticleDepartmentList)
  948. userType, _, err := services.GetUserType(user.CompanyId)
  949. if err != nil {
  950. br.Msg = "获取信息失败"
  951. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  952. return
  953. }
  954. if userType == 1 {
  955. resp.Paging = page
  956. br.Ret = 200
  957. br.Success = true
  958. br.Msg = "获取成功"
  959. br.Data = resp
  960. return
  961. }
  962. resp.HaveResearch = true
  963. //获取作者信息,并排序
  964. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  965. if err != nil {
  966. br.Msg = "获取信息失败"
  967. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  968. return
  969. }
  970. for k, v := range list {
  971. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  972. if err != nil {
  973. br.Msg = "获取信息失败"
  974. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  975. return
  976. }
  977. for k2, v2 := range artList {
  978. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  979. if err != nil {
  980. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  981. br.ErrMsg = "获取失败,Err:" + err.Error()
  982. return
  983. }
  984. var subjectNamesNew string
  985. if len(subjectNames) > 0 {
  986. slice := strings.Split(subjectNames, "/")
  987. for k3, v3 := range slice {
  988. if k3 < 4 {
  989. subjectNamesNew += v3 + "/"
  990. }
  991. }
  992. }
  993. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  994. if err != nil && err.Error() != utils.ErrNoRow() {
  995. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  996. br.ErrMsg = "获取失败,Err:" + err.Error()
  997. return
  998. }
  999. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1000. artList[k2].SubjectName = subjectNamesNew
  1001. artList[k2].DepartmentId = v.DepartmentId
  1002. if subjectNamesNew == "" {
  1003. artList[k2].IndustryName = industryName
  1004. } else {
  1005. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  1006. }
  1007. if artList[k2].IsReport == "1" {
  1008. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  1009. } else {
  1010. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  1011. }
  1012. }
  1013. list[k].List = artList
  1014. if v.FollowNum > 0 {
  1015. list[k].IsMyFollow = true
  1016. }
  1017. }
  1018. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  1019. if err != nil {
  1020. br.Msg = "获取信息失败"
  1021. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1022. return
  1023. }
  1024. if len(listnNew) > 0 {
  1025. for _, v := range listnNew {
  1026. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  1027. Management := new(models.IndustrialManagementIdInt)
  1028. if firstStr == 0 {
  1029. Management.IndustryName = v.IndustryName
  1030. } else {
  1031. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  1032. if err != nil {
  1033. br.Msg = "获取信息失败"
  1034. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  1035. return
  1036. }
  1037. var subjectNamesNew string
  1038. for _, v1 := range listSub {
  1039. subjectNamesNew += v1.SubjectName + "/"
  1040. }
  1041. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1042. Management.IndustryName = subjectNamesNew
  1043. }
  1044. Management.IndustrialManagementId = v.IndustrialManagementId
  1045. Management.ArticleId = v.ArticleId
  1046. resp.ListnNew = append(resp.ListnNew, Management)
  1047. }
  1048. }
  1049. resp.List = list
  1050. resp.Paging = page
  1051. br.Ret = 200
  1052. br.Success = true
  1053. br.Msg = "获取成功"
  1054. br.Data = resp
  1055. }
  1056. // @Title 关注作者/取消关注作者
  1057. // @Description 关注作者/取消关注作者 接口
  1058. // @Param request body models.CygxArticleDepartmentId true "type json string"
  1059. // @Success 200
  1060. // @router /fllowDepartment [post]
  1061. func (this *ReportController) FllowDepartment() {
  1062. br := new(models.BaseResponse).Init()
  1063. defer func() {
  1064. this.Data["json"] = br
  1065. this.ServeJSON()
  1066. }()
  1067. user := this.User
  1068. if user == nil {
  1069. br.Msg = "请重新登录"
  1070. br.Ret = 408
  1071. return
  1072. }
  1073. uid := user.UserId
  1074. var req models.CygxArticleDepartmentId
  1075. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1076. if err != nil {
  1077. br.Msg = "参数解析异常!"
  1078. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1079. return
  1080. }
  1081. departmentId := req.DepartmentId
  1082. var condition string
  1083. countDepartment, err := models.GetDepartmentCount(departmentId)
  1084. if err != nil {
  1085. br.Msg = "获取数据失败!"
  1086. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1087. return
  1088. }
  1089. if countDepartment == 0 {
  1090. br.Msg = "作者不存在!"
  1091. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  1092. return
  1093. }
  1094. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  1095. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1096. if err != nil {
  1097. br.Msg = "获取数据失败!"
  1098. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1099. return
  1100. }
  1101. resp := new(models.CygxArticleDepartmentFollowResp)
  1102. if countUser == 0 {
  1103. resp.GoFollow = true
  1104. }
  1105. if count == 0 {
  1106. item := new(models.CygxArticleDepartmentFollow)
  1107. item.DepartmentId = departmentId
  1108. item.UserId = uid
  1109. item.Email = user.Email
  1110. item.Mobile = user.Mobile
  1111. item.RealName = user.RealName
  1112. item.CompanyId = user.CompanyId
  1113. item.CompanyName = user.CompanyName
  1114. item.Type = 1
  1115. item.CreateTime = time.Now()
  1116. item.ModifyTime = time.Now()
  1117. _, err = models.AddArticleDepartmentFollow(item)
  1118. if err != nil {
  1119. br.Msg = "操作失败"
  1120. br.ErrMsg = "操作失败,Err:" + err.Error()
  1121. return
  1122. }
  1123. resp.Status = 1
  1124. } else {
  1125. var doType int
  1126. condition = ` AND type = 1`
  1127. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1128. if err != nil {
  1129. br.Msg = "操作失败!"
  1130. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1131. return
  1132. }
  1133. if count == 1 {
  1134. resp.Status = 2
  1135. doType = 2
  1136. } else {
  1137. resp.Status = 1
  1138. doType = 1
  1139. }
  1140. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  1141. if err != nil {
  1142. br.Msg = "操作失败"
  1143. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  1144. return
  1145. }
  1146. }
  1147. br.Msg = "操作成功"
  1148. br.Ret = 200
  1149. br.Success = true
  1150. br.Data = resp
  1151. }
  1152. // @Title 研选文章列表接口
  1153. // @Description 获取研选文章列表接口
  1154. // @Param PageSize query int true "每页数据条数"
  1155. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1156. // @Param ArticleId query int true "文章id"
  1157. // @Param DepartmentId query int true "作者ID"
  1158. // @Param IndustrialManagementId query int true "产业ID"
  1159. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1160. // @router /industry/reportList [get]
  1161. func (this *ReportController) ReportList() {
  1162. br := new(models.BaseResponse).Init()
  1163. defer func() {
  1164. this.Data["json"] = br
  1165. this.ServeJSON()
  1166. }()
  1167. user := this.User
  1168. if user == nil {
  1169. br.Msg = "请重新登录"
  1170. br.Ret = 408
  1171. return
  1172. }
  1173. uid := user.UserId
  1174. pageSize, _ := this.GetInt("PageSize")
  1175. currentIndex, _ := this.GetInt("CurrentIndex")
  1176. departmentId, _ := this.GetInt("DepartmentId")
  1177. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1178. articleId, _ := this.GetInt("ArticleId")
  1179. var condition string
  1180. var startSize int
  1181. if pageSize <= 0 {
  1182. pageSize = utils.PageSize20
  1183. }
  1184. if currentIndex <= 0 {
  1185. currentIndex = 1
  1186. }
  1187. startSize = paging.StartIndex(currentIndex, pageSize)
  1188. var pars []interface{}
  1189. var total int
  1190. resp := new(models.ReportArticleWhichIndustrialRepList)
  1191. page := paging.GetPaging(currentIndex, pageSize, total)
  1192. userType, _, err := services.GetUserType(user.CompanyId)
  1193. if err != nil {
  1194. br.Msg = "获取信息失败"
  1195. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1196. return
  1197. }
  1198. if userType == 1 {
  1199. resp.Paging = page
  1200. br.Ret = 200
  1201. br.Success = true
  1202. br.Msg = "获取成功"
  1203. br.Data = resp
  1204. return
  1205. }
  1206. resp.HaveResearch = true
  1207. if departmentId > 0 {
  1208. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  1209. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  1210. if err != nil {
  1211. br.Msg = "获取信息失败"
  1212. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1213. return
  1214. }
  1215. resp.NickName = detail.NickName
  1216. }
  1217. if industrialManagementId > 0 {
  1218. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  1219. }
  1220. if articleId > 0 {
  1221. detail, err := models.GetArticleDetailById(articleId)
  1222. if err != nil {
  1223. br.Msg = "获取信息失败"
  1224. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1225. return
  1226. }
  1227. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  1228. }
  1229. total, err = models.GetWhichDepartmentCount(condition)
  1230. if err != nil {
  1231. br.Msg = "获取信息失败"
  1232. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1233. return
  1234. }
  1235. page = paging.GetPaging(currentIndex, pageSize, total)
  1236. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1237. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1238. if err != nil {
  1239. br.Msg = "获取失败"
  1240. br.ErrMsg = "获取失败,Err:" + err.Error()
  1241. return
  1242. }
  1243. for k, v := range list {
  1244. if v.Readnum == 0 {
  1245. list[k].IsRed = true
  1246. }
  1247. list[k].IsResearch = true
  1248. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1249. if err != nil {
  1250. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1251. br.ErrMsg = "获取失败,Err:" + err.Error()
  1252. return
  1253. }
  1254. var subjectNamesNew string
  1255. if len(subjectNames) > 0 {
  1256. slice := strings.Split(subjectNames, "/")
  1257. for k3, v3 := range slice {
  1258. if k3 < 4 {
  1259. subjectNamesNew += v3 + "/"
  1260. }
  1261. }
  1262. }
  1263. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1264. if err != nil && err.Error() != utils.ErrNoRow() {
  1265. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1266. br.ErrMsg = "获取失败,Err:" + err.Error()
  1267. return
  1268. }
  1269. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1270. list[k].SubjectName = subjectNamesNew
  1271. if subjectNamesNew != "" {
  1272. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1273. } else {
  1274. list[k].IndustryName = industryName
  1275. }
  1276. resp.IndustryName = industryName
  1277. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1278. }
  1279. resp.List = list
  1280. resp.Paging = page
  1281. br.Ret = 200
  1282. br.Success = true
  1283. br.Msg = "获取成功"
  1284. br.Data = resp
  1285. }
  1286. // @Title 研选最新主题关键词文章列表接口
  1287. // @Description 获取研选最新主题关键词文章列表接口
  1288. // @Param PageSize query int true "每页数据条数"
  1289. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1290. // @Param ArticleId query int true "文章id"
  1291. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1292. // @router /industry/reportListNew [get]
  1293. func (this *ReportController) ReportListNew() {
  1294. br := new(models.BaseResponse).Init()
  1295. defer func() {
  1296. this.Data["json"] = br
  1297. this.ServeJSON()
  1298. }()
  1299. user := this.User
  1300. if user == nil {
  1301. br.Msg = "请重新登录"
  1302. br.Ret = 408
  1303. return
  1304. }
  1305. uid := user.UserId
  1306. pageSize, _ := this.GetInt("PageSize")
  1307. currentIndex, _ := this.GetInt("CurrentIndex")
  1308. articleId, _ := this.GetInt("ArticleId")
  1309. var condition string
  1310. var startSize int
  1311. if pageSize <= 0 {
  1312. pageSize = utils.PageSize20
  1313. }
  1314. if currentIndex <= 0 {
  1315. currentIndex = 1
  1316. }
  1317. startSize = paging.StartIndex(currentIndex, pageSize)
  1318. var pars []interface{}
  1319. var total int
  1320. resp := new(models.ReportArticleWhichIndustrialRepList)
  1321. page := paging.GetPaging(currentIndex, pageSize, total)
  1322. userType, _, err := services.GetUserType(user.CompanyId)
  1323. if err != nil {
  1324. br.Msg = "获取信息失败"
  1325. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1326. return
  1327. }
  1328. if userType == 1 {
  1329. resp.Paging = page
  1330. br.Ret = 200
  1331. br.Success = true
  1332. br.Msg = "获取成功"
  1333. br.Data = resp
  1334. return
  1335. }
  1336. resp.HaveResearch = true
  1337. if articleId > 0 {
  1338. detail, err := models.GetArticleDetailById(articleId)
  1339. if err != nil {
  1340. br.Msg = "获取信息失败"
  1341. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1342. return
  1343. }
  1344. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  1345. if firstStr == 0 {
  1346. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  1347. } else {
  1348. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  1349. }
  1350. }
  1351. total, err = models.GetWhichDepartmentCount(condition)
  1352. if err != nil {
  1353. br.Msg = "获取信息失败"
  1354. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1355. return
  1356. }
  1357. page = paging.GetPaging(currentIndex, pageSize, total)
  1358. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1359. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1360. if err != nil {
  1361. br.Msg = "获取失败"
  1362. br.ErrMsg = "获取失败,Err:" + err.Error()
  1363. return
  1364. }
  1365. for k, v := range list {
  1366. if v.Readnum == 0 {
  1367. list[k].IsRed = true
  1368. }
  1369. list[k].IsResearch = true
  1370. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1371. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1372. if err != nil {
  1373. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1374. br.ErrMsg = "获取失败,Err:" + err.Error()
  1375. return
  1376. }
  1377. var subjectNamesNew string
  1378. if len(subjectNames) > 0 {
  1379. slice := strings.Split(subjectNames, "/")
  1380. for k3, v3 := range slice {
  1381. if k3 < 4 {
  1382. subjectNamesNew += v3 + "/"
  1383. }
  1384. }
  1385. }
  1386. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1387. if err != nil && err.Error() != utils.ErrNoRow() {
  1388. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1389. br.ErrMsg = "获取失败,Err:" + err.Error()
  1390. return
  1391. }
  1392. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1393. list[k].SubjectName = subjectNamesNew
  1394. if subjectNamesNew != "" {
  1395. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1396. } else {
  1397. list[k].IndustryName = industryName
  1398. }
  1399. resp.IndustryName = industryName
  1400. }
  1401. resp.List = list
  1402. resp.Paging = page
  1403. br.Ret = 200
  1404. br.Success = true
  1405. br.Msg = "获取成功"
  1406. br.Data = resp
  1407. }
  1408. // @Title 是否展示绝密内参
  1409. // @Description 获取是否展示绝密内参接口
  1410. // @Param request body models.IsShow true "type json string"
  1411. // @Success 200
  1412. // @router /isShow [get]
  1413. func (this *ReportController) IsShow() {
  1414. br := new(models.BaseResponse).Init()
  1415. defer func() {
  1416. this.Data["json"] = br
  1417. this.ServeJSON()
  1418. }()
  1419. user := this.User
  1420. if user == nil {
  1421. br.Msg = "请重新登录"
  1422. br.Ret = 408
  1423. return
  1424. }
  1425. var resp models.IsShow
  1426. IsShowFreeButton, err := services.GetfreeButtonIsShow(user)
  1427. if err != nil {
  1428. br.Msg = "获取失败"
  1429. br.ErrMsg = "获取失败,GetfreeButtonIsShow Err:" + err.Error()
  1430. return
  1431. }
  1432. resp.IsShowChart = true
  1433. //resp.IsShowResearch = true
  1434. resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
  1435. resp.ActivitySpecialExplain = utils.ACTIVITY_SPECIAL_EXPLAIN
  1436. //resp.YanXuan_Explain = true
  1437. resp.IsShowFreeButton = IsShowFreeButton
  1438. resp.IsBelongRai = services.GetBelongingRai(user.Mobile)
  1439. resp.IsShowQuestionnaire = services.GetQuestionnaireButtonIsShow() // 获取研选问卷调查按钮是否展示
  1440. resp.IsShowResearchPoints = true
  1441. if utils.RunMode == "release" { //是否展示关于我们的视频,测试环境审核做隐藏
  1442. resp.IsShowAboutVideo = true
  1443. } else {
  1444. resp.IsShowMobileAndEmailButton = true //是否展示手机号跟邮箱按钮
  1445. }
  1446. //mobile := user.Mobile
  1447. //if mobile == "" {
  1448. // br.Ret = 200
  1449. // br.Success = true
  1450. // br.Data = resp
  1451. // return
  1452. //}
  1453. //total, _ := models.GetUserIsAdminCount(mobile)
  1454. //if total > 0 {
  1455. // resp.IsShowList = true
  1456. //}
  1457. resp.IsShowList = true
  1458. resp.SearchTxtList.SummarySearch = "全局搜索"
  1459. resp.SearchTxtList.ReportSearch = "全局搜索"
  1460. resp.SearchTxtList.YanXuanSearch = "全局搜索"
  1461. resp.SearchTxtList.ActivitySearch = "全局搜索"
  1462. resp.SearchTxtList.TabSearch = "请输入关键词"
  1463. resp.IsShow = true
  1464. br.Ret = 200
  1465. br.Success = true
  1466. br.Data = resp
  1467. }
  1468. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1469. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1470. // @Param PageSize query int true "每页数据条数"
  1471. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1472. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1473. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1474. // @router /reportList/byType [get]
  1475. func (this *ReportController) ReportListByType() {
  1476. br := new(models.BaseResponse).Init()
  1477. defer func() {
  1478. this.Data["json"] = br
  1479. this.ServeJSON()
  1480. }()
  1481. user := this.User
  1482. if user == nil {
  1483. br.Msg = "请重新登录"
  1484. br.Ret = 408
  1485. return
  1486. }
  1487. uid := user.UserId
  1488. pageSize, _ := this.GetInt("PageSize")
  1489. currentIndex, _ := this.GetInt("CurrentIndex")
  1490. reportType := this.GetString("ReportType")
  1491. var condition string
  1492. var startSize int
  1493. if pageSize <= 0 {
  1494. pageSize = utils.PageSize20
  1495. }
  1496. if currentIndex <= 0 {
  1497. currentIndex = 1
  1498. }
  1499. startSize = paging.StartIndex(currentIndex, pageSize)
  1500. var pars []interface{}
  1501. var total int
  1502. resp := new(models.CygxReportSelectionListPublicRep)
  1503. page := paging.GetPaging(currentIndex, pageSize, total)
  1504. var tbdb string
  1505. var readSql string
  1506. var reportTypeStr string
  1507. if reportType == "1" {
  1508. tbdb = "cygx_report_selection"
  1509. reportTypeStr = "bgjx"
  1510. } else if reportType == "2" {
  1511. tbdb = "cygx_research_summary"
  1512. reportTypeStr = "bzyjhz"
  1513. } else if reportType == "3" {
  1514. tbdb = "cygx_minutes_summary"
  1515. reportTypeStr = "szjyhz"
  1516. } else {
  1517. br.Msg = "请选择报告类型"
  1518. return
  1519. }
  1520. condition = ` AND publish_status = 1 `
  1521. if user.CompanyId != utils.HZ_COMPANY_ID {
  1522. condition += ` AND visible_range = 1 `
  1523. }
  1524. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1525. if err != nil {
  1526. br.Msg = "获取信息失败"
  1527. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1528. return
  1529. }
  1530. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1531. if reportType == "1" {
  1532. startSize = 0
  1533. pageSize = 1
  1534. total = 1
  1535. }
  1536. readSql = ` (SELECT COUNT(1) AS count FROM cygx_report_history_record AS h WHERE h.article_id = art.article_id AND report_type ='` + reportTypeStr + `' AND h.user_id = ` + strconv.Itoa(uid) + `) as read_num`
  1537. page = paging.GetPaging(currentIndex, pageSize, total)
  1538. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1539. if err != nil {
  1540. br.Msg = "获取失败"
  1541. br.ErrMsg = "获取失败,Err:" + err.Error()
  1542. return
  1543. }
  1544. for k, v := range list {
  1545. if reportType == "1" {
  1546. list[k].Abstract = v.UpdateDescription
  1547. }
  1548. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1549. if v.ReadNum == 0 {
  1550. list[k].IsRed = true
  1551. }
  1552. }
  1553. resp.List = list
  1554. resp.Paging = page
  1555. br.Ret = 200
  1556. br.Success = true
  1557. br.Msg = "获取成功"
  1558. br.Data = resp
  1559. }
  1560. // @Title 获取报告精选详情
  1561. // @Description 获取报告精选详情接口
  1562. // @Param ArticleId query int true "报告ID"
  1563. // @Param IsBestNew query bool false "是否获取最新的一篇报告"
  1564. // @Success 200 {object} models.ReportSelectionLetailResp
  1565. // @router /reportSelection/detail [get]
  1566. func (this *ReportController) Detail() {
  1567. br := new(models.BaseResponse).Init()
  1568. defer func() {
  1569. this.Data["json"] = br
  1570. this.ServeJSON()
  1571. }()
  1572. user := this.User
  1573. if user == nil {
  1574. br.Msg = "请重新登录"
  1575. br.Ret = 408
  1576. return
  1577. }
  1578. //if user.CompanyId != utils.HZ_COMPANY_ID {
  1579. // br.Msg = "报告编辑中,请稍后"
  1580. // br.IsSendEmail = false
  1581. // return
  1582. //}
  1583. //uid := user.UserId
  1584. articleId, _ := this.GetInt("ArticleId")
  1585. isBestNew, _ := this.GetBool("IsBestNew")
  1586. if isBestNew {
  1587. tbdb := "cygx_report_selection"
  1588. //reportTypeStr := "bgjx"
  1589. condition := ` AND publish_status = 1 `
  1590. var pars []interface{}
  1591. list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
  1592. if err != nil {
  1593. br.Msg = "获取失败"
  1594. br.ErrMsg = "获取失败,Err:" + err.Error()
  1595. return
  1596. }
  1597. for _, v := range list {
  1598. articleId = v.ArticleId
  1599. }
  1600. }
  1601. if articleId < 1 {
  1602. br.Msg = "获取信息失败"
  1603. br.ErrMsg = "报告ID错误" + strconv.Itoa(articleId)
  1604. return
  1605. }
  1606. resp := new(models.ReportSelectionLetailResp)
  1607. //判断用户权限
  1608. hasPermission, err := services.GetUserhasPermission(user)
  1609. if err != nil {
  1610. br.Msg = "获取信息失败"
  1611. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1612. }
  1613. resp.HasPermission = hasPermission
  1614. if hasPermission != 1 {
  1615. br.Ret = 200
  1616. br.Success = true
  1617. br.Msg = "获取成功"
  1618. br.Data = resp
  1619. return
  1620. }
  1621. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1622. if err != nil {
  1623. br.Msg = "获取信息失败"
  1624. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1625. return
  1626. }
  1627. if detail.ReportLink != "" {
  1628. articleIdLink, _ := services.GetReportLinkToArticleid(detail.ReportLink)
  1629. detail.CeLueArticleId = articleIdLink
  1630. }
  1631. //较上一期有观点变化(后台填写的核心逻辑汇总内容、标签内容有更新),或者新增的公司,显示new标签
  1632. var isAllNew bool // 判断是否都打新的标签
  1633. lastPeriods := detail.Periods - 1
  1634. mapBodyChartSummary := make(map[int]string)
  1635. mapLabel := make(map[int]string)
  1636. if lastPeriods > 0 {
  1637. detailLast, err := models.GetCygxReportSelectionInfoByperiods(lastPeriods)
  1638. if err != nil && err.Error() != utils.ErrNoRow() {
  1639. br.Msg = "获取信息失败"
  1640. br.ErrMsg = "报告不存在,Err:" + err.Error() + "Periods:" + strconv.Itoa(lastPeriods)
  1641. return
  1642. }
  1643. if detailLast != nil {
  1644. articleIdLast := detailLast.ArticleId
  1645. listLogLast, err := models.GetReportSelectionlogListAll(articleIdLast)
  1646. if err != nil {
  1647. br.Msg = "获取失败"
  1648. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1649. return
  1650. }
  1651. for _, v := range listLogLast {
  1652. mapBodyChartSummary[v.IndustrialSubjectId], _ = services.GetReportContentTextSubNew(v.Body)
  1653. mapLabel[v.IndustrialSubjectId] = v.Label
  1654. }
  1655. }
  1656. } else {
  1657. isAllNew = true
  1658. }
  1659. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1660. existMap := make(map[int]int)
  1661. var items []*models.ReportSelectionChartPermission
  1662. var itemsSubject []*models.ReportSelectionChartLogPermission
  1663. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1664. if err != nil {
  1665. br.Msg = "获取失败"
  1666. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1667. return
  1668. }
  1669. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1670. //获取行业核心逻辑汇总
  1671. listChartLog, err := models.GetCygxReportSelectionChartLogRepList(articleId)
  1672. if err != nil {
  1673. br.Msg = "获取失败"
  1674. br.ErrMsg = "获取失败,Err:" + err.Error()
  1675. return
  1676. }
  1677. mapChartLog := make(map[string]string)
  1678. for _, v := range listChartLog {
  1679. mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
  1680. }
  1681. for _, v := range listLog {
  1682. item := new(models.ReportSelectionChartPermission)
  1683. itemSubject := new(models.ReportSelectionChartLogPermission)
  1684. itemSubject.PermissionName = v.PermissionName
  1685. if existMap[v.ChartPermissionId] == 0 {
  1686. //item.PermissionName = v.PermissionName + "领域深度报告和调研"
  1687. item.PermissionName = v.PermissionName
  1688. item.IcoLink = v.IcoLink
  1689. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1690. if err != nil && err.Error() != utils.ErrNoRow() {
  1691. br.Msg = "获取信息失败"
  1692. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1693. return
  1694. }
  1695. for k2, v2 := range listSonLog {
  1696. var isNew bool
  1697. if isAllNew {
  1698. isNew = true
  1699. } else {
  1700. v2Body, _ := services.GetReportContentTextSubNew(v2.Body)
  1701. if mapBodyChartSummary[v2.IndustrialSubjectId] != v2Body || mapLabel[v2.IndustrialSubjectId] != v2.Label {
  1702. isNew = true
  1703. }
  1704. }
  1705. if v2.IndustrialManagementId != "" {
  1706. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1707. if err != nil && err.Error() != utils.ErrNoRow() {
  1708. br.Msg = "获取信息失败"
  1709. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1710. return
  1711. }
  1712. //v2.IsNew = isNew
  1713. listSonLog[k2].List = listIndustrial
  1714. if v2.Label != "" {
  1715. v2.CompanyLabel = strings.Split(v2.Label, "{|}")
  1716. }
  1717. }
  1718. isNew = false
  1719. itemSubject.ListSubject = append(itemSubject.ListSubject, &models.ReportSelectionChartLogSubjectName{SubjectName: v2.SubjectName, IsNew: isNew, IndustrialSubjectId: v2.IndustrialSubjectId})
  1720. }
  1721. item.BodyChartSummary = mapChartLog[v.PermissionName]
  1722. item.List = listSonLog
  1723. items = append(items, item)
  1724. itemsSubject = append(itemsSubject, itemSubject)
  1725. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1726. }
  1727. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1728. }
  1729. //historyRecord := new(models.CygxReportHistoryRecord)
  1730. //historyRecord.UserId = uid
  1731. //historyRecord.ArticleId = articleId
  1732. //historyRecord.CreateTime = time.Now()
  1733. //historyRecord.Mobile = user.Mobile
  1734. //historyRecord.Email = user.Email
  1735. //historyRecord.CompanyId = user.CompanyId
  1736. //historyRecord.CompanyName = user.CompanyName
  1737. //historyRecord.ReportType = "bgjx"
  1738. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1739. //if err != nil && err.Error() != utils.ErrNoRow() {
  1740. // br.Msg = "获取信息失败"
  1741. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1742. // return
  1743. //}
  1744. //historyRecord.RealName = user.RealName
  1745. //if sellerItem != nil {
  1746. // historyRecord.SellerName = sellerItem.RealName
  1747. //}
  1748. //
  1749. //go models.AddCygxReportHistoryRecord(historyRecord)
  1750. resp.List = items
  1751. resp.ListPermissionSubject = itemsSubject
  1752. resp.Detail = detail
  1753. br.Ret = 200
  1754. br.Success = true
  1755. br.Msg = "获取成功"
  1756. br.Data = resp
  1757. }
  1758. // @Title 获取本周研究汇总详情
  1759. // @Description 获取本周研究汇总详情接口
  1760. // @Param ArticleId query int true "报告ID"
  1761. // @Success 200 {object} models.ResearchSummaryLetailResp
  1762. // @router /researchSummary/detail [get]
  1763. func (this *ReportController) ResearchDetail() {
  1764. br := new(models.BaseResponse).Init()
  1765. defer func() {
  1766. this.Data["json"] = br
  1767. this.ServeJSON()
  1768. }()
  1769. user := this.User
  1770. if user == nil {
  1771. br.Msg = "请重新登录"
  1772. br.Ret = 408
  1773. return
  1774. }
  1775. //uid := user.UserId
  1776. articleId, _ := this.GetInt("ArticleId")
  1777. if articleId < 0 {
  1778. br.Msg = "参数错误"
  1779. br.ErrMsg = "参数错误"
  1780. return
  1781. }
  1782. resp := new(models.ResearchSummaryLetailResp)
  1783. //判断用户权限
  1784. hasPermission, err := services.GetUserhasPermission(user)
  1785. if err != nil {
  1786. br.Msg = "获取信息失败"
  1787. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1788. }
  1789. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1790. if err != nil {
  1791. br.Msg = "获取信息失败"
  1792. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1793. return
  1794. }
  1795. PermissionNameMap, err := services.GetPermissionNameMap()
  1796. if err != nil {
  1797. br.Msg = "获取失败"
  1798. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1799. return
  1800. }
  1801. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1802. if err != nil {
  1803. br.Msg = "获取失败"
  1804. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1805. return
  1806. }
  1807. //未设置全部可见的只能给弘则内部查看
  1808. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1809. resp.IsShow = true
  1810. }
  1811. resp.HasPermission = hasPermission
  1812. if hasPermission != 1 || !resp.IsShow {
  1813. br.Ret = 200
  1814. br.Success = true
  1815. br.Msg = "获取成功"
  1816. br.Data = resp
  1817. return
  1818. }
  1819. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1820. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1821. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1822. if err != nil {
  1823. br.Msg = "获取失败"
  1824. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1825. return
  1826. }
  1827. listArticleType, err := models.GetCygxArticleTypeList()
  1828. if err != nil {
  1829. br.Msg = "获取失败"
  1830. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1831. return
  1832. }
  1833. for k, v := range listFirst {
  1834. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1835. if err != nil && err.Error() != utils.ErrNoRow() {
  1836. br.Msg = "获取信息失败"
  1837. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1838. return
  1839. }
  1840. for k2, v2 := range listSecond {
  1841. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1842. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1843. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1844. if err != nil && err.Error() != utils.ErrNoRow() {
  1845. br.Msg = "获取信息失败"
  1846. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1847. return
  1848. }
  1849. for _, vType := range listArticleType {
  1850. if v2.ChartPermissionId == vType.YanxPermissionId {
  1851. listSecond[k2].IcoLink = vType.IcoLinkM
  1852. listSecond[k2].PermissionName = vType.YanxPermissionName
  1853. }
  1854. }
  1855. //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1856. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1857. // listSecond[k2].PermissionName = "买方研选纪要"
  1858. //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1859. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1860. // listSecond[k2].PermissionName = "买方研选观点"
  1861. //}
  1862. if len(listThird) > 0 {
  1863. for k3, v3 := range listThird {
  1864. if v3.VideoUrl != "" {
  1865. listThird[k3].IsHaveVideo = true
  1866. }
  1867. if v3.ReportLink == "0" {
  1868. listThird[k3].ReportLink = ""
  1869. }
  1870. }
  1871. listSecond[k2].List = listThird
  1872. }
  1873. }
  1874. if len(listSecond) > 0 {
  1875. listFirst[k].List = listSecond
  1876. }
  1877. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1878. if v.Type == "SDBG" {
  1879. listFirst[k].ListName = "深度报告"
  1880. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1881. } else if v.Type == "BZCHJH" {
  1882. listFirst[k].ListName = "本周晨会精华"
  1883. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1884. } else if v.Type == "CYDYJY" {
  1885. listFirst[k].ListName = "产业调研纪要"
  1886. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1887. } else if v.Type == "SSGS" {
  1888. listFirst[k].ListName = "上市公司调研纪要篇"
  1889. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1890. } else if v.Type == "SJDP" {
  1891. listFirst[k].ListName = "市场QA汇总"
  1892. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1893. } else if v.Type == "YANX" {
  1894. listFirst[k].ListName = "买方研选"
  1895. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1896. }
  1897. }
  1898. //historyRecord := new(models.CygxReportHistoryRecord)
  1899. //historyRecord.UserId = uid
  1900. //historyRecord.ArticleId = articleId
  1901. //historyRecord.CreateTime = time.Now()
  1902. //historyRecord.Mobile = user.Mobile
  1903. //historyRecord.Email = user.Email
  1904. //historyRecord.CompanyId = user.CompanyId
  1905. //historyRecord.CompanyName = user.CompanyName
  1906. //historyRecord.ReportType = "bzyjhz"
  1907. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1908. //if err != nil && err.Error() != utils.ErrNoRow() {
  1909. // br.Msg = "获取信息失败"
  1910. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1911. // return
  1912. //}
  1913. //historyRecord.RealName = user.RealName
  1914. //if sellerItem != nil {
  1915. // historyRecord.SellerName = sellerItem.RealName
  1916. //}
  1917. //go models.AddCygxReportHistoryRecord(historyRecord)
  1918. go services.ResearchSummaryHistoryUserRmind(user, articleId) // 本周研究汇总用户阅读操作操作行为,模板消息推送
  1919. resp.List = listFirst
  1920. resp.Detail = detail
  1921. br.Ret = 200
  1922. br.Success = true
  1923. br.Msg = "获取成功"
  1924. br.Data = resp
  1925. }
  1926. // @Title 上周纪要汇总内容详情
  1927. // @Description 获取上周纪要汇总内容详情接口
  1928. // @Param ArticleId query int true "报告ID"
  1929. // @Success 200 {object} models.MinutesSummaryLetailResp
  1930. // @router /minutesSummary/detailv4 [get]
  1931. func (this *ReportController) MinutesDetailV4() {
  1932. br := new(models.BaseResponse).Init()
  1933. defer func() {
  1934. this.Data["json"] = br
  1935. this.ServeJSON()
  1936. }()
  1937. user := this.User
  1938. if user == nil {
  1939. br.Msg = "请重新登录"
  1940. br.Ret = 408
  1941. return
  1942. }
  1943. //uid := user.UserId
  1944. articleId, _ := this.GetInt("ArticleId")
  1945. if articleId < 0 {
  1946. br.Msg = "参数错误"
  1947. br.ErrMsg = "参数错误"
  1948. return
  1949. }
  1950. resp := new(models.MinutesSummaryLetailRespV4)
  1951. //判断用户权限
  1952. hasPermission, err := services.GetUserhasPermission(user)
  1953. if err != nil {
  1954. br.Msg = "获取信息失败"
  1955. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1956. }
  1957. //resp.HasPermission = hasPermission
  1958. //if hasPermission != 1 {
  1959. // br.Ret = 200
  1960. // br.Success = true
  1961. // br.Msg = "获取成功"
  1962. // br.Data = resp
  1963. // return
  1964. //}
  1965. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1966. if err != nil {
  1967. br.Msg = "获取信息失败"
  1968. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1969. return
  1970. }
  1971. PermissionNameMap, err := services.GetPermissionNameMap()
  1972. if err != nil {
  1973. br.Msg = "获取失败"
  1974. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1975. return
  1976. }
  1977. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1978. if err != nil {
  1979. br.Msg = "获取失败"
  1980. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1981. return
  1982. }
  1983. //未设置全部可见的只能给弘则内部查看
  1984. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1985. resp.IsShow = true
  1986. }
  1987. resp.HasPermission = hasPermission
  1988. if hasPermission != 1 || !resp.IsShow {
  1989. br.Ret = 200
  1990. br.Success = true
  1991. br.Msg = "获取成功"
  1992. br.Data = resp
  1993. return
  1994. }
  1995. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1996. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1997. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1998. if err != nil {
  1999. br.Msg = "获取失败"
  2000. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  2001. return
  2002. }
  2003. for k, v := range listFirst {
  2004. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  2005. if err != nil && err.Error() != utils.ErrNoRow() {
  2006. br.Msg = "获取信息失败"
  2007. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2008. return
  2009. }
  2010. for k2, v2 := range listSecond {
  2011. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  2012. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  2013. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  2014. if err != nil && err.Error() != utils.ErrNoRow() {
  2015. br.Msg = "获取信息失败"
  2016. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2017. return
  2018. }
  2019. if len(listThird) > 0 {
  2020. for k3, v3 := range listThird {
  2021. if v3.VideoUrl != "" {
  2022. listThird[k3].IsHaveVideo = true
  2023. }
  2024. if v3.ReportLink == "0" {
  2025. listThird[k3].ReportLink = ""
  2026. }
  2027. }
  2028. listSecond[k2].List = listThird
  2029. }
  2030. }
  2031. if len(listSecond) > 0 {
  2032. listFirst[k].List = listSecond
  2033. }
  2034. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  2035. if v.Type == "CYDYJY" {
  2036. listFirst[k].ListName = "产业调研纪要"
  2037. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  2038. } else if v.Type == "SSGS" {
  2039. listFirst[k].ListName = "上市公司调研纪要篇"
  2040. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  2041. } else if v.Type == "YANX" {
  2042. listFirst[k].ListName = "买方研选纪要"
  2043. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  2044. }
  2045. }
  2046. //historyRecord := new(models.CygxReportHistoryRecord)
  2047. //historyRecord.UserId = uid
  2048. //historyRecord.ArticleId = articleId
  2049. //historyRecord.CreateTime = time.Now()
  2050. //historyRecord.Mobile = user.Mobile
  2051. //historyRecord.Email = user.Email
  2052. //historyRecord.CompanyId = user.CompanyId
  2053. //historyRecord.CompanyName = user.CompanyName
  2054. //historyRecord.ReportType = "szjyhz"
  2055. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  2056. //if err != nil && err.Error() != utils.ErrNoRow() {
  2057. // br.Msg = "获取信息失败"
  2058. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2059. // return
  2060. //}
  2061. //historyRecord.RealName = user.RealName
  2062. //if sellerItem != nil {
  2063. // historyRecord.SellerName = sellerItem.RealName
  2064. //}
  2065. //go models.AddCygxReportHistoryRecord(historyRecord)
  2066. go services.MinutesSummaryHistoryUserRmind(user, articleId) // 上周纪要汇总用户阅读,给销售发消息提醒
  2067. resp.List = listFirst
  2068. resp.Detail = detail
  2069. br.Ret = 200
  2070. br.Success = true
  2071. br.Msg = "获取成功"
  2072. br.Data = resp
  2073. }
  2074. // @Title 上周纪要汇总内容详情
  2075. // @Description 获取上周纪要汇总内容详情接口
  2076. // @Param ArticleId query int true "报告ID"
  2077. // @Success 200 {object} models.MinutesSummaryLetailResp
  2078. // @router /minutesSummary/detail [get]
  2079. func (this *ReportController) MinutesDetail() {
  2080. br := new(models.BaseResponse).Init()
  2081. defer func() {
  2082. this.Data["json"] = br
  2083. this.ServeJSON()
  2084. }()
  2085. user := this.User
  2086. if user == nil {
  2087. br.Msg = "请重新登录"
  2088. br.Ret = 408
  2089. return
  2090. }
  2091. //uid := user.UserId
  2092. articleId, _ := this.GetInt("ArticleId")
  2093. if articleId < 0 {
  2094. br.Msg = "参数错误"
  2095. br.ErrMsg = "参数错误"
  2096. return
  2097. }
  2098. resp := new(models.MinutesSummaryLetailResp)
  2099. //判断用户权限
  2100. hasPermission, err := services.GetUserhasPermission(user)
  2101. if err != nil {
  2102. br.Msg = "获取信息失败"
  2103. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  2104. }
  2105. resp.HasPermission = hasPermission
  2106. if hasPermission != 1 {
  2107. br.Ret = 200
  2108. br.Success = true
  2109. br.Msg = "获取成功"
  2110. br.Data = resp
  2111. return
  2112. }
  2113. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  2114. if err != nil {
  2115. br.Msg = "获取信息失败"
  2116. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  2117. return
  2118. }
  2119. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  2120. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  2121. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  2122. if err != nil {
  2123. br.Msg = "获取失败"
  2124. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  2125. return
  2126. }
  2127. for k, v := range listLog {
  2128. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  2129. if err != nil && err.Error() != utils.ErrNoRow() {
  2130. br.Msg = "获取信息失败"
  2131. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2132. return
  2133. }
  2134. if len(listSonLog) > 0 {
  2135. for k2, v2 := range listSonLog {
  2136. if v2.ReportLink == "0" {
  2137. listSonLog[k2].ReportLink = ""
  2138. }
  2139. }
  2140. listLog[k].List = listSonLog
  2141. }
  2142. }
  2143. //historyRecord := new(models.CygxReportHistoryRecord)
  2144. //historyRecord.UserId = uid
  2145. //historyRecord.ArticleId = articleId
  2146. //historyRecord.CreateTime = time.Now()
  2147. //historyRecord.Mobile = user.Mobile
  2148. //historyRecord.Email = user.Email
  2149. //historyRecord.CompanyId = user.CompanyId
  2150. //historyRecord.CompanyName = user.CompanyName
  2151. //historyRecord.ReportType = "szjyhz"
  2152. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  2153. //if err != nil && err.Error() != utils.ErrNoRow() {
  2154. // br.Msg = "获取信息失败"
  2155. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2156. // return
  2157. //}
  2158. //historyRecord.RealName = user.RealName
  2159. //if sellerItem != nil {
  2160. // historyRecord.SellerName = sellerItem.RealName
  2161. //}
  2162. //go models.AddCygxReportHistoryRecord(historyRecord)
  2163. resp.List = listLog
  2164. resp.Detail = detail
  2165. br.Ret = 200
  2166. br.Success = true
  2167. br.Msg = "获取成功"
  2168. br.Data = resp
  2169. }
  2170. // @Title 获取路演精华详情
  2171. // @Description 获取路演精华详情接口
  2172. // @Param ArticleId query int true "报告ID"
  2173. // @Success 200 {object} models.RoadshowDetailResp
  2174. // @router /roadshowEssence/detail [get]
  2175. func (this *ReportController) RoadshowDetail() {
  2176. br := new(models.BaseResponse).Init()
  2177. defer func() {
  2178. this.Data["json"] = br
  2179. this.ServeJSON()
  2180. }()
  2181. user := this.User
  2182. if user == nil {
  2183. br.Msg = "请登录"
  2184. br.ErrMsg = "请登录,用户信息为空"
  2185. br.Ret = 408
  2186. return
  2187. }
  2188. uid := user.UserId
  2189. articleId, err := this.GetInt("ArticleId")
  2190. if articleId <= 0 {
  2191. br.Msg = "文章不存在"
  2192. br.ErrMsg = "文章不存在,文章ID错误"
  2193. return
  2194. }
  2195. detail := new(models.ReportDetailRoadshow)
  2196. hasPermission := 0
  2197. hasFree := 0
  2198. //判断是否已经申请过
  2199. applyCount, err := models.GetApplyRecordCount(uid)
  2200. if err != nil && err.Error() != utils.ErrNoRow() {
  2201. br.Msg = "获取信息失败"
  2202. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2203. return
  2204. }
  2205. articleLyjhMap, _ := services.GetLyjhArticleMap()
  2206. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)
  2207. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  2208. if user.CompanyId > 1 {
  2209. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  2210. if err != nil {
  2211. br.Msg = "获取信息失败"
  2212. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  2213. return
  2214. }
  2215. detail, err = models.GetReportRoadshowDetailById(articleId)
  2216. if err != nil {
  2217. br.Msg = "获取信息失败"
  2218. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2219. return
  2220. }
  2221. detail.IsCollect = articleCollectMap[detail.ArticleId]
  2222. detail.IsRoadShow = articleLyjhMap[detail.ArticleId]
  2223. detail.Body = html.UnescapeString(detail.Body)
  2224. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  2225. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  2226. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  2227. if detail.ReportLink == "0" {
  2228. detail.ReportLink = ""
  2229. }
  2230. if companyPermission == "" {
  2231. if applyCount > 0 {
  2232. hasPermission = 5
  2233. } else {
  2234. hasPermission = 2
  2235. }
  2236. hasFree = 2
  2237. goto Loop
  2238. } else {
  2239. hasFree = 1
  2240. var articlePermissionPermissionName string
  2241. articlePermissionPermissionName = detail.CategoryName
  2242. var hasPersion bool
  2243. slice := strings.Split(articlePermissionPermissionName, ",")
  2244. for _, v := range slice {
  2245. if strings.Contains(companyPermission, v) {
  2246. hasPersion = true
  2247. }
  2248. }
  2249. if hasPersion {
  2250. hasPermission = 1
  2251. historyRecord := new(models.CygxArticleHistoryRecord)
  2252. historyRecord.UserId = uid
  2253. historyRecord.ArticleId = articleId
  2254. historyRecord.CreateTime = time.Now()
  2255. historyRecord.Mobile = user.Mobile
  2256. historyRecord.Email = user.Email
  2257. historyRecord.CompanyId = user.CompanyId
  2258. historyRecord.CompanyName = user.CompanyName
  2259. go models.AddCygxArticleHistoryRecord(historyRecord)
  2260. } else { //无该行业权限
  2261. hasPermission = 3
  2262. }
  2263. if hasPermission == 1 {
  2264. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  2265. if !utils.Rc.IsExist(key) {
  2266. //新增浏览记录
  2267. record := new(models.CygxArticleViewRecord)
  2268. record.UserId = uid
  2269. record.ArticleId = articleId
  2270. record.CreateTime = time.Now()
  2271. record.Mobile = user.Mobile
  2272. record.Email = user.Email
  2273. record.CompanyId = user.CompanyId
  2274. record.CompanyName = user.CompanyName
  2275. go models.AddCygxArticleViewRecord(record)
  2276. utils.Rc.Put(key, 1, 5*time.Second)
  2277. models.ModifyReportLastViewTime(uid)
  2278. }
  2279. }
  2280. }
  2281. } else { //潜在客户
  2282. if applyCount > 0 {
  2283. hasPermission = 5
  2284. } else {
  2285. hasPermission = 4
  2286. }
  2287. }
  2288. Loop:
  2289. if hasPermission != 1 {
  2290. detail.Body = ""
  2291. detail.Abstract = ""
  2292. }
  2293. resp := new(models.RoadshowDetailResp)
  2294. resp.HasPermission = hasPermission
  2295. resp.HasFree = hasFree
  2296. resp.Detail = detail
  2297. br.Ret = 200
  2298. br.Success = true
  2299. br.Msg = "获取成功"
  2300. br.Data = resp
  2301. }
  2302. // @Title 产业文章列表接口
  2303. // @Description 获取产业文章列表接口
  2304. // @Param KeyWord query string true "搜索关键词"
  2305. // @Success 200 {object} models.CygxIndustrySearchList
  2306. // @router /industryAndArticle/list [get]
  2307. func (this *ReportController) IndustryAndArticleList() {
  2308. br := new(models.BaseResponse).Init()
  2309. defer func() {
  2310. this.Data["json"] = br
  2311. this.ServeJSON()
  2312. }()
  2313. user := this.User
  2314. if user == nil {
  2315. br.Msg = "请重新登录"
  2316. br.Ret = 408
  2317. return
  2318. }
  2319. uid := user.UserId
  2320. keyWord := this.GetString("KeyWord")
  2321. orderSrt := "update_time DESC"
  2322. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2323. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2324. if err != nil {
  2325. br.Msg = "获取信息失败"
  2326. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2327. return
  2328. }
  2329. for k, v := range list {
  2330. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2331. if err != nil {
  2332. br.Msg = "获取信息失败"
  2333. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2334. return
  2335. }
  2336. list[k].IndustrialSubjectList = industrialSubjectList
  2337. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2338. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2339. if err != nil {
  2340. br.Msg = "获取信息失败"
  2341. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2342. return
  2343. }
  2344. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2345. }
  2346. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2347. if err != nil {
  2348. br.Msg = "获取失败"
  2349. br.ErrMsg = "获取失败,Err:" + err.Error()
  2350. return
  2351. }
  2352. for k2, v2 := range artList {
  2353. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  2354. if err != nil {
  2355. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2356. br.ErrMsg = "获取失败,Err:" + err.Error()
  2357. return
  2358. }
  2359. var subjectNamesNew string
  2360. if len(subjectNames) > 0 {
  2361. slice := strings.Split(subjectNames, "/")
  2362. for k3, v3 := range slice {
  2363. if k3 < 4 {
  2364. subjectNamesNew += v3 + "/"
  2365. }
  2366. }
  2367. }
  2368. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  2369. if err != nil && err.Error() != utils.ErrNoRow() {
  2370. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2371. br.ErrMsg = "获取失败,Err:" + err.Error()
  2372. return
  2373. }
  2374. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2375. artList[k2].SubjectName = subjectNamesNew
  2376. if subjectNamesNew == "" {
  2377. artList[k2].IndustryName = industryName
  2378. } else {
  2379. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  2380. }
  2381. }
  2382. if keyWord != "" {
  2383. keyWordItem := new(models.CygxUserSearchKeyWord)
  2384. keyWordItem.UserId = user.UserId
  2385. keyWordItem.KeyWord = keyWord
  2386. keyWordItem.PageType = "ReortSearch"
  2387. keyWordItem.CreateTime = time.Now()
  2388. go models.AddUserSearchKeyWord(keyWordItem)
  2389. }
  2390. resp := new(models.CygxIndustrySearchList)
  2391. resp.ArtList = artList
  2392. resp.IndList = list
  2393. br.Ret = 200
  2394. br.Success = true
  2395. br.Msg = "获取成功"
  2396. br.Data = resp
  2397. }
  2398. // @Title 产业报告分类关联作者列表接口Pc端
  2399. // @Description 获取产业报告分类关联作者列表接口Pc端
  2400. // @Param ChartPermissionId query int true "分类ID"
  2401. // @Param KeyWord query string true "搜索关键词"
  2402. // @Param PageSize query int true "每页数据条数"
  2403. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2404. // @Success 200 {object} models.CygxArticleDepartmentListPc
  2405. // @router /industryListByDepartmentPc [get]
  2406. func (this *ReportController) IndustryListByDepartmentPc() {
  2407. br := new(models.BaseResponse).Init()
  2408. defer func() {
  2409. this.Data["json"] = br
  2410. this.ServeJSON()
  2411. }()
  2412. user := this.User
  2413. if user == nil {
  2414. br.Msg = "请重新登录"
  2415. br.Ret = 408
  2416. return
  2417. }
  2418. uid := user.UserId
  2419. pageSize, _ := this.GetInt("PageSize")
  2420. currentIndex, _ := this.GetInt("CurrentIndex")
  2421. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  2422. keyWord := this.GetString("KeyWord")
  2423. var startSize int
  2424. var condition string
  2425. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  2426. if pageSize <= 0 {
  2427. pageSize = utils.PageSize20
  2428. }
  2429. if currentIndex <= 0 {
  2430. currentIndex = 1
  2431. }
  2432. var articleIdGroup string
  2433. if keyWord != "" {
  2434. //获取标的关联的文章ID
  2435. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  2436. if err != nil {
  2437. br.Msg = "获取信息失败"
  2438. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2439. return
  2440. }
  2441. //获取产业关联的标的
  2442. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  2443. if err != nil {
  2444. br.Msg = "获取信息失败"
  2445. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  2446. return
  2447. }
  2448. if articleIdSub != "" && articleIdInd != "" {
  2449. articleIdGroup = articleIdSub + "," + articleIdInd
  2450. } else if articleIdSub != "" && articleIdInd == "" {
  2451. articleIdGroup = articleIdSub
  2452. } else if articleIdSub == "" && articleIdInd != "" {
  2453. articleIdGroup = articleIdInd
  2454. }
  2455. slice := strings.Split(keyWord, "/")
  2456. if len(slice) > 1 {
  2457. var subjectIds string
  2458. for _, v := range slice {
  2459. subjectId, err := models.GetcygxIndustrialSubjectByName(v)
  2460. if err != nil && err.Error() != utils.ErrNoRow() {
  2461. br.Msg = "获取信息失败"
  2462. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2463. return
  2464. }
  2465. if subjectId != "" {
  2466. subjectIds += subjectId + ","
  2467. }
  2468. }
  2469. subjectIds = strings.TrimRight(subjectIds, ",")
  2470. if len(subjectIds) > 0 {
  2471. articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
  2472. if err != nil {
  2473. br.Msg = "获取信息失败"
  2474. br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
  2475. return
  2476. }
  2477. if articleIdGroup != "" {
  2478. if articleBySub != "" {
  2479. articleIdGroup += "," + articleBySub
  2480. }
  2481. } else {
  2482. articleIdGroup = articleBySub
  2483. }
  2484. }
  2485. }
  2486. }
  2487. if articleIdGroup != "" {
  2488. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  2489. }
  2490. startSize = paging.StartIndex(currentIndex, pageSize)
  2491. total, err := models.GetArticleDepartmentCount(condition)
  2492. page := paging.GetPaging(currentIndex, pageSize, total)
  2493. resp := new(models.CygxArticleDepartmentListPc)
  2494. userType, _, err := services.GetUserType(user.CompanyId)
  2495. if err != nil {
  2496. br.Msg = "获取信息失败"
  2497. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  2498. return
  2499. }
  2500. if userType == 1 {
  2501. resp.Paging = page
  2502. br.Ret = 200
  2503. br.Success = true
  2504. br.Msg = "获取成功"
  2505. br.Data = resp
  2506. return
  2507. }
  2508. resp.HaveResearch = true
  2509. //获取作者信息,并排序
  2510. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  2511. if err != nil {
  2512. br.Msg = "获取信息失败"
  2513. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2514. return
  2515. }
  2516. for k, v := range list {
  2517. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  2518. if err != nil {
  2519. br.Msg = "获取信息失败"
  2520. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2521. return
  2522. }
  2523. for k2, v2 := range artList {
  2524. if artList[k2].IsReport == "1" {
  2525. artList[k2].Title = v2.Title
  2526. } else {
  2527. artList[k2].Title = v2.Title
  2528. }
  2529. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2530. }
  2531. list[k].List = artList
  2532. if v.FollowNum > 0 {
  2533. list[k].IsMyFollow = true
  2534. }
  2535. }
  2536. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  2537. if err != nil {
  2538. br.Msg = "获取信息失败"
  2539. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2540. return
  2541. }
  2542. if len(listnNew) > 0 {
  2543. for _, v := range listnNew {
  2544. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  2545. Management := new(models.IndustrialManagementIdInt)
  2546. if firstStr == 0 {
  2547. Management.IndustryName = v.IndustryName
  2548. } else {
  2549. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  2550. if err != nil {
  2551. br.Msg = "获取信息失败"
  2552. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  2553. return
  2554. }
  2555. var subjectNamesNew string
  2556. for _, v1 := range listSub {
  2557. subjectNamesNew += v1.SubjectName + "/"
  2558. }
  2559. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2560. Management.IndustryName = subjectNamesNew
  2561. }
  2562. Management.IndustrialManagementId = v.IndustrialManagementId
  2563. Management.ArticleId = v.ArticleId
  2564. resp.ListnNew = append(resp.ListnNew, Management)
  2565. }
  2566. }
  2567. resp.List = list
  2568. resp.Paging = page
  2569. br.Ret = 200
  2570. br.Success = true
  2571. br.Msg = "获取成功"
  2572. br.Data = resp
  2573. }
  2574. // @Title 产业文章列表接口Pc端
  2575. // @Description 获取产业文章列表接口Pc端
  2576. // @Param KeyWord query string true "搜索关键词"
  2577. // @Success 200 {object} models.CygxIndustrySearchListPc
  2578. // @router /industryAndArticle/listPc [get]
  2579. func (this *ReportController) IndustryAndArticleListPc() {
  2580. br := new(models.BaseResponse).Init()
  2581. defer func() {
  2582. this.Data["json"] = br
  2583. this.ServeJSON()
  2584. }()
  2585. user := this.User
  2586. if user == nil {
  2587. br.Msg = "请重新登录"
  2588. br.Ret = 408
  2589. return
  2590. }
  2591. uid := user.UserId
  2592. keyWord := this.GetString("KeyWord")
  2593. resp := new(models.CygxIndustrySearchListPc)
  2594. orderSrt := "update_time DESC"
  2595. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2596. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2597. if err != nil {
  2598. br.Msg = "获取信息失败"
  2599. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2600. return
  2601. }
  2602. for k, v := range list {
  2603. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2604. if err != nil {
  2605. br.Msg = "获取信息失败"
  2606. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2607. return
  2608. }
  2609. list[k].IndustrialSubjectList = industrialSubjectList
  2610. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2611. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2612. if err != nil {
  2613. br.Msg = "获取信息失败"
  2614. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2615. return
  2616. }
  2617. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2618. }
  2619. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2620. if err != nil {
  2621. br.Msg = "获取失败"
  2622. br.ErrMsg = "获取失败,Err:" + err.Error()
  2623. return
  2624. }
  2625. if len(artList) > 0 {
  2626. var articleIds string
  2627. for _, v := range artList {
  2628. articleIds += strconv.Itoa(v.ArticleId) + ","
  2629. }
  2630. articleIds = strings.TrimRight(articleIds, ",")
  2631. if articleIds != "" {
  2632. condition = ` AND a.article_id IN (` + articleIds + `)`
  2633. DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
  2634. if err != nil {
  2635. br.Msg = "获取信息失败"
  2636. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2637. return
  2638. }
  2639. for k, v := range DepartmentList {
  2640. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
  2641. if err != nil {
  2642. br.Msg = "获取信息失败"
  2643. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2644. return
  2645. }
  2646. for k2, v2 := range artList {
  2647. if artList[k2].IsReport == "1" {
  2648. artList[k2].Title = v2.Title
  2649. } else {
  2650. artList[k2].Title = v2.Title
  2651. }
  2652. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2653. }
  2654. DepartmentList[k].List = artList
  2655. if v.FollowNum > 0 {
  2656. DepartmentList[k].IsMyFollow = true
  2657. }
  2658. }
  2659. resp.DepartmentList = DepartmentList
  2660. }
  2661. }
  2662. if keyWord != "" {
  2663. keyWordItem := new(models.CygxUserSearchKeyWord)
  2664. keyWordItem.UserId = user.UserId
  2665. keyWordItem.KeyWord = keyWord
  2666. keyWordItem.PageType = "ReortSearch"
  2667. keyWordItem.CreateTime = time.Now()
  2668. go models.AddUserSearchKeyWord(keyWordItem)
  2669. }
  2670. resp.IndList = list
  2671. br.Ret = 200
  2672. br.Success = true
  2673. br.Msg = "获取成功"
  2674. br.Data = resp
  2675. }
  2676. // @Title 报告搜索
  2677. // @Description 报告搜索接口
  2678. // @Param KeyWord query string true "搜索关键词"
  2679. // @Success 200 {object} models.ReoprtSearchResp
  2680. // @router /searchReport [get]
  2681. func (this *ReportController) SearchReport() {
  2682. br := new(models.BaseResponse).Init()
  2683. defer func() {
  2684. this.Data["json"] = br
  2685. this.ServeJSON()
  2686. }()
  2687. user := this.User
  2688. if user == nil {
  2689. br.Msg = "请重新登录"
  2690. br.Ret = 408
  2691. return
  2692. }
  2693. keyWord := this.GetString("KeyWord")
  2694. var condition string
  2695. var sqlGroup string
  2696. //匹配报告标题、
  2697. condition = `AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  2698. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2699. //对应产业名称、标的名称。
  2700. listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2701. if err != nil {
  2702. br.Msg = "获取信息失败"
  2703. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2704. return
  2705. }
  2706. for k, v := range listYx {
  2707. listYx[k].Source = 2
  2708. if v.MyCollectNum > 0 {
  2709. listYx[k].IsCollect = true
  2710. }
  2711. }
  2712. listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2713. if err != nil {
  2714. br.Msg = "获取信息失败"
  2715. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2716. return
  2717. }
  2718. for k, v := range listHz {
  2719. listHz[k].Source = 1
  2720. if v.MyCollectNum > 0 {
  2721. listHz[k].IsCollect = true
  2722. }
  2723. }
  2724. if keyWord != "" {
  2725. keyWordItem := new(models.CygxUserSearchKeyWord)
  2726. keyWordItem.UserId = user.UserId
  2727. keyWordItem.KeyWord = keyWord
  2728. keyWordItem.PageType = "ReortSearch"
  2729. keyWordItem.CreateTime = time.Now()
  2730. go models.AddUserSearchKeyWord(keyWordItem)
  2731. //go services.AddUserSearchLog(user, keyWord, 5)
  2732. }
  2733. if len(listYx) == 0 {
  2734. listYx = make([]*models.ArticleCollectionResp, 0)
  2735. }
  2736. if len(listHz) == 0 {
  2737. listHz = make([]*models.ArticleCollectionResp, 0)
  2738. }
  2739. resp := new(models.ReoprtSearchResp)
  2740. resp.ListYx = listYx
  2741. resp.ListHz = listHz
  2742. br.Ret = 200
  2743. br.Success = true
  2744. br.Msg = "获取成功"
  2745. br.Data = resp
  2746. }
  2747. // @Title 资源包搜索
  2748. // @Description 资源包搜索接口
  2749. // @Param KeyWord query string true "搜索关键词"
  2750. // @Success 200 {object} models.SearchResourceResp
  2751. // @router /searchResource [get]
  2752. func (this *ReportController) SearchResource() {
  2753. br := new(models.BaseResponse).Init()
  2754. defer func() {
  2755. this.Data["json"] = br
  2756. this.ServeJSON()
  2757. }()
  2758. user := this.User
  2759. if user == nil {
  2760. br.Msg = "请重新登录"
  2761. br.Ret = 408
  2762. return
  2763. }
  2764. uid := user.UserId
  2765. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2766. if err != nil {
  2767. br.Msg = "获取失败"
  2768. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2769. return
  2770. }
  2771. fllowMap := make(map[int]int)
  2772. if len(fllowList) > 0 {
  2773. for _, v := range fllowList {
  2774. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2775. }
  2776. }
  2777. keyWord := this.GetString("KeyWord")
  2778. var condition string
  2779. var conditionOr string
  2780. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2781. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2782. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2783. listHz, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  2784. if err != nil {
  2785. br.Msg = "获取信息失败"
  2786. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2787. return
  2788. }
  2789. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2790. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2791. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2792. listYx, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  2793. if err != nil {
  2794. br.Msg = "获取信息失败"
  2795. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2796. return
  2797. }
  2798. //合并产业关联的标的
  2799. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2800. if err != nil {
  2801. br.Msg = "获取信息失败"
  2802. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2803. return
  2804. }
  2805. industrialIdArr := make([]int, 0)
  2806. for k, v := range listHz {
  2807. listHz[k].Source = 1
  2808. if fllowMap[v.IndustrialManagementId] > 0 {
  2809. listHz[k].IsFollw = true
  2810. }
  2811. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2812. }
  2813. for k, v := range listYx {
  2814. listYx[k].Source = 2
  2815. if fllowMap[v.IndustrialManagementId] > 0 {
  2816. listYx[k].IsFollw = true
  2817. }
  2818. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2819. }
  2820. if len(industrialIdArr) > 0 {
  2821. //合并产业关联的标的
  2822. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2823. if err != nil {
  2824. br.Msg = "获取信息失败"
  2825. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2826. return
  2827. }
  2828. mapIndustrial := make(map[string]int)
  2829. for _, v := range listSubjcet {
  2830. for k2, v2 := range listYx {
  2831. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2832. listYx[k2].IndustrialSubjectList = append(listYx[k2].IndustrialSubjectList, v)
  2833. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2834. }
  2835. }
  2836. for k2, v2 := range listHz {
  2837. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2838. listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
  2839. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2840. }
  2841. }
  2842. }
  2843. }
  2844. if keyWord != "" {
  2845. keyWordItem := new(models.CygxUserSearchKeyWord)
  2846. keyWordItem.UserId = user.UserId
  2847. keyWordItem.KeyWord = keyWord
  2848. keyWordItem.PageType = "ReortSearch"
  2849. keyWordItem.CreateTime = time.Now()
  2850. go models.AddUserSearchKeyWord(keyWordItem)
  2851. }
  2852. resp := new(models.SearchResourceResp)
  2853. if len(listYx) == 0 {
  2854. listYx = make([]*models.IndustrialManagementHotResp, 0)
  2855. }
  2856. if len(listHz) == 0 {
  2857. listHz = make([]*models.IndustrialManagementHotResp, 0)
  2858. }
  2859. resp.ListYx = listYx
  2860. resp.ListHz = listHz
  2861. br.Ret = 200
  2862. br.Success = true
  2863. br.Msg = "获取成功"
  2864. br.Data = resp
  2865. }
  2866. // @Title 报告搜索、资源包搜索接口
  2867. // @Description 报告搜索、资源包搜索接口接口
  2868. // @Param KeyWord query string true "搜索关键词"
  2869. // @Param PageSize query int true "每页数据条数"
  2870. // @Success 200 {object} models.SearchReportAndResourceResp
  2871. // @router /searchReportAndResource [get]
  2872. func (this *ReportController) SearchReportAndResource() {
  2873. br := new(models.BaseResponse).Init()
  2874. defer func() {
  2875. this.Data["json"] = br
  2876. this.ServeJSON()
  2877. }()
  2878. user := this.User
  2879. if user == nil {
  2880. br.Msg = "请重新登录"
  2881. br.Ret = 408
  2882. return
  2883. }
  2884. uid := user.UserId
  2885. keyWord := this.GetString("KeyWord")
  2886. pageSize, _ := this.GetInt("PageSize")
  2887. var condition string
  2888. var conditionSpecial string // 研选专栏
  2889. var sqlGroup string
  2890. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  2891. if err != nil {
  2892. br.Msg = "获取信息失败"
  2893. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  2894. return
  2895. }
  2896. if articleTypeIds == "" {
  2897. br.Msg = "获取信息失败"
  2898. br.ErrMsg = "研选分类ID不能为空"
  2899. return
  2900. }
  2901. //匹配报告标题、
  2902. //condition = `AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  2903. condition = `AND ( a.title LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  2904. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2905. //if pageSize > 0 {
  2906. // sqlGroup += ` LIMIT 5 `
  2907. //} else {
  2908. sqlGroup += ` LIMIT 100 `
  2909. //}
  2910. conditionSpecial = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.content LIKE '%` + keyWord + `%' )`
  2911. //ListYxReport, err := models.GetArticleAndYxSpecialList(` AND a.article_type_id IN (`+articleTypeIds+`) `+condition, conditionSpecial, user.UserId)
  2912. ListYxReport, err := models.GetArticleAndYxSpecialList(condition, conditionSpecial, user.UserId)
  2913. if err != nil {
  2914. br.Msg = "获取信息失败"
  2915. br.ErrMsg = "获取研选文章列表失败,Err:" + err.Error()
  2916. return
  2917. }
  2918. //ListHzReport, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+articleTypeIds+`) `+condition+sqlGroup, user.UserId)
  2919. //if err != nil {
  2920. // br.Msg = "获取信息失败"
  2921. // br.ErrMsg = "获取弘则报告文章列表失败,Err:" + err.Error()
  2922. // return
  2923. //}
  2924. keyWordArr, err := services.GetIndustryMapNameSliceV3(keyWord)
  2925. if err != nil {
  2926. br.Msg = "获取失败"
  2927. br.ErrMsg = "获取分词失败,GetIndustryMapNameSliceV3 Err: " + err.Error()
  2928. return
  2929. }
  2930. keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  2931. var keyWordIk string
  2932. if len(keyWordArr) > 1 {
  2933. keyWordIk = services.KeyWordArrSqlRegexp(keyWordArr)
  2934. var conditionIk string
  2935. var sqlGroupIk string
  2936. conditionIk = `AND ( a.title REGEXP '` + keyWordIk + `' OR a.annotation REGEXP '` + keyWordIk + `' OR a.abstract REGEXP '` + keyWordIk + `') AND a.publish_status = 1 `
  2937. sqlGroupIk = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2938. if pageSize > 0 {
  2939. sqlGroupIk += ` LIMIT 5 `
  2940. } else {
  2941. sqlGroupIk += ` LIMIT 20 `
  2942. }
  2943. //conditionIk += ` AND ( a.title NOT LIKE '%` + keyWord + `%' AND a.body NOT LIKE '%` + keyWord + `%' AND a.annotation NOT LIKE '%` + keyWord + `%' AND a.abstract NOT LIKE '%` + keyWord + `%') `
  2944. conditionIk += ` AND ( a.title NOT LIKE '%` + keyWord + `%' AND a.annotation NOT LIKE '%` + keyWord + `%' AND a.abstract NOT LIKE '%` + keyWord + `%') `
  2945. //研选的联想词列表
  2946. //ListYxReportIk, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+articleTypeIds+`) `+conditionIk+sqlGroupIk, user.UserId)
  2947. ListYxReportIk, err := models.GetArticleCollectionList(conditionIk+sqlGroupIk, user.UserId)
  2948. if err != nil && err.Error() != utils.ErrNoRow() {
  2949. br.Msg = "获取信息失败"
  2950. br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2951. return
  2952. }
  2953. if len(ListYxReportIk) > 0 {
  2954. for _, v := range ListYxReportIk {
  2955. ListYxReport = append(ListYxReport, v)
  2956. }
  2957. }
  2958. ////弘则的联想词列表
  2959. //ListHzReportIk, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+articleTypeIds+`) `+conditionIk+sqlGroupIk, user.UserId)
  2960. //if err != nil && err.Error() != utils.ErrNoRow() {
  2961. // br.Msg = "获取信息失败"
  2962. // br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2963. // return
  2964. //}
  2965. //if len(ListHzReportIk) > 0 {
  2966. // for _, v := range ListHzReportIk {
  2967. // ListHzReport = append(ListHzReport, v)
  2968. // }
  2969. //}
  2970. }
  2971. var articleIdsArr []int
  2972. var articleIdsSpecialArr []int // 研选专栏ID
  2973. //for k, v := range ListHzReport {
  2974. // ListHzReport[k].Source = 1
  2975. // //if v.MyCollectNum > 0 {
  2976. // // ListHzReport[k].IsCollect = true
  2977. // //}
  2978. // articleIdsArr = append(articleIdsArr, v.ArticleId)
  2979. //}
  2980. for k, v := range ListYxReport {
  2981. ListYxReport[k].Source = 2
  2982. //if v.MyCollectNum > 0 {
  2983. // ListYxReport[k].IsCollect = true
  2984. //}
  2985. if v.ArticleTypeId == -1 {
  2986. articleIdsSpecialArr = append(articleIdsSpecialArr, v.ArticleId)
  2987. } else {
  2988. articleIdsArr = append(articleIdsArr, v.ArticleId)
  2989. }
  2990. }
  2991. var articleIds string
  2992. //for _, v := range ListHzReport {
  2993. // articleIds += strconv.Itoa(v.ArticleId) + ","
  2994. //}
  2995. articleMapPv := services.GetArticleHistoryByArticleId(articleIdsArr) //文章Pv
  2996. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  2997. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIdsArr) //文章收藏的数量
  2998. articleCollectYanxuanSpecialMap, _ := services.GetYanxuanSpecialCollectMap(user.UserId) //用户收藏的研选专栏
  2999. for i, v := range ListYxReport {
  3000. articleIds += strconv.Itoa(v.ArticleId) + ","
  3001. if v.ArticleTypeId == -1 {
  3002. v.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
  3003. v.IsCollect = articleCollectYanxuanSpecialMap[v.ArticleId]
  3004. } else if v.ArticleTypeId > 0 {
  3005. ListYxReport[i].ArticleTypeName = utils.CYGX_YANXUAN_ARTICLE
  3006. ListYxReport[i].Pv = articleMapPv[v.ArticleId]
  3007. ListYxReport[i].CollectNum = articleCollectNumMap[v.ArticleId]
  3008. ListYxReport[i].IsCollect = articleCollectMap[v.ArticleId]
  3009. }
  3010. if v.SpecialType == 1 {
  3011. ListYxReport[i].Title = "【笔记】" + ListYxReport[i].Title
  3012. } else if ListYxReport[i].SpecialType == 2 {
  3013. ListYxReport[i].Title = "【观点】" + ListYxReport[i].Title
  3014. }
  3015. if v.CompanyTags != "" {
  3016. v.SpecialTags += v.CompanyTags
  3017. }
  3018. if v.IndustryTags != "" {
  3019. if v.SpecialTags != "" {
  3020. v.SpecialTags += ","
  3021. }
  3022. v.SpecialTags += v.IndustryTags
  3023. }
  3024. v.SpecialTags = v.SpecialTags
  3025. if v.IsSpecial == 1 {
  3026. v.Resource = 2
  3027. } else {
  3028. if v.ReportId > 0 {
  3029. v.Resource = 3
  3030. v.ReportId = v.ReportId
  3031. } else {
  3032. v.Resource = 1
  3033. }
  3034. }
  3035. }
  3036. articleIds = strings.TrimRight(articleIds, ",")
  3037. silcearticleIds := strings.Split(articleIds, ",")
  3038. var parsindustrial []interface{}
  3039. parsindustrial = make([]interface{}, 0)
  3040. articleIdList := make([]string, 0)
  3041. for _, v := range silcearticleIds {
  3042. articleIdList = append(articleIdList, v)
  3043. }
  3044. conditionindustrial := ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` ) `
  3045. parsindustrial = append(parsindustrial, articleIdList)
  3046. industrialList, err := models.GetIndustrialListByarticleId(parsindustrial, conditionindustrial)
  3047. if err != nil {
  3048. return
  3049. }
  3050. industrialMap := make(map[int][]*models.IndustrialManagementResp)
  3051. if len(industrialList) > 0 {
  3052. for _, v := range industrialList {
  3053. item := new(models.IndustrialManagementResp)
  3054. //item.ArticleId = v.ArticleId
  3055. item.IndustrialManagementId = v.IndustrialManagementId
  3056. item.IndustryName = v.IndustryName
  3057. item.ChartPermissionId = v.ChartPermissionId
  3058. industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
  3059. }
  3060. }
  3061. //for k, v := range ListHzReport {
  3062. // if len(industrialMap[v.ArticleId]) > 0 {
  3063. // ListHzReport[k].List = industrialMap[v.ArticleId]
  3064. // } else {
  3065. // ListHzReport[k].List = make([]*models.IndustrialManagementResp, 0)
  3066. // }
  3067. // v.Pv = articleMapPv[v.ArticleId]
  3068. // v.CollectNum = articleCollectNumMap[v.ArticleId]
  3069. // v.IsCollect = articleCollectMap[v.ArticleId]
  3070. // if v.ReportId > 0 {
  3071. // v.Resource = 3
  3072. // }
  3073. //}
  3074. for k, v := range ListYxReport {
  3075. if len(industrialMap[v.ArticleId]) > 0 {
  3076. ListYxReport[k].List = industrialMap[v.ArticleId]
  3077. } else {
  3078. ListYxReport[k].List = make([]*models.IndustrialManagementResp, 0)
  3079. }
  3080. }
  3081. //获取文章关联的产业
  3082. if len(ListYxReport) == 0 {
  3083. ListYxReport = make([]*models.ArticleCollectionResp, 0)
  3084. }
  3085. //if len(ListHzReport) == 0 {
  3086. // ListHzReport = make([]*models.ArticleCollectionResp, 0)
  3087. //}
  3088. fllowList, err := models.GetUserFllowIndustrialList(uid)
  3089. if err != nil {
  3090. br.Msg = "获取失败"
  3091. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  3092. return
  3093. }
  3094. fllowMap := make(map[int]int)
  3095. if len(fllowList) > 0 {
  3096. for _, v := range fllowList {
  3097. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  3098. }
  3099. }
  3100. condition = ` AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  3101. listHzResource, err := models.GetSearchResourceListcondition(condition, 0, pageSize)
  3102. if err != nil {
  3103. br.Msg = "获取信息失败"
  3104. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3105. return
  3106. }
  3107. if len(listHzResource) > 0 {
  3108. listHzResource, err = services.HandleIndustryListHzAndYx(listHzResource, user, "Hz")
  3109. if err != nil {
  3110. br.Msg = "获取信息失败"
  3111. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3112. return
  3113. }
  3114. }
  3115. //condition = ` AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  3116. //
  3117. //hotMapindustrial, e := services.IndustrialManagementHotMapGropuPermission()
  3118. //if e != nil {
  3119. // br.Msg = "获取信息失败"
  3120. // br.ErrMsg = "获取hot标签失败,IndustrialManagementHotMapGropuPermission ,Err:" + err.Error()
  3121. // return
  3122. //}
  3123. //listYxResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  3124. //if err != nil {
  3125. // br.Msg = "获取信息失败"
  3126. // br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  3127. // return
  3128. //}
  3129. ////合并产业关联的标的
  3130. //listSubjcet, err := models.GetThemeHeatSubjectList("")
  3131. //if err != nil {
  3132. // br.Msg = "获取信息失败"
  3133. // br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3134. // return
  3135. //}
  3136. //industrialIdArr := make([]int, 0)
  3137. //nowTime := time.Now().Local()
  3138. //threeMonBefore := nowTime.AddDate(0, -3, 0)
  3139. //mapHot := make(map[int]bool)
  3140. //
  3141. ////if themeType == 2 {
  3142. //mapHot, err = services.GetYanXuanIndustrialManagementIdHotMap(articleTypeIds)
  3143. //if err != nil {
  3144. // br.Msg = "获取信息失败"
  3145. // br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error()
  3146. // return
  3147. //}
  3148. //
  3149. ////conditionOrder := ` ORDER BY sum_num DESC `
  3150. ////listHot, err := models.GetThemeHeatList(user.UserId, condition, conditionOrder, 0, 3)
  3151. ////if err != nil {
  3152. //// br.Msg = "获取信息失败"
  3153. //// br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3154. //// return
  3155. ////}
  3156. //for k, _ := range mapHot {
  3157. // industrialIdArr = append(industrialIdArr, k)
  3158. //}
  3159. //orderSrt := "man.recommended_index DESC,update_time DESC"
  3160. //for k, v := range listHzResource {
  3161. // // 关联报告发布时间均在3个月内则标记New
  3162. // if v.MinReportTime != "" {
  3163. // t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3164. // if e != nil {
  3165. // err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3166. // return
  3167. // }
  3168. // if t.After(threeMonBefore) {
  3169. // listHzResource[k].IsNew = true
  3170. // }
  3171. // }
  3172. // //弘则资源包不展示hot标签
  3173. // //if mapHot[v.IndustryName] > 0 {
  3174. // // listHzResource[k].IsHot = true
  3175. // //}
  3176. // listHzResource[k].Source = 1
  3177. // if fllowMap[v.IndustrialManagementId] > 0 {
  3178. // listHzResource[k].IsFollw = true
  3179. // }
  3180. // v.IsHot = hotMapindustrial[v.IndustrialManagementId]
  3181. // industrialIdSlice := make([]int, 0)
  3182. // articleIdArr := make([]int, 0)
  3183. // industrialIdSlice = append(industrialIdSlice, v.IndustrialManagementId)
  3184. // listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdSlice)
  3185. // if err != nil && err.Error() != utils.ErrNoRow() {
  3186. // return
  3187. // }
  3188. // for _, v := range listUpdateTime {
  3189. // articleIdArr = append(articleIdArr, v.ArticleId)
  3190. // }
  3191. //
  3192. // if err != nil {
  3193. // return
  3194. // }
  3195. // mapHistroyArticleId := make(map[int]int)
  3196. //
  3197. // if user.UserId > 0 {
  3198. // listArticleHistory, e := models.GetUserToArticleHistory(user.UserId, articleIdArr)
  3199. // if e != nil && e.Error() != utils.ErrNoRow() {
  3200. // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  3201. // return
  3202. // }
  3203. // for _, v := range listArticleHistory {
  3204. // mapHistroyArticleId[v.ArticleId] = v.ArticleId
  3205. // }
  3206. // }
  3207. // condition2 := ` AND man.industry_name LIKE '%` + keyWord + `%' `
  3208. // list, err := models.GetIndustrialManagementAll(uid, condition2, orderSrt, 0, 20)
  3209. // if err != nil {
  3210. // br.Msg = "获取信息失败"
  3211. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3212. // return
  3213. // }
  3214. //
  3215. // mapUPdateTime := make(map[int]string)
  3216. // //获取这些产业下最新更新的文章
  3217. //
  3218. // //时间线的更新时间
  3219. // // maptimelineUPdateTime := make(map[int]string)
  3220. // listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
  3221. // if err != nil && err.Error() != utils.ErrNoRow() {
  3222. // br.Msg = "获取信息失败"
  3223. // br.ErrMsg = "GetTimeLineReportIndustrialPublishdateList,Err:" + err.Error()
  3224. // return
  3225. // }
  3226. // for _, v := range listtimelinePublishdate {
  3227. // if mapUPdateTime[v.IndustrialManagementId] != "" {
  3228. // if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3229. // mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
  3230. // }
  3231. // }
  3232. // }
  3233. //
  3234. // //mapHistroyArticleId := make(map[int]int)
  3235. //
  3236. // //if userId > 0 {
  3237. // // listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
  3238. // // if e != nil && e.Error() != utils.ErrNoRow() {
  3239. // // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  3240. // // return
  3241. // // }
  3242. // // for _, v := range listArticleHistory {
  3243. // // mapHistroyArticleId[v.ArticleId] = v.ArticleId
  3244. // // }
  3245. // //}
  3246. // var industrialIds string
  3247. // for _, id := range industrialIdArr {
  3248. // industrialIds += strconv.Itoa(id) + ","
  3249. // }
  3250. // industrialIds = strings.TrimRight(industrialIds, ",")
  3251. // articleList, err := models.GetReportIndustrialReadNumList(user.UserId, industrialIds, user.CreatedTime)
  3252. // if err != nil && err.Error() != utils.ErrNoRow() {
  3253. // br.Msg = "获取信息失败"
  3254. // br.ErrMsg = "GetReportIndustrialReadNumList,Err:" + err.Error()
  3255. // return
  3256. // }
  3257. // mapHistroyindustrialId := make(map[int]int)
  3258. // for _, v := range articleList {
  3259. // mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
  3260. // }
  3261. // //nowTime := time.Now().Local()
  3262. // //threeMonBefore := nowTime.AddDate(0, -3, 0)
  3263. //
  3264. // //查询用户今天是否看过时间线
  3265. // //haveMorningMeeting := false
  3266. // //var morningMeetingTime string
  3267. // recrodList, err := models.GetTimeLineRecordAllCount(user.UserId, time.Now().Format(utils.FormatDate))
  3268. // if err != nil {
  3269. // br.Msg = "获取信息失败"
  3270. // br.ErrMsg = "GetTimeLineRecordAllCount,Err:" + err.Error()
  3271. // return
  3272. // }
  3273. // var industrialManagementIdstr string
  3274. // industrialIdMap := make(map[string]time.Time)
  3275. // for _, v := range recrodList {
  3276. // industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
  3277. // if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
  3278. // if createTime.Before(v.CreateTime) {
  3279. // industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3280. // }
  3281. // } else {
  3282. // industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3283. // }
  3284. // }
  3285. //
  3286. // mmList, err := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
  3287. // if err != nil {
  3288. // return
  3289. // }
  3290. // morningMeetingTimeMap := make(map[int]time.Time)
  3291. // for _, v := range mmList {
  3292. // morningMeetingTimeMap[v.IndustryId] = v.CreateTime
  3293. // }
  3294. // timeLineRedMap := make(map[int]bool, 0)
  3295. //
  3296. // for _, industrialId := range industrialIdArr {
  3297. // if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
  3298. // if createTime.Before(morningMeetingTimeMap[industrialId]) {
  3299. // timeLineRedMap[industrialId] = true
  3300. // }
  3301. // }
  3302. // }
  3303. //
  3304. // for k, v := range list {
  3305. // list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3306. // if user.UserId > 0 {
  3307. // //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3308. // if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3309. // if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3310. // list[k].IsRed = true
  3311. // }
  3312. // }
  3313. // } else {
  3314. // if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3315. // list[k].IsRed = true
  3316. // }
  3317. // list[k].IsFollow = 0
  3318. // }
  3319. //
  3320. // list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3321. // if user.UserId > 0 {
  3322. // //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3323. // if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3324. // if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3325. // list[k].IsRed = true
  3326. // }
  3327. // }
  3328. // } else {
  3329. // if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3330. // list[k].IsRed = true
  3331. // }
  3332. // list[k].IsFollow = 0
  3333. // }
  3334. // }
  3335. //
  3336. // industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3337. //}
  3338. //
  3339. //for k, v := range listYxResource {
  3340. // // 关联报告发布时间均在3个月内则标记New
  3341. // if v.MinReportTime != "" {
  3342. // t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3343. // if e != nil {
  3344. // err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3345. // return
  3346. // }
  3347. // if t.After(threeMonBefore) {
  3348. // listYxResource[k].IsNew = true
  3349. // }
  3350. // }
  3351. // listYxResource[k].IsHot = mapHot[v.IndustrialManagementId]
  3352. // listYxResource[k].Source = 2
  3353. // if fllowMap[v.IndustrialManagementId] > 0 {
  3354. // listYxResource[k].IsFollw = true
  3355. // }
  3356. // v.IsHot = hotMapindustrial[v.IndustrialManagementId]
  3357. // industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3358. //}
  3359. //
  3360. //if len(industrialIdArr) > 0 {
  3361. // //查询产业视频
  3362. // industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
  3363. // // 获取默认图配置
  3364. // _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  3365. // if e != nil {
  3366. // br.Msg = "获取视频默认配置图失败"
  3367. // br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  3368. // return
  3369. // }
  3370. // videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialIdArr)
  3371. // if err != nil {
  3372. // br.Msg = "产业视频列表失败"
  3373. // br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
  3374. // return
  3375. // }
  3376. // for _, v := range videoList {
  3377. // tmp := &models.MicroVideoSimpleInfo{
  3378. // Id: v.VideoId,
  3379. // Title: "5min逻辑【" + v.IndustryName + "】解析",
  3380. // ResourceUrl: v.VideoUrl,
  3381. // BackgroundImg: v.ImgUrl,
  3382. // PlaySeconds: v.VideoDuration,
  3383. // DetailImgUrl: v.DetailImgUrl,
  3384. // ChartPermissionName: v.ChartPermissionName,
  3385. // ChartPermissionId: v.ChartPermissionId,
  3386. // }
  3387. // if tmp.BackgroundImg == "" {
  3388. // tmp.BackgroundImg = videoMap[v.ChartPermissionId]
  3389. // }
  3390. // industrialVideoMap[v.IndustryId] = tmp
  3391. // }
  3392. //
  3393. // //查询权限
  3394. // // 用户权限
  3395. // authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  3396. // if e != nil {
  3397. // br.Msg = "获取失败"
  3398. // br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  3399. // return
  3400. // }
  3401. //
  3402. // for k, v := range listHzResource {
  3403. // //展示产业视频
  3404. // if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
  3405. // au := new(models.UserPermissionAuthInfo)
  3406. // au.SellerName = authInfo.SellerName
  3407. // au.SellerMobile = authInfo.SellerMobile
  3408. // au.HasPermission = authInfo.HasPermission
  3409. // au.OperationMode = authInfo.OperationMode
  3410. // if au.HasPermission == 1 {
  3411. // // 非宏观权限进一步判断是否有权限
  3412. // if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  3413. // au.HasPermission = 2
  3414. // }
  3415. // }
  3416. // // 无权限的弹框提示
  3417. // if au.HasPermission != 1 {
  3418. // if au.OperationMode == services.UserPermissionOperationModeCall {
  3419. // au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  3420. // } else {
  3421. // au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  3422. // }
  3423. // video.ResourceUrl = ""
  3424. // }
  3425. // listHzResource[k].AuthInfo = au
  3426. // listHzResource[k].IndustryVideo = video
  3427. // }
  3428. // }
  3429. //
  3430. // //合并产业关联的标的
  3431. // listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  3432. // if err != nil {
  3433. // br.Msg = "获取信息失败"
  3434. // br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3435. // return
  3436. // }
  3437. // //严选的产业只关联研选下面的标的
  3438. // var yxcondition string
  3439. // var yxPer []interface{}
  3440. // yxcondition = ` AND ag.article_id >= ?`
  3441. // yxPer = append(yxPer, utils.SummaryArticleId)
  3442. // listYxAticleSubject, err := models.GetSubjectArticleGroupManagementList(yxcondition, yxPer)
  3443. // if err != nil && err.Error() != utils.ErrNoRow() {
  3444. // br.Msg = "获取信息失败"
  3445. // br.ErrMsg = "获取研选报告关联的标的信息失败,GetSubjectArticleGroupManagementListErr:" + err.Error()
  3446. // return
  3447. // }
  3448. // mapYxSubject := make(map[int]int)
  3449. // for _, v := range listYxAticleSubject {
  3450. // mapYxSubject[v.IndustrialSubjectId] = v.IndustrialSubjectId
  3451. // }
  3452. //
  3453. // mapIndustrial := make(map[string]int)
  3454. // for _, v := range listSubjcet {
  3455. // for k2, v2 := range listYxResource {
  3456. // if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 && mapYxSubject[v.IndustrialSubjectId] > 0 {
  3457. // listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
  3458. // mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  3459. // }
  3460. // }
  3461. // for k2, v2 := range listHzResource {
  3462. // if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  3463. // listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
  3464. // mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  3465. // }
  3466. // }
  3467. // }
  3468. //}
  3469. resp := new(models.SearchReportAndResourceResp)
  3470. //if len(listYxResource) == 0 {
  3471. // listYxResource = make([]*models.IndustrialManagementHotResp, 0)
  3472. //}
  3473. //if len(listHzResource) == 0 {
  3474. // listHzResource =
  3475. // listHzResource = make([]*models.IndustrialManagement,0)
  3476. //}
  3477. if keyWord != "" {
  3478. keyWordItem := new(models.CygxUserSearchKeyWord)
  3479. keyWordItem.UserId = user.UserId
  3480. keyWordItem.KeyWord = keyWord
  3481. keyWordItem.PageType = "ReortSearch"
  3482. keyWordItem.CreateTime = time.Now()
  3483. go models.AddUserSearchKeyWord(keyWordItem)
  3484. //go services.AddUserSearchLog(user, keyWord, 5)
  3485. }
  3486. resp.ListHzResource = listHzResource
  3487. resp.ListYxResource = make([]*models.IndustrialManagementHotResp, 0)
  3488. resp.ListYxReport = make([]*models.ArticleCollectionResp, 0)
  3489. resp.ListHzReport = ListYxReport
  3490. br.Ret = 200
  3491. br.Success = true
  3492. br.Msg = "获取成功"
  3493. br.Data = resp
  3494. }
  3495. // @Title 产业报告公司列表
  3496. // @Description 获取产业报告公司列表接口
  3497. // @Param ChartPermissionId query int true "行业id"
  3498. // @Success 200 {object} models.IndustrialManagementList
  3499. // @router /home/stockName [get]
  3500. func (this *ReportController) StockNameList() {
  3501. br := new(models.BaseResponse).Init()
  3502. defer func() {
  3503. this.Data["json"] = br
  3504. this.ServeJSON()
  3505. }()
  3506. user := this.User
  3507. if user == nil {
  3508. br.Msg = "请重新登录"
  3509. br.Ret = 408
  3510. return
  3511. }
  3512. //uid := user.UserId
  3513. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  3514. list, err := models.GetSummaryArticle(chartPermissionId)
  3515. if err != nil {
  3516. br.Msg = "获取综述报告公司名称失败"
  3517. br.ErrMsg = "获取综述报告公司名称失败,Err:" + err.Error()
  3518. return
  3519. }
  3520. var respList []*models.SummaryArticleStock
  3521. for _, item := range list {
  3522. sliceSubjects := strings.Split(item.Stock, "/")
  3523. if len(sliceSubjects) > 0 {
  3524. for i, vSubject := range sliceSubjects {
  3525. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  3526. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  3527. subject := sliceXiahuaxian[0]
  3528. if i > 0 {
  3529. newItem := models.SummaryArticleStock{
  3530. Id: item.Id,
  3531. ArticleId: item.ArticleId,
  3532. Stock: subject,
  3533. }
  3534. respList = append(respList, &newItem)
  3535. } else {
  3536. item.Stock = subject
  3537. respList = append(respList, item)
  3538. }
  3539. }
  3540. }
  3541. //index := strings.Index(item.Stock, "(")
  3542. //item.Stock = item.Stock[:index]
  3543. //if strings.Contains(item.Stock, "-B"){
  3544. // item.Stock = strings.Replace(item.Stock, "-B", "", -1)
  3545. //}
  3546. //if strings.Contains(item.Stock, "-W"){
  3547. // item.Stock = strings.Replace(item.Stock, "-W", "", -1)
  3548. //}
  3549. }
  3550. resp := new(models.SummaryArticleStockResp)
  3551. resp.List = respList
  3552. br.Ret = 200
  3553. br.Success = true
  3554. br.Msg = "获取成功"
  3555. br.Data = resp
  3556. }
  3557. // @Title 文章留言接口
  3558. // @Description 文章留言接口
  3559. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  3560. // @Success 200 {object} models.TacticsListResp
  3561. // @router /commentAdd [post]
  3562. func (this *ReportController) CommentAdd() {
  3563. br := new(models.BaseResponse).Init()
  3564. defer func() {
  3565. this.Data["json"] = br
  3566. this.ServeJSON()
  3567. }()
  3568. user := this.User
  3569. if user == nil {
  3570. br.Msg = "请重新登录"
  3571. br.Ret = 408
  3572. return
  3573. }
  3574. var req models.AddCygxArticleCommentReq
  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. if req.ArticleId <= 0 {
  3582. br.Msg = "文章不存在"
  3583. br.ErrMsg = "文章不存在,文章ID错误"
  3584. return
  3585. }
  3586. if req.Content == "" {
  3587. br.Msg = "建议内容不可为空"
  3588. return
  3589. }
  3590. content := req.Content
  3591. itemToken, err := services.WxGetToken()
  3592. if err != nil {
  3593. br.Msg = "GetWxAccessToken Err:" + err.Error()
  3594. return
  3595. }
  3596. if itemToken.AccessToken == "" {
  3597. br.Msg = "accessToken is empty"
  3598. return
  3599. }
  3600. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  3601. if err != nil {
  3602. br.Msg = "内容校验失败!"
  3603. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  3604. return
  3605. }
  3606. if commerr.ErrCode != 0 {
  3607. br.Msg = "内容违规,请重新提交!"
  3608. br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  3609. return
  3610. }
  3611. articleId := req.ArticleId
  3612. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  3613. if articleInfo == nil {
  3614. br.Msg = "操作失败"
  3615. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3616. return
  3617. }
  3618. if errInfo != nil {
  3619. br.Msg = "操作失败"
  3620. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3621. return
  3622. }
  3623. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  3624. if err != nil {
  3625. br.Msg = "提交失败!"
  3626. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3627. return
  3628. }
  3629. if companyDetail == nil {
  3630. br.Msg = "提交失败!"
  3631. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  3632. return
  3633. }
  3634. item := models.CygxArticleComment{
  3635. UserId: user.UserId,
  3636. ArticleId: req.ArticleId,
  3637. CreateTime: time.Now(),
  3638. Mobile: user.Mobile,
  3639. Email: user.Email,
  3640. CompanyId: user.CompanyId,
  3641. CompanyName: companyDetail.CompanyName,
  3642. Content: content,
  3643. Title: articleInfo.Title,
  3644. }
  3645. msgId, err := models.AddArticleComment(&item)
  3646. if err != nil {
  3647. br.Msg = "提交失败"
  3648. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  3649. return
  3650. }
  3651. go services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
  3652. go services.SendCommentWxTemplateMsgByYxCategory(req, user, articleInfo, int(msgId)) // 发送用户留言提醒(研选公众号类目模版消息)
  3653. br.Ret = 200
  3654. br.Success = true
  3655. br.Msg = "提交成功"
  3656. }
  3657. // @Title 记录用户浏览音频回放接口
  3658. // @Description 记录用户浏览音频回放接口
  3659. // @Param request body models.ArticleIdReq true "type json string"
  3660. // @Success Ret=200 操作成功
  3661. // @router /voiceHistory/add [post]
  3662. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  3663. br := new(models.BaseResponse).Init()
  3664. defer func() {
  3665. this.Data["json"] = br
  3666. this.ServeJSON()
  3667. }()
  3668. user := this.User
  3669. if user == nil {
  3670. br.Msg = "请登录"
  3671. br.ErrMsg = "请登录,用户信息为空"
  3672. br.Ret = 408
  3673. return
  3674. }
  3675. uid := user.UserId
  3676. var req models.ArticleIdReq
  3677. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3678. if err != nil {
  3679. br.Msg = "参数解析异常!"
  3680. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3681. return
  3682. }
  3683. articleId := req.ArticleId
  3684. playSeconds := req.PlaySeconds
  3685. pageRouter := req.PageRouter
  3686. if pageRouter == "本周研究汇总" {
  3687. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  3688. if articleInfo == nil {
  3689. br.Msg = "操作失败"
  3690. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3691. return
  3692. }
  3693. if errInfo != nil {
  3694. br.Msg = "操作失败"
  3695. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3696. return
  3697. }
  3698. var sellerName string
  3699. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3700. if err != nil {
  3701. br.Msg = "报名失败!"
  3702. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3703. return
  3704. }
  3705. item := models.CygxResearchSummaryVoiceHistory{
  3706. ArticleId: articleId,
  3707. UserId: uid,
  3708. CreateTime: time.Now(),
  3709. Mobile: user.Mobile,
  3710. Email: user.Email,
  3711. CompanyId: user.CompanyId,
  3712. CompanyName: user.CompanyName,
  3713. RealName: user.RealName,
  3714. SellerName: sellerName,
  3715. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3716. ModifyTime: time.Now(),
  3717. }
  3718. if playSeconds != 0 {
  3719. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  3720. if err != nil {
  3721. br.Msg = "操作失败"
  3722. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3723. return
  3724. }
  3725. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3726. if err != nil {
  3727. br.Msg = "更新失败"
  3728. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3729. return
  3730. }
  3731. } else {
  3732. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  3733. if err != nil {
  3734. br.Msg = "操作失败"
  3735. br.ErrMsg = "操作失败,Err:" + err.Error()
  3736. return
  3737. }
  3738. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  3739. if err != nil {
  3740. br.Msg = "更新失败"
  3741. br.ErrMsg = "更新失败,Err:" + err.Error()
  3742. return
  3743. }
  3744. }
  3745. } else if pageRouter == "上周纪要汇总" {
  3746. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  3747. if articleInfo == nil {
  3748. br.Msg = "操作失败"
  3749. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3750. return
  3751. }
  3752. if errInfo != nil {
  3753. br.Msg = "操作失败"
  3754. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3755. return
  3756. }
  3757. var sellerName string
  3758. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3759. if err != nil {
  3760. br.Msg = "报名失败!"
  3761. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3762. return
  3763. }
  3764. item := models.CygxMinutesSummaryVoiceHistory{
  3765. ArticleId: articleId,
  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. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3775. ModifyTime: time.Now(),
  3776. }
  3777. if playSeconds != 0 {
  3778. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  3779. if err != nil {
  3780. br.Msg = "操作失败"
  3781. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3782. return
  3783. }
  3784. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3785. if err != nil {
  3786. br.Msg = "更新失败"
  3787. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3788. return
  3789. }
  3790. } else {
  3791. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  3792. if err != nil {
  3793. br.Msg = "操作失败"
  3794. br.ErrMsg = "操作失败,Err:" + err.Error()
  3795. return
  3796. }
  3797. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  3798. if err != nil {
  3799. br.Msg = "更新失败"
  3800. br.ErrMsg = "更新失败,Err:" + err.Error()
  3801. return
  3802. }
  3803. }
  3804. } else if pageRouter == "报告精选" {
  3805. articleInfo, errInfo := models.GetCygxReportSelectionInfoById(articleId)
  3806. if articleInfo == nil {
  3807. br.Msg = "操作失败"
  3808. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3809. return
  3810. }
  3811. if errInfo != nil {
  3812. br.Msg = "操作失败"
  3813. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3814. return
  3815. }
  3816. var sellerName string
  3817. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3818. if err != nil {
  3819. br.Msg = "报名失败!"
  3820. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3821. return
  3822. }
  3823. item := models.CygxReportSelectionVoiceHistory{
  3824. ArticleId: articleId,
  3825. UserId: uid,
  3826. CreateTime: time.Now(),
  3827. Mobile: user.Mobile,
  3828. Email: user.Email,
  3829. CompanyId: user.CompanyId,
  3830. CompanyName: user.CompanyName,
  3831. RealName: user.RealName,
  3832. SellerName: sellerName,
  3833. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3834. ModifyTime: time.Now(),
  3835. }
  3836. if playSeconds != 0 {
  3837. lastItem, err := models.GetLastCygxReportSelectionVoiceHistory(articleId, user.UserId)
  3838. if err != nil {
  3839. br.Msg = "操作失败"
  3840. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3841. return
  3842. }
  3843. err = models.UpdateLastCygxReportSelectionVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3844. if err != nil {
  3845. br.Msg = "更新失败"
  3846. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3847. return
  3848. }
  3849. } else {
  3850. err = models.AddCygxReportSelectionVoiceHistory(&item)
  3851. if err != nil {
  3852. br.Msg = "操作失败"
  3853. br.ErrMsg = "操作失败,Err:" + err.Error()
  3854. return
  3855. }
  3856. err = models.UpdateReportSelectionVoiceCounts(articleId)
  3857. if err != nil {
  3858. br.Msg = "更新失败"
  3859. br.ErrMsg = "更新失败,Err:" + err.Error()
  3860. return
  3861. }
  3862. }
  3863. }
  3864. br.Ret = 200
  3865. br.Success = true
  3866. br.Msg = "操作成功"
  3867. return
  3868. }
  3869. // @Title 周期行业报告分类列表接口
  3870. // @Description 周期获取行业报告分类列表接口
  3871. // @Success 200 {object} models.TradeReportMappingResp
  3872. // @router /zhouqi_tradeList [get]
  3873. func (this *ReportController) ZouqiTradeList() {
  3874. br := new(models.BaseResponse).Init()
  3875. defer func() {
  3876. this.Data["json"] = br
  3877. this.ServeJSON()
  3878. }()
  3879. user := this.User
  3880. if user == nil {
  3881. br.Msg = "请重新登录"
  3882. br.Ret = 408
  3883. return
  3884. }
  3885. listCategory, err := models.GetCygxZhouqiArticleMapFirst()
  3886. if err != nil {
  3887. br.Msg = "获取信息失败"
  3888. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3889. return
  3890. }
  3891. resp := new(models.TradeReportMappingResp)
  3892. var list []*models.TradeReportMapping
  3893. if len(listCategory) == 0 {
  3894. list = make([]*models.TradeReportMapping, 0)
  3895. } else {
  3896. for _, v := range listCategory {
  3897. item := new(models.TradeReportMapping)
  3898. item.CategoryId = v.CategoryId
  3899. item.MatchTypeName = v.MatchTypeName
  3900. item.UpdateTime = v.ArticleUpdateTime
  3901. //item.ListArticle = make([]*models.HomeArticle, 0)
  3902. list = append(list, item)
  3903. }
  3904. }
  3905. resp.List = list
  3906. br.Ret = 200
  3907. br.Success = true
  3908. br.Msg = "获取成功"
  3909. br.Data = resp
  3910. }
  3911. // @Title 周期根据行业分类获取行业文章列表
  3912. // @Description 周期根据行业分类获取行业文章列表接口
  3913. // @Param PageSize query int true "每页数据条数"
  3914. // @Param CurrentIndex query int true "当前页页码,从1开始"
  3915. // @Param CategoryId query int true "分类ID"
  3916. // @Success 200 {object} models.TacticsListResp
  3917. // @router /tactics/zhouqi_list [get]
  3918. func (this *ReportController) ZhouqiTacticsList() {
  3919. br := new(models.BaseResponse).Init()
  3920. defer func() {
  3921. this.Data["json"] = br
  3922. this.ServeJSON()
  3923. }()
  3924. user := this.User
  3925. if user == nil {
  3926. br.Msg = "请重新登录"
  3927. br.Ret = 408
  3928. return
  3929. }
  3930. //uid := user.UserId
  3931. pageSize, _ := this.GetInt("PageSize")
  3932. currentIndex, _ := this.GetInt("CurrentIndex")
  3933. categoryId, _ := this.GetInt("CategoryId")
  3934. var startSize int
  3935. if pageSize <= 0 {
  3936. pageSize = utils.PageSize20
  3937. }
  3938. if currentIndex <= 0 {
  3939. currentIndex = 1
  3940. }
  3941. startSize = paging.StartIndex(currentIndex, pageSize)
  3942. detail, err := models.GetCygxZhouqiArticleMapInfoById(categoryId)
  3943. if err != nil {
  3944. br.Msg = "获取信息失败"
  3945. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3946. return
  3947. }
  3948. var total int
  3949. //var err error
  3950. resp := new(models.TacticsListZhouqiResp)
  3951. page := paging.GetPaging(currentIndex, pageSize, total)
  3952. list := make([]*models.HomeArticle, 0)
  3953. listCategory, err := models.GetCygxZhouqiArticleMapByParentId(categoryId)
  3954. if err != nil {
  3955. br.Msg = "获取信息失败"
  3956. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  3957. return
  3958. }
  3959. var matchTypeName = []string{}
  3960. var seriesName = []string{}
  3961. for _, v := range listCategory {
  3962. if v.MatchTypeName != "" {
  3963. matchTypeName = append(matchTypeName, v.MatchTypeName)
  3964. }
  3965. if v.SeriesName != "" {
  3966. seriesName = append(seriesName, v.SeriesName)
  3967. }
  3968. }
  3969. var conditionOr string
  3970. if detail.FiccReportId != "" {
  3971. conditionOr = " OR art.report_id IN (" + detail.FiccReportId + ")" // 手动配置报告展示逻辑处理
  3972. }
  3973. if len(seriesName) > 0 {
  3974. conditionOr += " OR series_name IN ('" + strings.Join(seriesName, "','") + "') "
  3975. }
  3976. var condition string
  3977. //var pars []interface{}
  3978. //if len(seriesName) == 0 {
  3979. // condition = " AND field_name IN ('" + strings.Join(matchTypeName, "','") + "')"
  3980. //} else {
  3981. // condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') OR series_name IN ('" + strings.Join(seriesName, "','") + "') )"
  3982. //}
  3983. condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') " + conditionOr + " ) "
  3984. list, total, err = models.GetReportAndproductIndustrylListimgZhouqi(condition, startSize, pageSize)
  3985. if err != nil {
  3986. br.Msg = "获取信息失败"
  3987. br.Msg = "GetReportAndproductIndustrylListimgZhouqi,Err:" + err.Error()
  3988. return
  3989. }
  3990. listPublic, err := services.HandleArticleCategoryImg(list)
  3991. if err != nil {
  3992. br.Msg = "获取失败"
  3993. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  3994. return
  3995. }
  3996. var articleIds []int
  3997. for _, v := range listPublic {
  3998. if v.Resource == 1 {
  3999. articleIds = append(articleIds, v.ArticleId)
  4000. }
  4001. }
  4002. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  4003. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  4004. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  4005. resp.IsShowAbstract = true
  4006. listResp := make([]*models.HomeArticle, 0)
  4007. for _, v := range listPublic {
  4008. item := new(models.HomeArticle)
  4009. item.ArticleId = v.ArticleId
  4010. item.ReportId = v.ReportId
  4011. item.Title = v.Title
  4012. item.Annotation = v.Annotation
  4013. item.Abstract = v.Abstract
  4014. item.ImgUrlPc = v.ImgUrlPc
  4015. item.PublishDate = v.PublishDate
  4016. item.Resource = v.Resource
  4017. if v.Resource == 1 {
  4018. item.Pv = articleMapPv[v.ArticleId]
  4019. item.IsCollect = articleCollectMap[v.ArticleId]
  4020. item.CollectNum = articleCollectNumMap[v.ArticleId]
  4021. }
  4022. if v.ReportId > 0 {
  4023. item.Resource = 3
  4024. }
  4025. if v.Abstract != "" {
  4026. item.IsShowAbstract = resp.IsShowAbstract
  4027. }
  4028. listResp = append(listResp, item)
  4029. }
  4030. if len(listResp) == 0 {
  4031. listResp = make([]*models.HomeArticle, 0)
  4032. }
  4033. page = paging.GetPaging(currentIndex, pageSize, total)
  4034. resp.List = listResp
  4035. resp.Paging = page
  4036. br.Ret = 200
  4037. br.Success = true
  4038. br.Msg = "获取成功"
  4039. br.Data = resp
  4040. }
  4041. // @Title 获取用户的选择详情
  4042. // @Description 获取用户的选择详情接口
  4043. // @Success 200 {object} models.CygxXzsChooseSendResp
  4044. // @router /choose/detail [get]
  4045. func (this *ReportController) ChooseDetail() {
  4046. br := new(models.BaseResponse).Init()
  4047. defer func() {
  4048. this.Data["json"] = br
  4049. this.ServeJSON()
  4050. }()
  4051. user := this.User
  4052. if user == nil {
  4053. br.Msg = "请登录"
  4054. br.ErrMsg = "请登录,用户信息为空"
  4055. br.Ret = 408
  4056. return
  4057. }
  4058. resp := new(models.CygxXzsChooseSendResp)
  4059. var condition string
  4060. var pars []interface{}
  4061. mobile := user.Mobile
  4062. if mobile == "" {
  4063. br.Ret = 200
  4064. br.Success = true
  4065. br.Msg = "获取成功"
  4066. br.Data = resp
  4067. }
  4068. permissionId, err := models.GetCompanyPermissionId(user.CompanyId)
  4069. if err != nil {
  4070. br.Msg = "获取信息失败"
  4071. br.ErrMsg = "GetCompanyPermissionId,Err:" + err.Error()
  4072. return
  4073. }
  4074. if permissionId == "" {
  4075. br.Ret = 200
  4076. br.Success = true
  4077. br.Msg = "获取成功"
  4078. br.Data = resp
  4079. }
  4080. //mapIndustrial := make(map[int][]*models.IndustrialManagementRep)
  4081. mapIndustrialFollow := make(map[int][]*models.IndustrialManagementRep) // 重点关注的行业下的数组结构
  4082. mapIndustrialPush := make(map[int][]*models.IndustrialManagementRep) // 接受推送的行业下的数组结构
  4083. mapIndustrialUninterested := make(map[int][]*models.IndustrialManagementRep) // 不感兴趣的行业下的数组结构
  4084. //mapFllow := make(map[int]int)
  4085. checkListFollow := make(map[int]int) // 重点关注的ID
  4086. checkListPush := make(map[int]int) // 接受推送的ID
  4087. checkListUninterested := make(map[int]int) // 不感兴趣的ID
  4088. mapCategory := make(map[int]int)
  4089. //ampCheckList := make(map[int][]int, 0)
  4090. ampCheckListFollow := make(map[int][]int, 0) // 重点关注的ID
  4091. ampCheckListPush := make(map[int][]int, 0) // 接受推送的ID
  4092. ampCheckListUninterested := make(map[int][]int, 0) // 不感兴趣的ID
  4093. //permissionIdList := make([]string, 0)
  4094. fllowList, err := models.GetCygxIndustryFllowListByMobile(mobile)
  4095. if err != nil && err.Error() != utils.ErrNoRow() {
  4096. br.Msg = "获取信息失败"
  4097. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  4098. return
  4099. }
  4100. for _, v := range fllowList {
  4101. switch v.FollowType {
  4102. case 1:
  4103. checkListFollow[v.IndustrialManagementId] = v.IndustrialManagementId
  4104. case 0:
  4105. checkListPush[v.IndustrialManagementId] = v.IndustrialManagementId
  4106. case 3:
  4107. checkListUninterested[v.IndustrialManagementId] = v.IndustrialManagementId
  4108. }
  4109. }
  4110. industrialList, err := models.GetindustrialManagement()
  4111. if err != nil {
  4112. br.Msg = "获取信息失败"
  4113. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  4114. return
  4115. }
  4116. for _, v := range industrialList {
  4117. if v.ChartPermissionId == utils.ZHOU_QI_ID {
  4118. continue
  4119. }
  4120. v.IsFllow = true
  4121. if checkListFollow[v.IndustrialManagementId] > 0 {
  4122. //添加重点关注的行业赛道
  4123. ampCheckListFollow[v.ChartPermissionId] = append(ampCheckListFollow[v.ChartPermissionId], v.IndustrialManagementId)
  4124. mapIndustrialFollow[v.ChartPermissionId] = append(mapIndustrialFollow[v.ChartPermissionId], v)
  4125. } else if checkListUninterested[v.IndustrialManagementId] > 0 {
  4126. //添加不感兴趣的行业赛道
  4127. ampCheckListUninterested[v.ChartPermissionId] = append(ampCheckListUninterested[v.ChartPermissionId], v.IndustrialManagementId)
  4128. mapIndustrialUninterested[v.ChartPermissionId] = append(mapIndustrialUninterested[v.ChartPermissionId], v)
  4129. } else {
  4130. //添加接受推送的行业赛道
  4131. mapIndustrialPush[v.ChartPermissionId] = append(mapIndustrialPush[v.ChartPermissionId], v)
  4132. ampCheckListPush[v.ChartPermissionId] = append(ampCheckListPush[v.ChartPermissionId], v.IndustrialManagementId)
  4133. }
  4134. }
  4135. slicepermissionId := strings.Split(permissionId, ",")
  4136. permissionList, err := models.GetChartPermissionAllXzs(condition, pars)
  4137. if err != nil {
  4138. br.Msg = "获取信息失败"
  4139. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  4140. return
  4141. }
  4142. //策略固收的处理
  4143. categoryListFollow, err := models.GetCygxXzsChooseCategoryList(mobile)
  4144. if err != nil && err.Error() != utils.ErrNoRow() {
  4145. br.Msg = "获取信息失败"
  4146. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  4147. return
  4148. }
  4149. checkListCelueFollow := make(map[int]int) // 重点关注的ID
  4150. checkListCeluePush := make(map[int]int) // 接受推送的ID
  4151. checkListCelueUninterested := make(map[int]int) // 不感兴趣的ID
  4152. for _, v := range categoryListFollow {
  4153. //mapFllow[v.IndustrialManagementId] = v.IndustrialManagementId
  4154. switch v.FollowType {
  4155. case 1:
  4156. checkListCelueFollow[v.CategoryId] = v.CategoryId
  4157. case 0:
  4158. checkListCeluePush[v.CategoryId] = v.CategoryId
  4159. case 3:
  4160. checkListCelueUninterested[v.CategoryId] = v.CategoryId
  4161. }
  4162. }
  4163. for _, v := range categoryListFollow {
  4164. mapCategory[v.CategoryId] = v.CategoryId
  4165. }
  4166. celueList, err := models.GetReportMappingStrategyAllXzs()
  4167. if err != nil {
  4168. br.Msg = "获取信息失败"
  4169. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  4170. return
  4171. }
  4172. for _, v := range celueList {
  4173. v.IsFllow = true
  4174. if checkListCelueFollow[v.IndustrialManagementId] > 0 {
  4175. //添加重点关注的行业赛道
  4176. ampCheckListFollow[v.ChartPermissionId] = append(ampCheckListFollow[v.ChartPermissionId], v.IndustrialManagementId)
  4177. mapIndustrialFollow[v.ChartPermissionId] = append(mapIndustrialFollow[v.ChartPermissionId], v)
  4178. } else if checkListCelueUninterested[v.IndustrialManagementId] > 0 {
  4179. //添加不感兴趣的行业赛道
  4180. ampCheckListUninterested[v.ChartPermissionId] = append(ampCheckListUninterested[v.ChartPermissionId], v.IndustrialManagementId)
  4181. mapIndustrialUninterested[v.ChartPermissionId] = append(mapIndustrialUninterested[v.ChartPermissionId], v)
  4182. } else {
  4183. //添加接受推送的行业赛道
  4184. mapIndustrialPush[v.ChartPermissionId] = append(mapIndustrialPush[v.ChartPermissionId], v)
  4185. ampCheckListPush[v.ChartPermissionId] = append(ampCheckListPush[v.ChartPermissionId], v.IndustrialManagementId)
  4186. }
  4187. }
  4188. //策略、固收的处理 end
  4189. //周期的处理
  4190. zhouqiListFollow, err := models.GetCygxXzsChooseCategoryZhouqiList(mobile)
  4191. if err != nil && err.Error() != utils.ErrNoRow() {
  4192. br.Msg = "获取信息失败"
  4193. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  4194. return
  4195. }
  4196. checkListZhouqiFollow := make(map[int]int) // 重点关注的ID
  4197. checkListZhouqiPush := make(map[int]int) // 接受推送的ID
  4198. checkListZhouqiUninterested := make(map[int]int) // 不感兴趣的ID
  4199. for _, v := range zhouqiListFollow {
  4200. //mapFllow[v.IndustrialManagementId] = v.IndustrialManagementId
  4201. switch v.FollowType {
  4202. case 1:
  4203. checkListZhouqiFollow[v.CategoryId] = v.CategoryId
  4204. case 0:
  4205. checkListZhouqiPush[v.CategoryId] = v.CategoryId
  4206. case 3:
  4207. checkListZhouqiUninterested[v.CategoryId] = v.CategoryId
  4208. }
  4209. }
  4210. zhouqiList, err := models.GetCygxZhouqiArticleMapFirst()
  4211. if err != nil {
  4212. br.Msg = "获取信息失败"
  4213. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  4214. return
  4215. }
  4216. for _, vZhouqi := range zhouqiList {
  4217. v := new(models.IndustrialManagementRep)
  4218. v.IsFllow = true
  4219. v.IndustrialManagementId = vZhouqi.CategoryId
  4220. v.IndustryName = vZhouqi.MatchTypeName
  4221. v.ChartPermissionId = utils.ZHOU_QI_ID
  4222. if checkListZhouqiFollow[v.IndustrialManagementId] > 0 {
  4223. //添加重点关注的行业赛道
  4224. ampCheckListFollow[v.ChartPermissionId] = append(ampCheckListFollow[v.ChartPermissionId], v.IndustrialManagementId)
  4225. mapIndustrialFollow[v.ChartPermissionId] = append(mapIndustrialFollow[v.ChartPermissionId], v)
  4226. } else if checkListZhouqiUninterested[v.IndustrialManagementId] > 0 {
  4227. //添加不感兴趣的行业赛道
  4228. ampCheckListUninterested[v.ChartPermissionId] = append(ampCheckListUninterested[v.ChartPermissionId], v.IndustrialManagementId)
  4229. mapIndustrialUninterested[v.ChartPermissionId] = append(mapIndustrialUninterested[v.ChartPermissionId], v)
  4230. } else {
  4231. //添加接受推送的行业赛道
  4232. mapIndustrialPush[v.ChartPermissionId] = append(mapIndustrialPush[v.ChartPermissionId], v)
  4233. ampCheckListPush[v.ChartPermissionId] = append(ampCheckListPush[v.ChartPermissionId], v.IndustrialManagementId)
  4234. }
  4235. }
  4236. //周期的处理end
  4237. for k, v := range permissionList {
  4238. if len(mapIndustrialFollow[v.ChartPermissionId]) == 0 {
  4239. permissionList[k].ListFollow = make([]*models.IndustrialManagementRep, 0)
  4240. } else {
  4241. permissionList[k].ListFollow = mapIndustrialFollow[v.ChartPermissionId]
  4242. }
  4243. if len(mapIndustrialPush[v.ChartPermissionId]) == 0 {
  4244. permissionList[k].ListPush = make([]*models.IndustrialManagementRep, 0)
  4245. } else {
  4246. permissionList[k].ListPush = mapIndustrialPush[v.ChartPermissionId]
  4247. }
  4248. if len(mapIndustrialUninterested[v.ChartPermissionId]) == 0 {
  4249. permissionList[k].ListUninterested = make([]*models.IndustrialManagementRep, 0)
  4250. } else {
  4251. permissionList[k].ListUninterested = mapIndustrialUninterested[v.ChartPermissionId]
  4252. }
  4253. if len(ampCheckListFollow[v.ChartPermissionId]) == 0 {
  4254. permissionList[k].CheckListFollow = make([]int, 0)
  4255. } else {
  4256. permissionList[k].CheckListFollow = ampCheckListFollow[v.ChartPermissionId]
  4257. }
  4258. if len(ampCheckListPush[v.ChartPermissionId]) == 0 {
  4259. permissionList[k].CheckListPush = make([]int, 0)
  4260. } else {
  4261. permissionList[k].CheckListPush = ampCheckListPush[v.ChartPermissionId]
  4262. }
  4263. if len(ampCheckListUninterested[v.ChartPermissionId]) == 0 {
  4264. permissionList[k].CheckListUninterested = make([]int, 0)
  4265. } else {
  4266. permissionList[k].CheckListUninterested = ampCheckListUninterested[v.ChartPermissionId]
  4267. }
  4268. v.HasCheck = utils.InArrayByStr(slicepermissionId, strconv.Itoa(v.ChartPermissionId))
  4269. }
  4270. count, err := models.GetXzsChooseSendCountByMobile(mobile)
  4271. if err != nil {
  4272. br.Msg = "获取信息失败"
  4273. br.ErrMsg = "GetXzsChooseSendCountByMobile,Err:" + err.Error()
  4274. return
  4275. }
  4276. if count == 0 {
  4277. resp.IsObjective = 1
  4278. resp.IsSubjective = 1
  4279. } else {
  4280. detail, err := models.GetCygxXzsChooseSendByMobile(mobile)
  4281. if err != nil {
  4282. br.Msg = "获取信息失败"
  4283. br.ErrMsg = "GetCygxXzsChooseSendByMobile,Err:" + err.Error()
  4284. return
  4285. }
  4286. resp.IsObjective = detail.IsObjective
  4287. resp.IsSubjective = detail.IsSubjective
  4288. resp.IsRefuse = detail.IsRefuse
  4289. }
  4290. resp.IsPush = 1 - resp.IsRefuse
  4291. resp.List = permissionList
  4292. br.Ret = 200
  4293. br.Success = true
  4294. br.Msg = "获取成功"
  4295. br.Data = resp
  4296. }
  4297. // @Title 提交用户的选择关注的类型
  4298. // @Description 提交用户的选择关注的类型接口
  4299. // @Param request body models.SubmitChooseSendResp true "type json string"
  4300. // @Success 200 {object} models.CygxXzsChooseSendResp
  4301. // @router /choose/submit_follow_type [post]
  4302. func (this *ReportController) ChooseSubmitFollowType() {
  4303. br := new(models.BaseResponse).Init()
  4304. defer func() {
  4305. this.Data["json"] = br
  4306. this.ServeJSON()
  4307. }()
  4308. user := this.User
  4309. if user == nil {
  4310. br.Msg = "请登录"
  4311. br.ErrMsg = "请登录,用户信息为空"
  4312. br.Ret = 408
  4313. return
  4314. }
  4315. if user.Mobile == "" {
  4316. br.Msg = "提交失败!"
  4317. br.ErrMsg = "提交失败,手机号不能为空"
  4318. return
  4319. }
  4320. var req models.SubmitChooseSendFollowTypeResp
  4321. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  4322. if err != nil {
  4323. br.Msg = "参数解析异常!"
  4324. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  4325. return
  4326. }
  4327. listMap, err := models.GetCygxXzsChooseCategoryMapList()
  4328. if err != nil {
  4329. br.Msg = "操作失败!"
  4330. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  4331. return
  4332. }
  4333. mapReport := make(map[int]int)
  4334. for _, v := range listMap {
  4335. mapReport[v.CategoryId] = v.Id
  4336. }
  4337. followType := req.FollowType
  4338. listReq := req.List
  4339. var itemsFllow []*models.CygxIndustryFllow
  4340. var itemsCategory []*models.CygxXzsChooseCategory
  4341. var itemsZhouqi []*models.CygxXzsChooseCategoryZhouqi
  4342. var zhouqiIds []int
  4343. var celueIds []int
  4344. var industryIds []int
  4345. for _, vChartPermissionn := range listReq {
  4346. if vChartPermissionn.ChartPermissionName == utils.CE_LUE_NAME || vChartPermissionn.ChartPermissionName == utils.GU_SHOU_NAME {
  4347. //策略与固收
  4348. for _, v := range vChartPermissionn.CheckList {
  4349. item := new(models.CygxXzsChooseCategory)
  4350. categoryId := v
  4351. item.CategoryId = v
  4352. item.IdCygx = mapReport[categoryId]
  4353. item.UserId = user.UserId
  4354. item.Mobile = user.Mobile
  4355. item.Email = user.Email
  4356. item.CompanyId = user.CompanyId
  4357. item.CompanyName = user.CompanyName
  4358. item.RealName = user.RealName
  4359. item.FollowType = followType
  4360. item.CreateTime = time.Now()
  4361. item.ModifyTime = time.Now()
  4362. itemsCategory = append(itemsCategory, item)
  4363. celueIds = append(celueIds, v)
  4364. }
  4365. } else if vChartPermissionn.ChartPermissionName == utils.ZHOU_QI_NAME {
  4366. //周期
  4367. for _, v := range vChartPermissionn.CheckList {
  4368. item := new(models.CygxXzsChooseCategoryZhouqi)
  4369. item.CategoryId = v
  4370. item.UserId = user.UserId
  4371. item.Email = user.Email
  4372. item.Mobile = user.Mobile
  4373. item.RealName = user.RealName
  4374. item.CompanyId = user.CompanyId
  4375. item.CompanyName = user.CompanyName
  4376. item.FollowType = followType
  4377. item.CreateTime = time.Now()
  4378. item.ModifyTime = time.Now()
  4379. itemsZhouqi = append(itemsZhouqi, item)
  4380. zhouqiIds = append(zhouqiIds, v)
  4381. }
  4382. } else {
  4383. //正常带有产业的行业
  4384. for _, v := range vChartPermissionn.CheckList {
  4385. item := new(models.CygxIndustryFllow)
  4386. item.IndustrialManagementId = v
  4387. item.UserId = user.UserId
  4388. item.Mobile = user.Mobile
  4389. item.Email = user.Email
  4390. item.CompanyId = user.CompanyId
  4391. item.CompanyName = user.CompanyName
  4392. item.RealName = user.RealName
  4393. item.Type = 1
  4394. item.FollowType = followType
  4395. if followType == 3 {
  4396. item.FollowTypeOrder = -1
  4397. } else {
  4398. item.FollowTypeOrder = followType
  4399. }
  4400. item.CreateTime = time.Now()
  4401. item.ModifyTime = time.Now()
  4402. item.Source = 2
  4403. itemsFllow = append(itemsFllow, item)
  4404. industryIds = append(industryIds, v)
  4405. }
  4406. }
  4407. }
  4408. err = models.AddCygxXzsChooseSendFollow(user.Mobile, itemsFllow, itemsCategory, itemsZhouqi, industryIds, celueIds, zhouqiIds)
  4409. if err != nil {
  4410. br.Msg = "保存失败!"
  4411. br.ErrMsg = "保存失败!,Err:" + err.Error()
  4412. return
  4413. }
  4414. br.Ret = 200
  4415. br.Success = true
  4416. br.Msg = "保存成功"
  4417. }
  4418. // @Title 推送更新内容
  4419. // @Description 推送更新内容接口
  4420. // @Param request body models.SubmitChooseSendResp true "type json string"
  4421. // @Success 200 {object} models.CygxXzsChooseSendResp
  4422. // @router /choose/submit_push [post]
  4423. func (this *ReportController) ChooseSubmitPush() {
  4424. br := new(models.BaseResponse).Init()
  4425. defer func() {
  4426. this.Data["json"] = br
  4427. this.ServeJSON()
  4428. }()
  4429. user := this.User
  4430. if user == nil {
  4431. br.Msg = "请登录"
  4432. br.ErrMsg = "请登录,用户信息为空"
  4433. br.Ret = 408
  4434. return
  4435. }
  4436. if user.Mobile == "" {
  4437. br.Msg = "提交失败!"
  4438. br.ErrMsg = "提交失败,手机号不能为空"
  4439. return
  4440. }
  4441. var req models.SubmitChooseSendResp
  4442. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  4443. if err != nil {
  4444. br.Msg = "参数解析异常!"
  4445. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  4446. return
  4447. }
  4448. isPush := req.IsPush // 是否接受推送
  4449. //isRefuse := req.IsRefuse
  4450. isSubjective := req.IsSubjective
  4451. isObjective := req.IsObjective
  4452. req.IsRefuse = 1 - isPush // 是否拒绝推送,与是否接收推送进行取反(兼容老的数据库字段)
  4453. isRefuse := req.IsRefuse
  4454. if isRefuse == 0 && isSubjective == 0 && isObjective == 0 {
  4455. br.Msg = "请至少选择一项主客观内容"
  4456. return
  4457. }
  4458. //如果为1 则不做任何推送 ,主观客观默认改成0
  4459. if isRefuse == 1 {
  4460. isSubjective = 0
  4461. isObjective = 0
  4462. }
  4463. mobile := user.Mobile
  4464. item := new(models.CygxXzsChooseSend)
  4465. item.UserId = user.UserId
  4466. item.Mobile = user.Mobile
  4467. item.Email = user.Email
  4468. item.CompanyId = user.CompanyId
  4469. item.CompanyName = user.CompanyName
  4470. item.RealName = user.RealName
  4471. item.CreateTime = time.Now()
  4472. item.ModifyTime = time.Now()
  4473. item.IsRefuse = req.IsRefuse
  4474. item.IsSubjective = isSubjective
  4475. item.IsObjective = isObjective
  4476. count, err := models.GetXzsChooseSendCountByMobile(mobile)
  4477. if err != nil {
  4478. br.Msg = "获取信息失败"
  4479. br.ErrMsg = "GetXzsChooseSendCountByMobile,Err:" + err.Error()
  4480. return
  4481. }
  4482. //如果有记录就新增,没有记录就修改
  4483. if count == 0 {
  4484. err = models.AddCygxXzsChooseSendPush(item)
  4485. } else {
  4486. err = models.UpdateCygxXzsChooseSendPush(item)
  4487. }
  4488. if err != nil {
  4489. br.Msg = "保存失败!"
  4490. br.ErrMsg = "保存失败!,Err:" + err.Error()
  4491. return
  4492. }
  4493. br.Ret = 200
  4494. br.Success = true
  4495. br.Msg = "保存成功"
  4496. }