report.go 150 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660
  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. v.ResourceObj = "articlespecial"
  3028. } else {
  3029. if v.ReportId > 0 {
  3030. v.Resource = 3
  3031. v.ReportId = v.ReportId
  3032. v.ResourceObj = "articleficc"
  3033. } else {
  3034. v.Resource = 1
  3035. if v.ArticleTypeId > 0 {
  3036. v.ResourceObj = "articleyx"
  3037. } else {
  3038. v.ResourceObj = "articlevmp"
  3039. }
  3040. }
  3041. }
  3042. }
  3043. articleIds = strings.TrimRight(articleIds, ",")
  3044. silcearticleIds := strings.Split(articleIds, ",")
  3045. var parsindustrial []interface{}
  3046. parsindustrial = make([]interface{}, 0)
  3047. articleIdList := make([]string, 0)
  3048. for _, v := range silcearticleIds {
  3049. articleIdList = append(articleIdList, v)
  3050. }
  3051. conditionindustrial := ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` ) `
  3052. parsindustrial = append(parsindustrial, articleIdList)
  3053. industrialList, err := models.GetIndustrialListByarticleId(parsindustrial, conditionindustrial)
  3054. if err != nil {
  3055. return
  3056. }
  3057. industrialMap := make(map[int][]*models.IndustrialManagementResp)
  3058. if len(industrialList) > 0 {
  3059. for _, v := range industrialList {
  3060. item := new(models.IndustrialManagementResp)
  3061. //item.ArticleId = v.ArticleId
  3062. item.IndustrialManagementId = v.IndustrialManagementId
  3063. item.IndustryName = v.IndustryName
  3064. item.ChartPermissionId = v.ChartPermissionId
  3065. industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
  3066. }
  3067. }
  3068. //for k, v := range ListHzReport {
  3069. // if len(industrialMap[v.ArticleId]) > 0 {
  3070. // ListHzReport[k].List = industrialMap[v.ArticleId]
  3071. // } else {
  3072. // ListHzReport[k].List = make([]*models.IndustrialManagementResp, 0)
  3073. // }
  3074. // v.Pv = articleMapPv[v.ArticleId]
  3075. // v.CollectNum = articleCollectNumMap[v.ArticleId]
  3076. // v.IsCollect = articleCollectMap[v.ArticleId]
  3077. // if v.ReportId > 0 {
  3078. // v.Resource = 3
  3079. // }
  3080. //}
  3081. for k, v := range ListYxReport {
  3082. if len(industrialMap[v.ArticleId]) > 0 {
  3083. ListYxReport[k].List = industrialMap[v.ArticleId]
  3084. } else {
  3085. ListYxReport[k].List = make([]*models.IndustrialManagementResp, 0)
  3086. }
  3087. }
  3088. //获取文章关联的产业
  3089. if len(ListYxReport) == 0 {
  3090. ListYxReport = make([]*models.ArticleCollectionResp, 0)
  3091. }
  3092. //if len(ListHzReport) == 0 {
  3093. // ListHzReport = make([]*models.ArticleCollectionResp, 0)
  3094. //}
  3095. fllowList, err := models.GetUserFllowIndustrialList(uid)
  3096. if err != nil {
  3097. br.Msg = "获取失败"
  3098. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  3099. return
  3100. }
  3101. fllowMap := make(map[int]int)
  3102. if len(fllowList) > 0 {
  3103. for _, v := range fllowList {
  3104. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  3105. }
  3106. }
  3107. 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 + `%' ) `
  3108. listHzResource, err := models.GetSearchResourceListcondition(condition, 0, pageSize)
  3109. if err != nil {
  3110. br.Msg = "获取信息失败"
  3111. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3112. return
  3113. }
  3114. if len(listHzResource) > 0 {
  3115. listHzResource, err = services.HandleIndustryListHzAndYx(listHzResource, user, "Hz")
  3116. if err != nil {
  3117. br.Msg = "获取信息失败"
  3118. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3119. return
  3120. }
  3121. }
  3122. //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 + `%' ) `
  3123. //
  3124. //hotMapindustrial, e := services.IndustrialManagementHotMapGropuPermission()
  3125. //if e != nil {
  3126. // br.Msg = "获取信息失败"
  3127. // br.ErrMsg = "获取hot标签失败,IndustrialManagementHotMapGropuPermission ,Err:" + err.Error()
  3128. // return
  3129. //}
  3130. //listYxResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  3131. //if err != nil {
  3132. // br.Msg = "获取信息失败"
  3133. // br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  3134. // return
  3135. //}
  3136. ////合并产业关联的标的
  3137. //listSubjcet, err := models.GetThemeHeatSubjectList("")
  3138. //if err != nil {
  3139. // br.Msg = "获取信息失败"
  3140. // br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3141. // return
  3142. //}
  3143. //industrialIdArr := make([]int, 0)
  3144. //nowTime := time.Now().Local()
  3145. //threeMonBefore := nowTime.AddDate(0, -3, 0)
  3146. //mapHot := make(map[int]bool)
  3147. //
  3148. ////if themeType == 2 {
  3149. //mapHot, err = services.GetYanXuanIndustrialManagementIdHotMap(articleTypeIds)
  3150. //if err != nil {
  3151. // br.Msg = "获取信息失败"
  3152. // br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error()
  3153. // return
  3154. //}
  3155. //
  3156. ////conditionOrder := ` ORDER BY sum_num DESC `
  3157. ////listHot, err := models.GetThemeHeatList(user.UserId, condition, conditionOrder, 0, 3)
  3158. ////if err != nil {
  3159. //// br.Msg = "获取信息失败"
  3160. //// br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3161. //// return
  3162. ////}
  3163. //for k, _ := range mapHot {
  3164. // industrialIdArr = append(industrialIdArr, k)
  3165. //}
  3166. //orderSrt := "man.recommended_index DESC,update_time DESC"
  3167. //for k, v := range listHzResource {
  3168. // // 关联报告发布时间均在3个月内则标记New
  3169. // if v.MinReportTime != "" {
  3170. // t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3171. // if e != nil {
  3172. // err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3173. // return
  3174. // }
  3175. // if t.After(threeMonBefore) {
  3176. // listHzResource[k].IsNew = true
  3177. // }
  3178. // }
  3179. // //弘则资源包不展示hot标签
  3180. // //if mapHot[v.IndustryName] > 0 {
  3181. // // listHzResource[k].IsHot = true
  3182. // //}
  3183. // listHzResource[k].Source = 1
  3184. // if fllowMap[v.IndustrialManagementId] > 0 {
  3185. // listHzResource[k].IsFollw = true
  3186. // }
  3187. // v.IsHot = hotMapindustrial[v.IndustrialManagementId]
  3188. // industrialIdSlice := make([]int, 0)
  3189. // articleIdArr := make([]int, 0)
  3190. // industrialIdSlice = append(industrialIdSlice, v.IndustrialManagementId)
  3191. // listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdSlice)
  3192. // if err != nil && err.Error() != utils.ErrNoRow() {
  3193. // return
  3194. // }
  3195. // for _, v := range listUpdateTime {
  3196. // articleIdArr = append(articleIdArr, v.ArticleId)
  3197. // }
  3198. //
  3199. // if err != nil {
  3200. // return
  3201. // }
  3202. // mapHistroyArticleId := make(map[int]int)
  3203. //
  3204. // if user.UserId > 0 {
  3205. // listArticleHistory, e := models.GetUserToArticleHistory(user.UserId, articleIdArr)
  3206. // if e != nil && e.Error() != utils.ErrNoRow() {
  3207. // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  3208. // return
  3209. // }
  3210. // for _, v := range listArticleHistory {
  3211. // mapHistroyArticleId[v.ArticleId] = v.ArticleId
  3212. // }
  3213. // }
  3214. // condition2 := ` AND man.industry_name LIKE '%` + keyWord + `%' `
  3215. // list, err := models.GetIndustrialManagementAll(uid, condition2, orderSrt, 0, 20)
  3216. // if err != nil {
  3217. // br.Msg = "获取信息失败"
  3218. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3219. // return
  3220. // }
  3221. //
  3222. // mapUPdateTime := make(map[int]string)
  3223. // //获取这些产业下最新更新的文章
  3224. //
  3225. // //时间线的更新时间
  3226. // // maptimelineUPdateTime := make(map[int]string)
  3227. // listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
  3228. // if err != nil && err.Error() != utils.ErrNoRow() {
  3229. // br.Msg = "获取信息失败"
  3230. // br.ErrMsg = "GetTimeLineReportIndustrialPublishdateList,Err:" + err.Error()
  3231. // return
  3232. // }
  3233. // for _, v := range listtimelinePublishdate {
  3234. // if mapUPdateTime[v.IndustrialManagementId] != "" {
  3235. // if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3236. // mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
  3237. // }
  3238. // }
  3239. // }
  3240. //
  3241. // //mapHistroyArticleId := make(map[int]int)
  3242. //
  3243. // //if userId > 0 {
  3244. // // listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
  3245. // // if e != nil && e.Error() != utils.ErrNoRow() {
  3246. // // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  3247. // // return
  3248. // // }
  3249. // // for _, v := range listArticleHistory {
  3250. // // mapHistroyArticleId[v.ArticleId] = v.ArticleId
  3251. // // }
  3252. // //}
  3253. // var industrialIds string
  3254. // for _, id := range industrialIdArr {
  3255. // industrialIds += strconv.Itoa(id) + ","
  3256. // }
  3257. // industrialIds = strings.TrimRight(industrialIds, ",")
  3258. // articleList, err := models.GetReportIndustrialReadNumList(user.UserId, industrialIds, user.CreatedTime)
  3259. // if err != nil && err.Error() != utils.ErrNoRow() {
  3260. // br.Msg = "获取信息失败"
  3261. // br.ErrMsg = "GetReportIndustrialReadNumList,Err:" + err.Error()
  3262. // return
  3263. // }
  3264. // mapHistroyindustrialId := make(map[int]int)
  3265. // for _, v := range articleList {
  3266. // mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
  3267. // }
  3268. // //nowTime := time.Now().Local()
  3269. // //threeMonBefore := nowTime.AddDate(0, -3, 0)
  3270. //
  3271. // //查询用户今天是否看过时间线
  3272. // //haveMorningMeeting := false
  3273. // //var morningMeetingTime string
  3274. // recrodList, err := models.GetTimeLineRecordAllCount(user.UserId, time.Now().Format(utils.FormatDate))
  3275. // if err != nil {
  3276. // br.Msg = "获取信息失败"
  3277. // br.ErrMsg = "GetTimeLineRecordAllCount,Err:" + err.Error()
  3278. // return
  3279. // }
  3280. // var industrialManagementIdstr string
  3281. // industrialIdMap := make(map[string]time.Time)
  3282. // for _, v := range recrodList {
  3283. // industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
  3284. // if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
  3285. // if createTime.Before(v.CreateTime) {
  3286. // industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3287. // }
  3288. // } else {
  3289. // industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3290. // }
  3291. // }
  3292. //
  3293. // mmList, err := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
  3294. // if err != nil {
  3295. // return
  3296. // }
  3297. // morningMeetingTimeMap := make(map[int]time.Time)
  3298. // for _, v := range mmList {
  3299. // morningMeetingTimeMap[v.IndustryId] = v.CreateTime
  3300. // }
  3301. // timeLineRedMap := make(map[int]bool, 0)
  3302. //
  3303. // for _, industrialId := range industrialIdArr {
  3304. // if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
  3305. // if createTime.Before(morningMeetingTimeMap[industrialId]) {
  3306. // timeLineRedMap[industrialId] = true
  3307. // }
  3308. // }
  3309. // }
  3310. //
  3311. // for k, v := range list {
  3312. // list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3313. // if user.UserId > 0 {
  3314. // //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3315. // if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3316. // if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3317. // list[k].IsRed = true
  3318. // }
  3319. // }
  3320. // } else {
  3321. // if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3322. // list[k].IsRed = true
  3323. // }
  3324. // list[k].IsFollow = 0
  3325. // }
  3326. //
  3327. // list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3328. // if user.UserId > 0 {
  3329. // //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3330. // if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3331. // if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3332. // list[k].IsRed = true
  3333. // }
  3334. // }
  3335. // } else {
  3336. // if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3337. // list[k].IsRed = true
  3338. // }
  3339. // list[k].IsFollow = 0
  3340. // }
  3341. // }
  3342. //
  3343. // industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3344. //}
  3345. //
  3346. //for k, v := range listYxResource {
  3347. // // 关联报告发布时间均在3个月内则标记New
  3348. // if v.MinReportTime != "" {
  3349. // t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3350. // if e != nil {
  3351. // err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3352. // return
  3353. // }
  3354. // if t.After(threeMonBefore) {
  3355. // listYxResource[k].IsNew = true
  3356. // }
  3357. // }
  3358. // listYxResource[k].IsHot = mapHot[v.IndustrialManagementId]
  3359. // listYxResource[k].Source = 2
  3360. // if fllowMap[v.IndustrialManagementId] > 0 {
  3361. // listYxResource[k].IsFollw = true
  3362. // }
  3363. // v.IsHot = hotMapindustrial[v.IndustrialManagementId]
  3364. // industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3365. //}
  3366. //
  3367. //if len(industrialIdArr) > 0 {
  3368. // //查询产业视频
  3369. // industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
  3370. // // 获取默认图配置
  3371. // _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  3372. // if e != nil {
  3373. // br.Msg = "获取视频默认配置图失败"
  3374. // br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  3375. // return
  3376. // }
  3377. // videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialIdArr)
  3378. // if err != nil {
  3379. // br.Msg = "产业视频列表失败"
  3380. // br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
  3381. // return
  3382. // }
  3383. // for _, v := range videoList {
  3384. // tmp := &models.MicroVideoSimpleInfo{
  3385. // Id: v.VideoId,
  3386. // Title: "5min逻辑【" + v.IndustryName + "】解析",
  3387. // ResourceUrl: v.VideoUrl,
  3388. // BackgroundImg: v.ImgUrl,
  3389. // PlaySeconds: v.VideoDuration,
  3390. // DetailImgUrl: v.DetailImgUrl,
  3391. // ChartPermissionName: v.ChartPermissionName,
  3392. // ChartPermissionId: v.ChartPermissionId,
  3393. // }
  3394. // if tmp.BackgroundImg == "" {
  3395. // tmp.BackgroundImg = videoMap[v.ChartPermissionId]
  3396. // }
  3397. // industrialVideoMap[v.IndustryId] = tmp
  3398. // }
  3399. //
  3400. // //查询权限
  3401. // // 用户权限
  3402. // authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  3403. // if e != nil {
  3404. // br.Msg = "获取失败"
  3405. // br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  3406. // return
  3407. // }
  3408. //
  3409. // for k, v := range listHzResource {
  3410. // //展示产业视频
  3411. // if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
  3412. // au := new(models.UserPermissionAuthInfo)
  3413. // au.SellerName = authInfo.SellerName
  3414. // au.SellerMobile = authInfo.SellerMobile
  3415. // au.HasPermission = authInfo.HasPermission
  3416. // au.OperationMode = authInfo.OperationMode
  3417. // if au.HasPermission == 1 {
  3418. // // 非宏观权限进一步判断是否有权限
  3419. // if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  3420. // au.HasPermission = 2
  3421. // }
  3422. // }
  3423. // // 无权限的弹框提示
  3424. // if au.HasPermission != 1 {
  3425. // if au.OperationMode == services.UserPermissionOperationModeCall {
  3426. // au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  3427. // } else {
  3428. // au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  3429. // }
  3430. // video.ResourceUrl = ""
  3431. // }
  3432. // listHzResource[k].AuthInfo = au
  3433. // listHzResource[k].IndustryVideo = video
  3434. // }
  3435. // }
  3436. //
  3437. // //合并产业关联的标的
  3438. // listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  3439. // if err != nil {
  3440. // br.Msg = "获取信息失败"
  3441. // br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3442. // return
  3443. // }
  3444. // //严选的产业只关联研选下面的标的
  3445. // var yxcondition string
  3446. // var yxPer []interface{}
  3447. // yxcondition = ` AND ag.article_id >= ?`
  3448. // yxPer = append(yxPer, utils.SummaryArticleId)
  3449. // listYxAticleSubject, err := models.GetSubjectArticleGroupManagementList(yxcondition, yxPer)
  3450. // if err != nil && err.Error() != utils.ErrNoRow() {
  3451. // br.Msg = "获取信息失败"
  3452. // br.ErrMsg = "获取研选报告关联的标的信息失败,GetSubjectArticleGroupManagementListErr:" + err.Error()
  3453. // return
  3454. // }
  3455. // mapYxSubject := make(map[int]int)
  3456. // for _, v := range listYxAticleSubject {
  3457. // mapYxSubject[v.IndustrialSubjectId] = v.IndustrialSubjectId
  3458. // }
  3459. //
  3460. // mapIndustrial := make(map[string]int)
  3461. // for _, v := range listSubjcet {
  3462. // for k2, v2 := range listYxResource {
  3463. // if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 && mapYxSubject[v.IndustrialSubjectId] > 0 {
  3464. // listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
  3465. // mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  3466. // }
  3467. // }
  3468. // for k2, v2 := range listHzResource {
  3469. // if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  3470. // listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
  3471. // mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  3472. // }
  3473. // }
  3474. // }
  3475. //}
  3476. resp := new(models.SearchReportAndResourceResp)
  3477. //if len(listYxResource) == 0 {
  3478. // listYxResource = make([]*models.IndustrialManagementHotResp, 0)
  3479. //}
  3480. //if len(listHzResource) == 0 {
  3481. // listHzResource =
  3482. // listHzResource = make([]*models.IndustrialManagement,0)
  3483. //}
  3484. if keyWord != "" {
  3485. keyWordItem := new(models.CygxUserSearchKeyWord)
  3486. keyWordItem.UserId = user.UserId
  3487. keyWordItem.KeyWord = keyWord
  3488. keyWordItem.PageType = "ReortSearch"
  3489. keyWordItem.CreateTime = time.Now()
  3490. go models.AddUserSearchKeyWord(keyWordItem)
  3491. //go services.AddUserSearchLog(user, keyWord, 5)
  3492. }
  3493. resp.ListHzResource = listHzResource
  3494. resp.ListYxResource = make([]*models.IndustrialManagementHotResp, 0)
  3495. resp.ListYxReport = make([]*models.ArticleCollectionResp, 0)
  3496. resp.ListHzReport = ListYxReport
  3497. br.Ret = 200
  3498. br.Success = true
  3499. br.Msg = "获取成功"
  3500. br.Data = resp
  3501. }
  3502. // @Title 产业报告公司列表
  3503. // @Description 获取产业报告公司列表接口
  3504. // @Param ChartPermissionId query int true "行业id"
  3505. // @Success 200 {object} models.IndustrialManagementList
  3506. // @router /home/stockName [get]
  3507. func (this *ReportController) StockNameList() {
  3508. br := new(models.BaseResponse).Init()
  3509. defer func() {
  3510. this.Data["json"] = br
  3511. this.ServeJSON()
  3512. }()
  3513. user := this.User
  3514. if user == nil {
  3515. br.Msg = "请重新登录"
  3516. br.Ret = 408
  3517. return
  3518. }
  3519. //uid := user.UserId
  3520. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  3521. list, err := models.GetSummaryArticle(chartPermissionId)
  3522. if err != nil {
  3523. br.Msg = "获取综述报告公司名称失败"
  3524. br.ErrMsg = "获取综述报告公司名称失败,Err:" + err.Error()
  3525. return
  3526. }
  3527. var respList []*models.SummaryArticleStock
  3528. for _, item := range list {
  3529. sliceSubjects := strings.Split(item.Stock, "/")
  3530. if len(sliceSubjects) > 0 {
  3531. for i, vSubject := range sliceSubjects {
  3532. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  3533. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  3534. subject := sliceXiahuaxian[0]
  3535. if i > 0 {
  3536. newItem := models.SummaryArticleStock{
  3537. Id: item.Id,
  3538. ArticleId: item.ArticleId,
  3539. Stock: subject,
  3540. }
  3541. respList = append(respList, &newItem)
  3542. } else {
  3543. item.Stock = subject
  3544. respList = append(respList, item)
  3545. }
  3546. }
  3547. }
  3548. //index := strings.Index(item.Stock, "(")
  3549. //item.Stock = item.Stock[:index]
  3550. //if strings.Contains(item.Stock, "-B"){
  3551. // item.Stock = strings.Replace(item.Stock, "-B", "", -1)
  3552. //}
  3553. //if strings.Contains(item.Stock, "-W"){
  3554. // item.Stock = strings.Replace(item.Stock, "-W", "", -1)
  3555. //}
  3556. }
  3557. resp := new(models.SummaryArticleStockResp)
  3558. resp.List = respList
  3559. br.Ret = 200
  3560. br.Success = true
  3561. br.Msg = "获取成功"
  3562. br.Data = resp
  3563. }
  3564. // @Title 文章留言接口
  3565. // @Description 文章留言接口
  3566. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  3567. // @Success 200 {object} models.TacticsListResp
  3568. // @router /commentAdd [post]
  3569. func (this *ReportController) CommentAdd() {
  3570. br := new(models.BaseResponse).Init()
  3571. defer func() {
  3572. this.Data["json"] = br
  3573. this.ServeJSON()
  3574. }()
  3575. user := this.User
  3576. if user == nil {
  3577. br.Msg = "请重新登录"
  3578. br.Ret = 408
  3579. return
  3580. }
  3581. var req models.AddCygxArticleCommentReq
  3582. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3583. if err != nil {
  3584. br.Msg = "参数解析异常!"
  3585. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3586. return
  3587. }
  3588. if req.ArticleId <= 0 {
  3589. br.Msg = "文章不存在"
  3590. br.ErrMsg = "文章不存在,文章ID错误"
  3591. return
  3592. }
  3593. if req.Content == "" {
  3594. br.Msg = "建议内容不可为空"
  3595. return
  3596. }
  3597. content := req.Content
  3598. itemToken, err := services.WxGetToken()
  3599. if err != nil {
  3600. br.Msg = "GetWxAccessToken Err:" + err.Error()
  3601. return
  3602. }
  3603. if itemToken.AccessToken == "" {
  3604. br.Msg = "accessToken is empty"
  3605. return
  3606. }
  3607. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  3608. if err != nil {
  3609. br.Msg = "内容校验失败!"
  3610. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  3611. return
  3612. }
  3613. if commerr.ErrCode != 0 {
  3614. br.Msg = "内容违规,请重新提交!"
  3615. br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  3616. return
  3617. }
  3618. articleId := req.ArticleId
  3619. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  3620. if articleInfo == nil {
  3621. br.Msg = "操作失败"
  3622. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3623. return
  3624. }
  3625. if errInfo != nil {
  3626. br.Msg = "操作失败"
  3627. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3628. return
  3629. }
  3630. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  3631. if err != nil {
  3632. br.Msg = "提交失败!"
  3633. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3634. return
  3635. }
  3636. if companyDetail == nil {
  3637. br.Msg = "提交失败!"
  3638. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  3639. return
  3640. }
  3641. item := models.CygxArticleComment{
  3642. UserId: user.UserId,
  3643. ArticleId: req.ArticleId,
  3644. CreateTime: time.Now(),
  3645. Mobile: user.Mobile,
  3646. Email: user.Email,
  3647. CompanyId: user.CompanyId,
  3648. CompanyName: companyDetail.CompanyName,
  3649. Content: content,
  3650. Title: articleInfo.Title,
  3651. }
  3652. msgId, err := models.AddArticleComment(&item)
  3653. if err != nil {
  3654. br.Msg = "提交失败"
  3655. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  3656. return
  3657. }
  3658. go services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
  3659. go services.SendCommentWxTemplateMsgByYxCategory(req, user, articleInfo, int(msgId)) // 发送用户留言提醒(研选公众号类目模版消息)
  3660. br.Ret = 200
  3661. br.Success = true
  3662. br.Msg = "提交成功"
  3663. }
  3664. // @Title 记录用户浏览音频回放接口
  3665. // @Description 记录用户浏览音频回放接口
  3666. // @Param request body models.ArticleIdReq true "type json string"
  3667. // @Success Ret=200 操作成功
  3668. // @router /voiceHistory/add [post]
  3669. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  3670. br := new(models.BaseResponse).Init()
  3671. defer func() {
  3672. this.Data["json"] = br
  3673. this.ServeJSON()
  3674. }()
  3675. user := this.User
  3676. if user == nil {
  3677. br.Msg = "请登录"
  3678. br.ErrMsg = "请登录,用户信息为空"
  3679. br.Ret = 408
  3680. return
  3681. }
  3682. uid := user.UserId
  3683. var req models.ArticleIdReq
  3684. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3685. if err != nil {
  3686. br.Msg = "参数解析异常!"
  3687. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3688. return
  3689. }
  3690. articleId := req.ArticleId
  3691. playSeconds := req.PlaySeconds
  3692. pageRouter := req.PageRouter
  3693. if pageRouter == "本周研究汇总" {
  3694. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  3695. if articleInfo == nil {
  3696. br.Msg = "操作失败"
  3697. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3698. return
  3699. }
  3700. if errInfo != nil {
  3701. br.Msg = "操作失败"
  3702. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3703. return
  3704. }
  3705. var sellerName string
  3706. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3707. if err != nil {
  3708. br.Msg = "报名失败!"
  3709. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3710. return
  3711. }
  3712. item := models.CygxResearchSummaryVoiceHistory{
  3713. ArticleId: articleId,
  3714. UserId: uid,
  3715. CreateTime: time.Now(),
  3716. Mobile: user.Mobile,
  3717. Email: user.Email,
  3718. CompanyId: user.CompanyId,
  3719. CompanyName: user.CompanyName,
  3720. RealName: user.RealName,
  3721. SellerName: sellerName,
  3722. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3723. ModifyTime: time.Now(),
  3724. }
  3725. if playSeconds != 0 {
  3726. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  3727. if err != nil {
  3728. br.Msg = "操作失败"
  3729. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3730. return
  3731. }
  3732. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3733. if err != nil {
  3734. br.Msg = "更新失败"
  3735. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3736. return
  3737. }
  3738. } else {
  3739. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  3740. if err != nil {
  3741. br.Msg = "操作失败"
  3742. br.ErrMsg = "操作失败,Err:" + err.Error()
  3743. return
  3744. }
  3745. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  3746. if err != nil {
  3747. br.Msg = "更新失败"
  3748. br.ErrMsg = "更新失败,Err:" + err.Error()
  3749. return
  3750. }
  3751. }
  3752. } else if pageRouter == "上周纪要汇总" {
  3753. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  3754. if articleInfo == nil {
  3755. br.Msg = "操作失败"
  3756. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3757. return
  3758. }
  3759. if errInfo != nil {
  3760. br.Msg = "操作失败"
  3761. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3762. return
  3763. }
  3764. var sellerName string
  3765. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3766. if err != nil {
  3767. br.Msg = "报名失败!"
  3768. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3769. return
  3770. }
  3771. item := models.CygxMinutesSummaryVoiceHistory{
  3772. ArticleId: articleId,
  3773. UserId: uid,
  3774. CreateTime: time.Now(),
  3775. Mobile: user.Mobile,
  3776. Email: user.Email,
  3777. CompanyId: user.CompanyId,
  3778. CompanyName: user.CompanyName,
  3779. RealName: user.RealName,
  3780. SellerName: sellerName,
  3781. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3782. ModifyTime: time.Now(),
  3783. }
  3784. if playSeconds != 0 {
  3785. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  3786. if err != nil {
  3787. br.Msg = "操作失败"
  3788. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3789. return
  3790. }
  3791. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3792. if err != nil {
  3793. br.Msg = "更新失败"
  3794. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3795. return
  3796. }
  3797. } else {
  3798. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  3799. if err != nil {
  3800. br.Msg = "操作失败"
  3801. br.ErrMsg = "操作失败,Err:" + err.Error()
  3802. return
  3803. }
  3804. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  3805. if err != nil {
  3806. br.Msg = "更新失败"
  3807. br.ErrMsg = "更新失败,Err:" + err.Error()
  3808. return
  3809. }
  3810. }
  3811. } else if pageRouter == "报告精选" {
  3812. articleInfo, errInfo := models.GetCygxReportSelectionInfoById(articleId)
  3813. if articleInfo == nil {
  3814. br.Msg = "操作失败"
  3815. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3816. return
  3817. }
  3818. if errInfo != nil {
  3819. br.Msg = "操作失败"
  3820. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3821. return
  3822. }
  3823. var sellerName string
  3824. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3825. if err != nil {
  3826. br.Msg = "报名失败!"
  3827. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3828. return
  3829. }
  3830. item := models.CygxReportSelectionVoiceHistory{
  3831. ArticleId: articleId,
  3832. UserId: uid,
  3833. CreateTime: time.Now(),
  3834. Mobile: user.Mobile,
  3835. Email: user.Email,
  3836. CompanyId: user.CompanyId,
  3837. CompanyName: user.CompanyName,
  3838. RealName: user.RealName,
  3839. SellerName: sellerName,
  3840. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3841. ModifyTime: time.Now(),
  3842. }
  3843. if playSeconds != 0 {
  3844. lastItem, err := models.GetLastCygxReportSelectionVoiceHistory(articleId, user.UserId)
  3845. if err != nil {
  3846. br.Msg = "操作失败"
  3847. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3848. return
  3849. }
  3850. err = models.UpdateLastCygxReportSelectionVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3851. if err != nil {
  3852. br.Msg = "更新失败"
  3853. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3854. return
  3855. }
  3856. } else {
  3857. err = models.AddCygxReportSelectionVoiceHistory(&item)
  3858. if err != nil {
  3859. br.Msg = "操作失败"
  3860. br.ErrMsg = "操作失败,Err:" + err.Error()
  3861. return
  3862. }
  3863. err = models.UpdateReportSelectionVoiceCounts(articleId)
  3864. if err != nil {
  3865. br.Msg = "更新失败"
  3866. br.ErrMsg = "更新失败,Err:" + err.Error()
  3867. return
  3868. }
  3869. }
  3870. }
  3871. br.Ret = 200
  3872. br.Success = true
  3873. br.Msg = "操作成功"
  3874. return
  3875. }
  3876. // @Title 周期行业报告分类列表接口
  3877. // @Description 周期获取行业报告分类列表接口
  3878. // @Success 200 {object} models.TradeReportMappingResp
  3879. // @router /zhouqi_tradeList [get]
  3880. func (this *ReportController) ZouqiTradeList() {
  3881. br := new(models.BaseResponse).Init()
  3882. defer func() {
  3883. this.Data["json"] = br
  3884. this.ServeJSON()
  3885. }()
  3886. user := this.User
  3887. if user == nil {
  3888. br.Msg = "请重新登录"
  3889. br.Ret = 408
  3890. return
  3891. }
  3892. listCategory, err := models.GetCygxZhouqiArticleMapFirst()
  3893. if err != nil {
  3894. br.Msg = "获取信息失败"
  3895. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3896. return
  3897. }
  3898. resp := new(models.TradeReportMappingResp)
  3899. var list []*models.TradeReportMapping
  3900. if len(listCategory) == 0 {
  3901. list = make([]*models.TradeReportMapping, 0)
  3902. } else {
  3903. for _, v := range listCategory {
  3904. item := new(models.TradeReportMapping)
  3905. item.CategoryId = v.CategoryId
  3906. item.MatchTypeName = v.MatchTypeName
  3907. item.UpdateTime = v.ArticleUpdateTime
  3908. //item.ListArticle = make([]*models.HomeArticle, 0)
  3909. list = append(list, item)
  3910. }
  3911. }
  3912. resp.List = list
  3913. br.Ret = 200
  3914. br.Success = true
  3915. br.Msg = "获取成功"
  3916. br.Data = resp
  3917. }
  3918. // @Title 周期根据行业分类获取行业文章列表
  3919. // @Description 周期根据行业分类获取行业文章列表接口
  3920. // @Param PageSize query int true "每页数据条数"
  3921. // @Param CurrentIndex query int true "当前页页码,从1开始"
  3922. // @Param CategoryId query int true "分类ID"
  3923. // @Success 200 {object} models.TacticsListResp
  3924. // @router /tactics/zhouqi_list [get]
  3925. func (this *ReportController) ZhouqiTacticsList() {
  3926. br := new(models.BaseResponse).Init()
  3927. defer func() {
  3928. this.Data["json"] = br
  3929. this.ServeJSON()
  3930. }()
  3931. user := this.User
  3932. if user == nil {
  3933. br.Msg = "请重新登录"
  3934. br.Ret = 408
  3935. return
  3936. }
  3937. //uid := user.UserId
  3938. pageSize, _ := this.GetInt("PageSize")
  3939. currentIndex, _ := this.GetInt("CurrentIndex")
  3940. categoryId, _ := this.GetInt("CategoryId")
  3941. var startSize int
  3942. if pageSize <= 0 {
  3943. pageSize = utils.PageSize20
  3944. }
  3945. if currentIndex <= 0 {
  3946. currentIndex = 1
  3947. }
  3948. startSize = paging.StartIndex(currentIndex, pageSize)
  3949. detail, err := models.GetCygxZhouqiArticleMapInfoById(categoryId)
  3950. if err != nil {
  3951. br.Msg = "获取信息失败"
  3952. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3953. return
  3954. }
  3955. var total int
  3956. //var err error
  3957. resp := new(models.TacticsListZhouqiResp)
  3958. page := paging.GetPaging(currentIndex, pageSize, total)
  3959. list := make([]*models.HomeArticle, 0)
  3960. listCategory, err := models.GetCygxZhouqiArticleMapByParentId(categoryId)
  3961. if err != nil {
  3962. br.Msg = "获取信息失败"
  3963. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  3964. return
  3965. }
  3966. var matchTypeName = []string{}
  3967. var seriesName = []string{}
  3968. for _, v := range listCategory {
  3969. if v.MatchTypeName != "" {
  3970. matchTypeName = append(matchTypeName, v.MatchTypeName)
  3971. }
  3972. if v.SeriesName != "" {
  3973. seriesName = append(seriesName, v.SeriesName)
  3974. }
  3975. }
  3976. var conditionOr string
  3977. if detail.FiccReportId != "" {
  3978. conditionOr = " OR art.report_id IN (" + detail.FiccReportId + ")" // 手动配置报告展示逻辑处理
  3979. }
  3980. if len(seriesName) > 0 {
  3981. conditionOr += " OR series_name IN ('" + strings.Join(seriesName, "','") + "') "
  3982. }
  3983. var condition string
  3984. //var pars []interface{}
  3985. //if len(seriesName) == 0 {
  3986. // condition = " AND field_name IN ('" + strings.Join(matchTypeName, "','") + "')"
  3987. //} else {
  3988. // condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') OR series_name IN ('" + strings.Join(seriesName, "','") + "') )"
  3989. //}
  3990. condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') " + conditionOr + " ) "
  3991. list, total, err = models.GetReportAndproductIndustrylListimgZhouqi(condition, startSize, pageSize)
  3992. if err != nil {
  3993. br.Msg = "获取信息失败"
  3994. br.Msg = "GetReportAndproductIndustrylListimgZhouqi,Err:" + err.Error()
  3995. return
  3996. }
  3997. listPublic, err := services.HandleArticleCategoryImg(list)
  3998. if err != nil {
  3999. br.Msg = "获取失败"
  4000. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  4001. return
  4002. }
  4003. var articleIds []int
  4004. for _, v := range listPublic {
  4005. if v.Resource == 1 {
  4006. articleIds = append(articleIds, v.ArticleId)
  4007. }
  4008. }
  4009. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  4010. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  4011. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  4012. resp.IsShowAbstract = true
  4013. listResp := make([]*models.HomeArticle, 0)
  4014. for _, v := range listPublic {
  4015. item := new(models.HomeArticle)
  4016. item.ArticleId = v.ArticleId
  4017. item.ReportId = v.ReportId
  4018. item.Title = v.Title
  4019. item.Annotation = v.Annotation
  4020. item.Abstract = v.Abstract
  4021. item.ImgUrlPc = v.ImgUrlPc
  4022. item.PublishDate = v.PublishDate
  4023. item.Resource = v.Resource
  4024. if v.Resource == 1 {
  4025. item.Pv = articleMapPv[v.ArticleId]
  4026. item.IsCollect = articleCollectMap[v.ArticleId]
  4027. item.CollectNum = articleCollectNumMap[v.ArticleId]
  4028. }
  4029. if v.ReportId > 0 {
  4030. item.Resource = 3
  4031. }
  4032. if v.Abstract != "" {
  4033. item.IsShowAbstract = resp.IsShowAbstract
  4034. }
  4035. listResp = append(listResp, item)
  4036. }
  4037. if len(listResp) == 0 {
  4038. listResp = make([]*models.HomeArticle, 0)
  4039. }
  4040. page = paging.GetPaging(currentIndex, pageSize, total)
  4041. resp.List = listResp
  4042. resp.Paging = page
  4043. br.Ret = 200
  4044. br.Success = true
  4045. br.Msg = "获取成功"
  4046. br.Data = resp
  4047. }
  4048. // @Title 获取用户的选择详情
  4049. // @Description 获取用户的选择详情接口
  4050. // @Success 200 {object} models.CygxXzsChooseSendResp
  4051. // @router /choose/detail [get]
  4052. func (this *ReportController) ChooseDetail() {
  4053. br := new(models.BaseResponse).Init()
  4054. defer func() {
  4055. this.Data["json"] = br
  4056. this.ServeJSON()
  4057. }()
  4058. user := this.User
  4059. if user == nil {
  4060. br.Msg = "请登录"
  4061. br.ErrMsg = "请登录,用户信息为空"
  4062. br.Ret = 408
  4063. return
  4064. }
  4065. resp := new(models.CygxXzsChooseSendResp)
  4066. var condition string
  4067. var pars []interface{}
  4068. mobile := user.Mobile
  4069. if mobile == "" {
  4070. br.Ret = 200
  4071. br.Success = true
  4072. br.Msg = "获取成功"
  4073. br.Data = resp
  4074. }
  4075. permissionId, err := models.GetCompanyPermissionId(user.CompanyId)
  4076. if err != nil {
  4077. br.Msg = "获取信息失败"
  4078. br.ErrMsg = "GetCompanyPermissionId,Err:" + err.Error()
  4079. return
  4080. }
  4081. if permissionId == "" {
  4082. br.Ret = 200
  4083. br.Success = true
  4084. br.Msg = "获取成功"
  4085. br.Data = resp
  4086. }
  4087. //mapIndustrial := make(map[int][]*models.IndustrialManagementRep)
  4088. mapIndustrialFollow := make(map[int][]*models.IndustrialManagementRep) // 重点关注的行业下的数组结构
  4089. mapIndustrialPush := make(map[int][]*models.IndustrialManagementRep) // 接受推送的行业下的数组结构
  4090. mapIndustrialUninterested := make(map[int][]*models.IndustrialManagementRep) // 不感兴趣的行业下的数组结构
  4091. //mapFllow := make(map[int]int)
  4092. checkListFollow := make(map[int]int) // 重点关注的ID
  4093. checkListPush := make(map[int]int) // 接受推送的ID
  4094. checkListUninterested := make(map[int]int) // 不感兴趣的ID
  4095. mapCategory := make(map[int]int)
  4096. //ampCheckList := make(map[int][]int, 0)
  4097. ampCheckListFollow := make(map[int][]int, 0) // 重点关注的ID
  4098. ampCheckListPush := make(map[int][]int, 0) // 接受推送的ID
  4099. ampCheckListUninterested := make(map[int][]int, 0) // 不感兴趣的ID
  4100. //permissionIdList := make([]string, 0)
  4101. fllowList, err := models.GetCygxIndustryFllowListByMobile(mobile)
  4102. if err != nil && err.Error() != utils.ErrNoRow() {
  4103. br.Msg = "获取信息失败"
  4104. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  4105. return
  4106. }
  4107. for _, v := range fllowList {
  4108. switch v.FollowType {
  4109. case 1:
  4110. checkListFollow[v.IndustrialManagementId] = v.IndustrialManagementId
  4111. case 0:
  4112. checkListPush[v.IndustrialManagementId] = v.IndustrialManagementId
  4113. case 3:
  4114. checkListUninterested[v.IndustrialManagementId] = v.IndustrialManagementId
  4115. }
  4116. }
  4117. industrialList, err := models.GetindustrialManagement()
  4118. if err != nil {
  4119. br.Msg = "获取信息失败"
  4120. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  4121. return
  4122. }
  4123. for _, v := range industrialList {
  4124. if v.ChartPermissionId == utils.ZHOU_QI_ID {
  4125. continue
  4126. }
  4127. v.IsFllow = true
  4128. if checkListFollow[v.IndustrialManagementId] > 0 {
  4129. //添加重点关注的行业赛道
  4130. ampCheckListFollow[v.ChartPermissionId] = append(ampCheckListFollow[v.ChartPermissionId], v.IndustrialManagementId)
  4131. mapIndustrialFollow[v.ChartPermissionId] = append(mapIndustrialFollow[v.ChartPermissionId], v)
  4132. } else if checkListUninterested[v.IndustrialManagementId] > 0 {
  4133. //添加不感兴趣的行业赛道
  4134. ampCheckListUninterested[v.ChartPermissionId] = append(ampCheckListUninterested[v.ChartPermissionId], v.IndustrialManagementId)
  4135. mapIndustrialUninterested[v.ChartPermissionId] = append(mapIndustrialUninterested[v.ChartPermissionId], v)
  4136. } else {
  4137. //添加接受推送的行业赛道
  4138. mapIndustrialPush[v.ChartPermissionId] = append(mapIndustrialPush[v.ChartPermissionId], v)
  4139. ampCheckListPush[v.ChartPermissionId] = append(ampCheckListPush[v.ChartPermissionId], v.IndustrialManagementId)
  4140. }
  4141. }
  4142. slicepermissionId := strings.Split(permissionId, ",")
  4143. permissionList, err := models.GetChartPermissionAllXzs(condition, pars)
  4144. if err != nil {
  4145. br.Msg = "获取信息失败"
  4146. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  4147. return
  4148. }
  4149. //策略固收的处理
  4150. categoryListFollow, err := models.GetCygxXzsChooseCategoryList(mobile)
  4151. if err != nil && err.Error() != utils.ErrNoRow() {
  4152. br.Msg = "获取信息失败"
  4153. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  4154. return
  4155. }
  4156. checkListCelueFollow := make(map[int]int) // 重点关注的ID
  4157. checkListCeluePush := make(map[int]int) // 接受推送的ID
  4158. checkListCelueUninterested := make(map[int]int) // 不感兴趣的ID
  4159. for _, v := range categoryListFollow {
  4160. //mapFllow[v.IndustrialManagementId] = v.IndustrialManagementId
  4161. switch v.FollowType {
  4162. case 1:
  4163. checkListCelueFollow[v.CategoryId] = v.CategoryId
  4164. case 0:
  4165. checkListCeluePush[v.CategoryId] = v.CategoryId
  4166. case 3:
  4167. checkListCelueUninterested[v.CategoryId] = v.CategoryId
  4168. }
  4169. }
  4170. for _, v := range categoryListFollow {
  4171. mapCategory[v.CategoryId] = v.CategoryId
  4172. }
  4173. celueList, err := models.GetReportMappingStrategyAllXzs()
  4174. if err != nil {
  4175. br.Msg = "获取信息失败"
  4176. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  4177. return
  4178. }
  4179. for _, v := range celueList {
  4180. v.IsFllow = true
  4181. if checkListCelueFollow[v.IndustrialManagementId] > 0 {
  4182. //添加重点关注的行业赛道
  4183. ampCheckListFollow[v.ChartPermissionId] = append(ampCheckListFollow[v.ChartPermissionId], v.IndustrialManagementId)
  4184. mapIndustrialFollow[v.ChartPermissionId] = append(mapIndustrialFollow[v.ChartPermissionId], v)
  4185. } else if checkListCelueUninterested[v.IndustrialManagementId] > 0 {
  4186. //添加不感兴趣的行业赛道
  4187. ampCheckListUninterested[v.ChartPermissionId] = append(ampCheckListUninterested[v.ChartPermissionId], v.IndustrialManagementId)
  4188. mapIndustrialUninterested[v.ChartPermissionId] = append(mapIndustrialUninterested[v.ChartPermissionId], v)
  4189. } else {
  4190. //添加接受推送的行业赛道
  4191. mapIndustrialPush[v.ChartPermissionId] = append(mapIndustrialPush[v.ChartPermissionId], v)
  4192. ampCheckListPush[v.ChartPermissionId] = append(ampCheckListPush[v.ChartPermissionId], v.IndustrialManagementId)
  4193. }
  4194. }
  4195. //策略、固收的处理 end
  4196. //周期的处理
  4197. zhouqiListFollow, err := models.GetCygxXzsChooseCategoryZhouqiList(mobile)
  4198. if err != nil && err.Error() != utils.ErrNoRow() {
  4199. br.Msg = "获取信息失败"
  4200. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  4201. return
  4202. }
  4203. checkListZhouqiFollow := make(map[int]int) // 重点关注的ID
  4204. checkListZhouqiPush := make(map[int]int) // 接受推送的ID
  4205. checkListZhouqiUninterested := make(map[int]int) // 不感兴趣的ID
  4206. for _, v := range zhouqiListFollow {
  4207. //mapFllow[v.IndustrialManagementId] = v.IndustrialManagementId
  4208. switch v.FollowType {
  4209. case 1:
  4210. checkListZhouqiFollow[v.CategoryId] = v.CategoryId
  4211. case 0:
  4212. checkListZhouqiPush[v.CategoryId] = v.CategoryId
  4213. case 3:
  4214. checkListZhouqiUninterested[v.CategoryId] = v.CategoryId
  4215. }
  4216. }
  4217. zhouqiList, err := models.GetCygxZhouqiArticleMapFirst()
  4218. if err != nil {
  4219. br.Msg = "获取信息失败"
  4220. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  4221. return
  4222. }
  4223. for _, vZhouqi := range zhouqiList {
  4224. v := new(models.IndustrialManagementRep)
  4225. v.IsFllow = true
  4226. v.IndustrialManagementId = vZhouqi.CategoryId
  4227. v.IndustryName = vZhouqi.MatchTypeName
  4228. v.ChartPermissionId = utils.ZHOU_QI_ID
  4229. if checkListZhouqiFollow[v.IndustrialManagementId] > 0 {
  4230. //添加重点关注的行业赛道
  4231. ampCheckListFollow[v.ChartPermissionId] = append(ampCheckListFollow[v.ChartPermissionId], v.IndustrialManagementId)
  4232. mapIndustrialFollow[v.ChartPermissionId] = append(mapIndustrialFollow[v.ChartPermissionId], v)
  4233. } else if checkListZhouqiUninterested[v.IndustrialManagementId] > 0 {
  4234. //添加不感兴趣的行业赛道
  4235. ampCheckListUninterested[v.ChartPermissionId] = append(ampCheckListUninterested[v.ChartPermissionId], v.IndustrialManagementId)
  4236. mapIndustrialUninterested[v.ChartPermissionId] = append(mapIndustrialUninterested[v.ChartPermissionId], v)
  4237. } else {
  4238. //添加接受推送的行业赛道
  4239. mapIndustrialPush[v.ChartPermissionId] = append(mapIndustrialPush[v.ChartPermissionId], v)
  4240. ampCheckListPush[v.ChartPermissionId] = append(ampCheckListPush[v.ChartPermissionId], v.IndustrialManagementId)
  4241. }
  4242. }
  4243. //周期的处理end
  4244. for k, v := range permissionList {
  4245. if len(mapIndustrialFollow[v.ChartPermissionId]) == 0 {
  4246. permissionList[k].ListFollow = make([]*models.IndustrialManagementRep, 0)
  4247. } else {
  4248. permissionList[k].ListFollow = mapIndustrialFollow[v.ChartPermissionId]
  4249. }
  4250. if len(mapIndustrialPush[v.ChartPermissionId]) == 0 {
  4251. permissionList[k].ListPush = make([]*models.IndustrialManagementRep, 0)
  4252. } else {
  4253. permissionList[k].ListPush = mapIndustrialPush[v.ChartPermissionId]
  4254. }
  4255. if len(mapIndustrialUninterested[v.ChartPermissionId]) == 0 {
  4256. permissionList[k].ListUninterested = make([]*models.IndustrialManagementRep, 0)
  4257. } else {
  4258. permissionList[k].ListUninterested = mapIndustrialUninterested[v.ChartPermissionId]
  4259. }
  4260. if len(ampCheckListFollow[v.ChartPermissionId]) == 0 {
  4261. permissionList[k].CheckListFollow = make([]int, 0)
  4262. } else {
  4263. permissionList[k].CheckListFollow = ampCheckListFollow[v.ChartPermissionId]
  4264. }
  4265. if len(ampCheckListPush[v.ChartPermissionId]) == 0 {
  4266. permissionList[k].CheckListPush = make([]int, 0)
  4267. } else {
  4268. permissionList[k].CheckListPush = ampCheckListPush[v.ChartPermissionId]
  4269. }
  4270. if len(ampCheckListUninterested[v.ChartPermissionId]) == 0 {
  4271. permissionList[k].CheckListUninterested = make([]int, 0)
  4272. } else {
  4273. permissionList[k].CheckListUninterested = ampCheckListUninterested[v.ChartPermissionId]
  4274. }
  4275. v.HasCheck = utils.InArrayByStr(slicepermissionId, strconv.Itoa(v.ChartPermissionId))
  4276. }
  4277. count, err := models.GetXzsChooseSendCountByMobile(mobile)
  4278. if err != nil {
  4279. br.Msg = "获取信息失败"
  4280. br.ErrMsg = "GetXzsChooseSendCountByMobile,Err:" + err.Error()
  4281. return
  4282. }
  4283. if count == 0 {
  4284. resp.IsObjective = 1
  4285. resp.IsSubjective = 1
  4286. } else {
  4287. detail, err := models.GetCygxXzsChooseSendByMobile(mobile)
  4288. if err != nil {
  4289. br.Msg = "获取信息失败"
  4290. br.ErrMsg = "GetCygxXzsChooseSendByMobile,Err:" + err.Error()
  4291. return
  4292. }
  4293. resp.IsObjective = detail.IsObjective
  4294. resp.IsSubjective = detail.IsSubjective
  4295. resp.IsRefuse = detail.IsRefuse
  4296. }
  4297. resp.IsPush = 1 - resp.IsRefuse
  4298. resp.List = permissionList
  4299. br.Ret = 200
  4300. br.Success = true
  4301. br.Msg = "获取成功"
  4302. br.Data = resp
  4303. }
  4304. // @Title 提交用户的选择关注的类型
  4305. // @Description 提交用户的选择关注的类型接口
  4306. // @Param request body models.SubmitChooseSendResp true "type json string"
  4307. // @Success 200 {object} models.CygxXzsChooseSendResp
  4308. // @router /choose/submit_follow_type [post]
  4309. func (this *ReportController) ChooseSubmitFollowType() {
  4310. br := new(models.BaseResponse).Init()
  4311. defer func() {
  4312. this.Data["json"] = br
  4313. this.ServeJSON()
  4314. }()
  4315. user := this.User
  4316. if user == nil {
  4317. br.Msg = "请登录"
  4318. br.ErrMsg = "请登录,用户信息为空"
  4319. br.Ret = 408
  4320. return
  4321. }
  4322. if user.Mobile == "" {
  4323. br.Msg = "提交失败!"
  4324. br.ErrMsg = "提交失败,手机号不能为空"
  4325. return
  4326. }
  4327. var req models.SubmitChooseSendFollowTypeResp
  4328. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  4329. if err != nil {
  4330. br.Msg = "参数解析异常!"
  4331. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  4332. return
  4333. }
  4334. listMap, err := models.GetCygxXzsChooseCategoryMapList()
  4335. if err != nil {
  4336. br.Msg = "操作失败!"
  4337. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  4338. return
  4339. }
  4340. mapReport := make(map[int]int)
  4341. for _, v := range listMap {
  4342. mapReport[v.CategoryId] = v.Id
  4343. }
  4344. followType := req.FollowType
  4345. listReq := req.List
  4346. var itemsFllow []*models.CygxIndustryFllow
  4347. var itemsCategory []*models.CygxXzsChooseCategory
  4348. var itemsZhouqi []*models.CygxXzsChooseCategoryZhouqi
  4349. var zhouqiIds []int
  4350. var celueIds []int
  4351. var industryIds []int
  4352. for _, vChartPermissionn := range listReq {
  4353. if vChartPermissionn.ChartPermissionName == utils.CE_LUE_NAME || vChartPermissionn.ChartPermissionName == utils.GU_SHOU_NAME {
  4354. //策略与固收
  4355. for _, v := range vChartPermissionn.CheckList {
  4356. item := new(models.CygxXzsChooseCategory)
  4357. categoryId := v
  4358. item.CategoryId = v
  4359. item.IdCygx = mapReport[categoryId]
  4360. item.UserId = user.UserId
  4361. item.Mobile = user.Mobile
  4362. item.Email = user.Email
  4363. item.CompanyId = user.CompanyId
  4364. item.CompanyName = user.CompanyName
  4365. item.RealName = user.RealName
  4366. item.FollowType = followType
  4367. item.CreateTime = time.Now()
  4368. item.ModifyTime = time.Now()
  4369. itemsCategory = append(itemsCategory, item)
  4370. celueIds = append(celueIds, v)
  4371. }
  4372. } else if vChartPermissionn.ChartPermissionName == utils.ZHOU_QI_NAME {
  4373. //周期
  4374. for _, v := range vChartPermissionn.CheckList {
  4375. item := new(models.CygxXzsChooseCategoryZhouqi)
  4376. item.CategoryId = v
  4377. item.UserId = user.UserId
  4378. item.Email = user.Email
  4379. item.Mobile = user.Mobile
  4380. item.RealName = user.RealName
  4381. item.CompanyId = user.CompanyId
  4382. item.CompanyName = user.CompanyName
  4383. item.FollowType = followType
  4384. item.CreateTime = time.Now()
  4385. item.ModifyTime = time.Now()
  4386. itemsZhouqi = append(itemsZhouqi, item)
  4387. zhouqiIds = append(zhouqiIds, v)
  4388. }
  4389. } else {
  4390. //正常带有产业的行业
  4391. for _, v := range vChartPermissionn.CheckList {
  4392. item := new(models.CygxIndustryFllow)
  4393. item.IndustrialManagementId = v
  4394. item.UserId = user.UserId
  4395. item.Mobile = user.Mobile
  4396. item.Email = user.Email
  4397. item.CompanyId = user.CompanyId
  4398. item.CompanyName = user.CompanyName
  4399. item.RealName = user.RealName
  4400. item.Type = 1
  4401. item.FollowType = followType
  4402. if followType == 3 {
  4403. item.FollowTypeOrder = -1
  4404. } else {
  4405. item.FollowTypeOrder = followType
  4406. }
  4407. item.CreateTime = time.Now()
  4408. item.ModifyTime = time.Now()
  4409. item.Source = 2
  4410. itemsFllow = append(itemsFllow, item)
  4411. industryIds = append(industryIds, v)
  4412. }
  4413. }
  4414. }
  4415. err = models.AddCygxXzsChooseSendFollow(user.Mobile, itemsFllow, itemsCategory, itemsZhouqi, industryIds, celueIds, zhouqiIds)
  4416. if err != nil {
  4417. br.Msg = "保存失败!"
  4418. br.ErrMsg = "保存失败!,Err:" + err.Error()
  4419. return
  4420. }
  4421. br.Ret = 200
  4422. br.Success = true
  4423. br.Msg = "保存成功"
  4424. }
  4425. // @Title 推送更新内容
  4426. // @Description 推送更新内容接口
  4427. // @Param request body models.SubmitChooseSendResp true "type json string"
  4428. // @Success 200 {object} models.CygxXzsChooseSendResp
  4429. // @router /choose/submit_push [post]
  4430. func (this *ReportController) ChooseSubmitPush() {
  4431. br := new(models.BaseResponse).Init()
  4432. defer func() {
  4433. this.Data["json"] = br
  4434. this.ServeJSON()
  4435. }()
  4436. user := this.User
  4437. if user == nil {
  4438. br.Msg = "请登录"
  4439. br.ErrMsg = "请登录,用户信息为空"
  4440. br.Ret = 408
  4441. return
  4442. }
  4443. if user.Mobile == "" {
  4444. br.Msg = "提交失败!"
  4445. br.ErrMsg = "提交失败,手机号不能为空"
  4446. return
  4447. }
  4448. var req models.SubmitChooseSendResp
  4449. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  4450. if err != nil {
  4451. br.Msg = "参数解析异常!"
  4452. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  4453. return
  4454. }
  4455. isPush := req.IsPush // 是否接受推送
  4456. //isRefuse := req.IsRefuse
  4457. isSubjective := req.IsSubjective
  4458. isObjective := req.IsObjective
  4459. req.IsRefuse = 1 - isPush // 是否拒绝推送,与是否接收推送进行取反(兼容老的数据库字段)
  4460. isRefuse := req.IsRefuse
  4461. if isRefuse == 0 && isSubjective == 0 && isObjective == 0 {
  4462. br.Msg = "请至少选择一项主客观内容"
  4463. return
  4464. }
  4465. //如果为1 则不做任何推送 ,主观客观默认改成0
  4466. if isRefuse == 1 {
  4467. isSubjective = 0
  4468. isObjective = 0
  4469. }
  4470. mobile := user.Mobile
  4471. item := new(models.CygxXzsChooseSend)
  4472. item.UserId = user.UserId
  4473. item.Mobile = user.Mobile
  4474. item.Email = user.Email
  4475. item.CompanyId = user.CompanyId
  4476. item.CompanyName = user.CompanyName
  4477. item.RealName = user.RealName
  4478. item.CreateTime = time.Now()
  4479. item.ModifyTime = time.Now()
  4480. item.IsRefuse = req.IsRefuse
  4481. item.IsSubjective = isSubjective
  4482. item.IsObjective = isObjective
  4483. count, err := models.GetXzsChooseSendCountByMobile(mobile)
  4484. if err != nil {
  4485. br.Msg = "获取信息失败"
  4486. br.ErrMsg = "GetXzsChooseSendCountByMobile,Err:" + err.Error()
  4487. return
  4488. }
  4489. //如果有记录就新增,没有记录就修改
  4490. if count == 0 {
  4491. err = models.AddCygxXzsChooseSendPush(item)
  4492. } else {
  4493. err = models.UpdateCygxXzsChooseSendPush(item)
  4494. }
  4495. if err != nil {
  4496. br.Msg = "保存失败!"
  4497. br.ErrMsg = "保存失败!,Err:" + err.Error()
  4498. return
  4499. }
  4500. br.Ret = 200
  4501. br.Success = true
  4502. br.Msg = "保存成功"
  4503. }