report.go 115 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. "github.com/medivhzhan/weapp/v2"
  7. "github.com/rdlucklib/rdluck_tools/paging"
  8. "hongze/hongze_cygx/models"
  9. "hongze/hongze_cygx/services"
  10. "hongze/hongze_cygx/utils"
  11. "html"
  12. "strconv"
  13. "strings"
  14. "time"
  15. )
  16. // 报告
  17. type ReportController struct {
  18. BaseAuthController
  19. }
  20. type ReportCommonController struct {
  21. BaseCommonController
  22. }
  23. // @Title 行业报告分类列表接口
  24. // @Description 获取行业报告分类列表接口
  25. // @Param ChartPermissionId query int true "分类ID"
  26. // @Success 200 {object} models.IndustrialManagementList
  27. // @router /home/tradeList [get]
  28. func (this *ReportController) TradeList() {
  29. br := new(models.BaseResponse).Init()
  30. defer func() {
  31. this.Data["json"] = br
  32. this.ServeJSON()
  33. }()
  34. user := this.User
  35. if user == nil {
  36. br.Msg = "请重新登录"
  37. br.Ret = 408
  38. return
  39. }
  40. uid := user.UserId
  41. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  42. if ChartPermissionId < 1 {
  43. br.Msg = "请输入分类ID"
  44. return
  45. }
  46. list, err := models.GetTradeAll(ChartPermissionId)
  47. if err != nil {
  48. br.Msg = "获取信息失败"
  49. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  50. return
  51. }
  52. var condition string
  53. var pars []interface{}
  54. for k, v := range list {
  55. if v.PolymerizationId != "" {
  56. condition = ` AND a.category_id IN(` + v.PolymerizationId + `)`
  57. } else {
  58. condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
  59. }
  60. listArticle, err := models.GetHomeList(condition, pars, 0, 1)
  61. if err != nil && err.Error() != utils.ErrNoRow() {
  62. br.Msg = "获取信息失败"
  63. br.Msg = "GetHomeList,Err:" + err.Error()
  64. return
  65. }
  66. if len(listArticle) > 0 {
  67. list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  68. count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
  69. if err != nil {
  70. br.Msg = "获取信息失败"
  71. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  72. return
  73. }
  74. if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
  75. list[k].IsRed = true
  76. }
  77. }
  78. }
  79. resp := new(models.TradeReportMappingResp)
  80. resp.List = list
  81. br.Ret = 200
  82. br.Success = true
  83. br.Msg = "获取成功"
  84. br.Data = resp
  85. }
  86. // @Title 产业报告分类列表接口
  87. // @Description 获取产业报告分类列表接口
  88. // @Param ChartPermissionId query int true "分类ID"
  89. // @Param IsNewLabel query string true "是否属于新标签,1是,0否"
  90. // @Param IsDeepLabel query string true "是否属于深标签,1是,0否"
  91. // @Param KeyWord query string true "搜索关键词"
  92. // @Param OrderColumn query int true "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
  93. // @Param DeepCover query int false "深度覆盖:0-否;1-是"
  94. // @Param RecommendFocus query int false "推荐关注:0-否;1-是"
  95. // @Param PageSize query int true "每页数据条数"
  96. // @Param CurrentIndex query int true "当前页页码,从1开始"
  97. // @Success 200 {object} models.IndustrialManagementList
  98. // @router /home/industryList [get]
  99. func (this *ReportController) IndustryList() {
  100. br := new(models.BaseResponse).Init()
  101. defer func() {
  102. this.Data["json"] = br
  103. this.ServeJSON()
  104. }()
  105. user := this.User
  106. if user == nil {
  107. br.Msg = "请重新登录"
  108. br.Ret = 408
  109. return
  110. }
  111. uid := user.UserId
  112. fmt.Println(uid)
  113. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  114. orderColumn := this.GetString("OrderColumn")
  115. orderColumnNew := this.GetString("OrderColumn")
  116. isNewLabel := this.GetString("IsNewLabel")
  117. isDeepLabel := this.GetString("IsDeepLabel")
  118. keyWord := this.GetString("KeyWord")
  119. pageSize, _ := this.GetInt("PageSize")
  120. currentIndex, _ := this.GetInt("CurrentIndex")
  121. deepCover, _ := this.GetInt("DeepCover")
  122. recommendFocus, _ := this.GetInt("RecommendFocus")
  123. var orderSrt string
  124. var condition string
  125. var startSize int
  126. resp := new(models.IndustrialManagementList)
  127. if pageSize <= 0 {
  128. pageSize = utils.PageSize20
  129. }
  130. if currentIndex <= 0 {
  131. currentIndex = 1
  132. }
  133. startSize = paging.StartIndex(currentIndex, pageSize)
  134. if isNewLabel == "1" {
  135. condition += ` AND is_new_label = ` + isNewLabel
  136. }
  137. if isDeepLabel == "1" {
  138. condition += ` AND is_deep_label = ` + isDeepLabel
  139. }
  140. if keyWord != "" {
  141. condition += ` AND subject_names LIKE '%` + keyWord + `%'`
  142. }
  143. var sqlChartPermissionId string
  144. if ChartPermissionId > 0 {
  145. sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
  146. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  147. }
  148. // 深度覆盖
  149. if deepCover == 1 {
  150. // 查询深标签产业报告数
  151. var deepCondition string
  152. var deepPars []interface{}
  153. deepCondition += ` AND man.is_deep_label = 1`
  154. if ChartPermissionId > 0 {
  155. deepCondition += ` AND man.chart_permission_id = ?`
  156. deepPars = append(deepPars, ChartPermissionId)
  157. }
  158. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  159. if e != nil {
  160. br.Msg = "获取信息失败"
  161. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  162. return
  163. }
  164. deepIdArr := make([]string, 0)
  165. for i := range industryCountList {
  166. if industryCountList[i].ArtNum > 10 {
  167. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  168. }
  169. }
  170. deepIds := strings.Join(deepIdArr, ",")
  171. if deepIds != "" {
  172. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  173. }
  174. }
  175. // 推荐关注
  176. if recommendFocus == 1 {
  177. condition += ` AND man.recommended_index >= 80`
  178. }
  179. // 列表总数据量
  180. var list []*models.IndustrialManagement
  181. total, err := models.GetIndustrialManagementAllCount(condition)
  182. if err != nil {
  183. br.Msg = "获取信息失败"
  184. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  185. return
  186. }
  187. page := paging.GetPaging(currentIndex, pageSize, total)
  188. if orderColumn == "" {
  189. orderColumn = "NewTime"
  190. }
  191. if orderColumn == "NewTime" {
  192. orderSrt = "update_time DESC"
  193. } else {
  194. orderSrt = "man.recommended_index DESC,update_time DESC"
  195. }
  196. if ChartPermissionId == 0 {
  197. ChartPermissionId = 20
  198. }
  199. // 阅读第三的产业详情
  200. //detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
  201. //if err != nil {
  202. // br.Msg = "获取信息失败"
  203. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  204. // return
  205. //}
  206. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
  207. if err != nil {
  208. br.Msg = "获取信息失败"
  209. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  210. return
  211. }
  212. // 获取近一个月产业报告阅读次数最多的产业
  213. var topCond string
  214. var topPars []interface{}
  215. //topReadIndustryId := 0
  216. if ChartPermissionId > 0 {
  217. topCond += ` AND chart_permission_id = ?`
  218. topPars = append(topPars, ChartPermissionId)
  219. }
  220. list, err = services.HandleIndustryList(list, user)
  221. if orderColumnNew != "" {
  222. item := new(models.CygxReportIndustrialSeaarchHistory)
  223. item.UserId = user.UserId
  224. item.Mobile = user.Mobile
  225. item.CompanyId = user.CompanyId
  226. item.CompanyName = user.CompanyName
  227. item.CreateTime = time.Now()
  228. item.IsDeepLabel = isDeepLabel
  229. item.IsNewLabel = isNewLabel
  230. item.ChartPermissionId = ChartPermissionId
  231. if orderColumnNew == "NewTime" {
  232. item.OrderColumn = "0"
  233. } else {
  234. item.OrderColumn = "1"
  235. }
  236. go models.AddCygxReportIndustrialSeaarchHistory(item)
  237. }
  238. resp.List = list
  239. resp.Paging = page
  240. br.Ret = 200
  241. br.Success = true
  242. br.Msg = "获取成功"
  243. br.Data = resp
  244. }
  245. // @Title 产业下所关联的文章分类列表
  246. // @Description 产业下所关联的文章分类列表接口
  247. // @Param IndustrialManagementId query int true "产业ID"
  248. // @Param ShowTimeLine query int true "是否展示时间线 0不展示,1展示"
  249. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  250. // @router /toArticleCategoryList [get]
  251. func (this *ReportController) ArticleCategoryList() {
  252. br := new(models.BaseResponse).Init()
  253. defer func() {
  254. this.Data["json"] = br
  255. this.ServeJSON()
  256. }()
  257. user := this.User
  258. if user == nil {
  259. br.Msg = "请重新登录"
  260. br.Ret = 408
  261. return
  262. }
  263. uid := user.UserId
  264. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  265. if industrialManagementId < 1 {
  266. br.Msg = "请输入分类ID"
  267. return
  268. }
  269. showTimeLine, _ := this.GetInt("ShowTimeLine", 0)
  270. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  271. if err != nil {
  272. br.Msg = "获取信息失败"
  273. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  274. return
  275. }
  276. list, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
  277. if err != nil {
  278. br.Msg = "获取信息失败"
  279. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  280. return
  281. }
  282. for k, v := range list {
  283. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  284. if err != nil && err.Error() != utils.ErrNoRow() {
  285. br.Msg = "获取信息失败"
  286. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  287. return
  288. }
  289. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  290. if err != nil && err.Error() != utils.ErrNoRow() {
  291. br.Msg = "获取信息失败"
  292. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  293. return
  294. }
  295. if Newdetail != nil {
  296. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  297. list[k].IsRed = true
  298. }
  299. }
  300. }
  301. // 用户权限
  302. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  303. if e != nil {
  304. br.Msg = "获取失败"
  305. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  306. return
  307. }
  308. videoSimple := new(models.MicroVideoSimpleInfo)
  309. // 权限
  310. var au *models.UserPermissionAuthInfo
  311. video, err := models.GetMicroRoadshowVideoByIndustryId(industrialManagementId)
  312. if err != nil {
  313. if err.Error() != utils.ErrNoRow() {
  314. br.Msg = "获取产业视频失败"
  315. br.ErrMsg = "获取产业视频失败,Err:" + err.Error()
  316. return
  317. }
  318. } else {
  319. videoSimple.Id = video.VideoId
  320. videoSimple.Title = "5min逻辑【" + video.IndustryName + "】解析"
  321. videoSimple.BackgroundImg = video.ImgUrl
  322. videoSimple.DetailImgUrl = video.DetailImgUrl
  323. if videoSimple.BackgroundImg == "" {
  324. // 获取默认图配置
  325. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  326. if e != nil {
  327. br.Msg = "获取视频默认配置图失败"
  328. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  329. return
  330. }
  331. videoSimple.BackgroundImg = videoMap[video.ChartPermissionId]
  332. }
  333. videoSimple.PlaySeconds = video.VideoDuration
  334. videoSimple.ResourceUrl = video.VideoUrl
  335. au = new(models.UserPermissionAuthInfo)
  336. au.SellerName = authInfo.SellerName
  337. au.SellerMobile = authInfo.SellerMobile
  338. au.HasPermission = authInfo.HasPermission
  339. au.OperationMode = authInfo.OperationMode
  340. if au.HasPermission == 1 {
  341. // 非宏观权限进一步判断是否有权限
  342. if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  343. au.HasPermission = 2
  344. }
  345. }
  346. // 无权限的弹框提示
  347. if au.HasPermission != 1 {
  348. if au.OperationMode == services.UserPermissionOperationModeCall {
  349. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  350. } else {
  351. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  352. }
  353. videoSimple.ResourceUrl = ""
  354. }
  355. }
  356. //时间线
  357. if showTimeLine == 1 {
  358. timeLineItem := models.IndustrialToArticleCategoryRep{
  359. CategoryId: 99999,
  360. MatchTypeName: "时间线",
  361. }
  362. timeLineList, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, 0, 30)
  363. if err != nil {
  364. br.Msg = "获取信息失败"
  365. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  366. return
  367. }
  368. //查询用户今天是否看过时间线
  369. haveMorningMeeting := false
  370. var morningMeetingTime string
  371. count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  372. if err != nil {
  373. br.Msg = "查询浏览记录数量失败"
  374. br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  375. return
  376. }
  377. var recordItem *models.CygxPageHistoryRecord
  378. if count > 1 {
  379. recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  380. if err != nil {
  381. br.Msg = "查询浏览记录失败"
  382. br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  383. return
  384. }
  385. }
  386. for _, v := range timeLineList {
  387. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
  388. if v.SubCategoryName == "时间线" {
  389. haveMorningMeeting = true
  390. morningMeetingTime = v.PublishTime
  391. continue
  392. }
  393. timeLineItem.IsRed = true
  394. }
  395. }
  396. //因为无法记录用户是否看过晨会点评,所以用用户今天是否看过时间线来判断是否显示小红点,这里是判断分类的小红点
  397. timeLineRed := false
  398. if count < 2 {
  399. timeLineRed = true
  400. } else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(morningMeetingTime)) {
  401. timeLineRed = true
  402. }
  403. if !timeLineItem.IsRed && timeLineRed && haveMorningMeeting {
  404. timeLineItem.IsRed = true
  405. }
  406. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  407. }
  408. resp := new(models.IndustrialToArticleCategoryListRep)
  409. resp.List = list
  410. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  411. resp.IndustryName = detail.IndustryName
  412. resp.IndustrialManagementId = industrialManagementId
  413. resp.AuthInfo = au
  414. if videoSimple.Id > 0 {
  415. resp.IndustryVideo = videoSimple
  416. }
  417. br.Ret = 200
  418. br.Success = true
  419. br.Msg = "获取成功"
  420. br.Data = resp
  421. }
  422. // @Title 产业文章列表接口
  423. // @Description 获取产业文章列表接口
  424. // @Param PageSize query int true "每页数据条数"
  425. // @Param CurrentIndex query int true "当前页页码,从1开始"
  426. // @Param CategoryId query int true "分类ID"
  427. // @Param IndustrialManagementId query int true "产业ID"
  428. // @Success 200 {object} models.TacticsListResp
  429. // @router /industry/ArticleList [get]
  430. func (this *ReportController) List() {
  431. br := new(models.BaseResponse).Init()
  432. defer func() {
  433. this.Data["json"] = br
  434. this.ServeJSON()
  435. }()
  436. user := this.User
  437. if user == nil {
  438. br.Msg = "请重新登录"
  439. br.Ret = 408
  440. return
  441. }
  442. uid := user.UserId
  443. pageSize, _ := this.GetInt("PageSize")
  444. currentIndex, _ := this.GetInt("CurrentIndex")
  445. categoryId, _ := this.GetInt("CategoryId")
  446. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  447. var startSize int
  448. if pageSize <= 0 {
  449. pageSize = utils.PageSize20
  450. }
  451. if currentIndex <= 0 {
  452. currentIndex = 1
  453. }
  454. startSize = paging.StartIndex(currentIndex, pageSize)
  455. var pars []interface{}
  456. var total int
  457. page := paging.GetPaging(currentIndex, pageSize, total)
  458. if categoryId < 1 {
  459. br.Msg = "请输入分类ID"
  460. return
  461. }
  462. if industrialManagementId < 1 {
  463. br.Msg = "请输入产业ID"
  464. return
  465. }
  466. if categoryId != 99999 {
  467. resp := new(models.TacticsListResp)
  468. //获取该产业下所对应的行业图片
  469. detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
  470. if errCategory != nil {
  471. br.Msg = "获取信息失败"
  472. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  473. return
  474. }
  475. //对应行业的图片
  476. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  477. if err != nil {
  478. br.Msg = "获取数据失败"
  479. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  480. return
  481. }
  482. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  483. mapChartPermission := make(map[string]string)
  484. var permissionName string
  485. var imgUrlChartPermission string
  486. for _, v := range chartPermissionUrlList {
  487. vslice := strings.Split(v, "_")
  488. permissionName = vslice[0]
  489. imgUrlChartPermission = vslice[len(vslice)-1]
  490. mapChartPermission[permissionName] = imgUrlChartPermission
  491. }
  492. total, err = models.GetReportIndustrialCount(categoryId, industrialManagementId)
  493. if err != nil {
  494. br.Msg = "获取信息失败"
  495. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  496. return
  497. }
  498. page = paging.GetPaging(currentIndex, pageSize, total)
  499. list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  500. if err != nil {
  501. br.Msg = "获取信息失败"
  502. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  503. return
  504. }
  505. //对应分类的所图片
  506. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  507. if err != nil {
  508. br.Msg = "获取数据失败"
  509. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  510. return
  511. }
  512. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  513. mapCategoryUrl := make(map[string]string)
  514. var categoryIdStr string
  515. var imgUrlChart string
  516. for _, v := range categoryUrlList {
  517. vslice := strings.Split(v, "_")
  518. categoryIdStr = vslice[0]
  519. imgUrlChart = vslice[len(vslice)-1]
  520. mapCategoryUrl[categoryIdStr] = imgUrlChart
  521. }
  522. lenList := len(list)
  523. for i := 0; i < lenList; i++ {
  524. item := list[i]
  525. list[i].Body, _ = services.GetReportContentTextSub(item.Body)
  526. //list[i].Abstract = html.UnescapeString(item.Abstract)
  527. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  528. //list[i].Annotation = services.GetAnnotationTextSub(item.Annotation)
  529. }
  530. for k, v := range list {
  531. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  532. list[k].IsRed = true
  533. }
  534. if v.VideoUrl != "" {
  535. list[k].IsHaveVideo = true
  536. }
  537. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  538. if mapCategoryUrl[v.CategoryId] == "" {
  539. if detail.ChartPermissionId == utils.YI_YAO_ID {
  540. list[k].ImgUrlPc = utils.YI_YAO_QI_TA
  541. }
  542. }
  543. }
  544. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  545. resp.ChartPermissionId = detail.ChartPermissionId
  546. resp.List = list
  547. resp.Paging = page
  548. br.Ret = 200
  549. br.Success = true
  550. br.Msg = "获取成功"
  551. br.Data = resp
  552. } else {
  553. //获取该产业下所对应的行业图片
  554. //因为时间线不属于数据表里的二级分类,所以图片Id用产业id查到的list中的任意一个categoryId取到的图片替代
  555. categoryList, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
  556. if err != nil {
  557. br.Msg = "获取信息失败"
  558. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  559. return
  560. }
  561. var timeLineCategoryId int
  562. if len(categoryList) > 0 {
  563. timeLineCategoryId = categoryList[0].CategoryId
  564. }
  565. var detail *models.ReportMapping
  566. var errCategory error
  567. if timeLineCategoryId > 0 {
  568. detail, errCategory = models.GetdetailByCategoryIdOne(timeLineCategoryId)
  569. if errCategory != nil {
  570. br.Msg = "获取信息失败"
  571. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  572. return
  573. }
  574. }
  575. //对应行业的图片
  576. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  577. if err != nil {
  578. br.Msg = "获取数据失败"
  579. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  580. return
  581. }
  582. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  583. mapChartPermission := make(map[string]string)
  584. var permissionName string
  585. var imgUrlChartPermission string
  586. for _, v := range chartPermissionUrlList {
  587. vslice := strings.Split(v, "_")
  588. permissionName = vslice[0]
  589. imgUrlChartPermission = vslice[len(vslice)-1]
  590. mapChartPermission[permissionName] = imgUrlChartPermission
  591. }
  592. total, err := models.GetTimeLineReportIndustrialCount(industrialManagementId)
  593. if err != nil {
  594. br.Msg = "获取信息失败"
  595. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  596. return
  597. }
  598. page = paging.GetPaging(currentIndex, pageSize, total)
  599. list, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, startSize, pageSize)
  600. if err != nil {
  601. br.Msg = "获取信息失败"
  602. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  603. return
  604. }
  605. //对应分类的所图片
  606. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  607. if err != nil {
  608. br.Msg = "获取数据失败"
  609. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  610. return
  611. }
  612. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  613. mapCategoryUrl := make(map[string]string)
  614. var categoryIdStr string
  615. var imgUrlChart string
  616. for _, v := range categoryUrlList {
  617. vslice := strings.Split(v, "_")
  618. categoryIdStr = vslice[0]
  619. imgUrlChart = vslice[len(vslice)-1]
  620. mapCategoryUrl[categoryIdStr] = imgUrlChart
  621. }
  622. //lenList := len(list)
  623. //for i := 0; i < lenList; i++ {
  624. // item := list[i]
  625. // list[i].Content, _ = services.GetReportContentTextSub(item.Content)
  626. // //list[i].Abstract = html.UnescapeString(item.Abstract)
  627. // //list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  628. //}
  629. //查询用户今天是否看过时间线
  630. count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  631. if err != nil {
  632. br.Msg = "查询浏览记录数量失败"
  633. br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  634. return
  635. }
  636. var recordItem *models.CygxPageHistoryRecord
  637. if count > 1 {
  638. recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  639. if err != nil {
  640. br.Msg = "查询浏览记录失败"
  641. br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  642. return
  643. }
  644. }
  645. for k, v := range list {
  646. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
  647. list[k].IsRed = true
  648. }
  649. timeLineRed := false
  650. if count < 2 && v.SubCategoryName == "时间线" {
  651. timeLineRed = true
  652. } else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishTime)) {
  653. timeLineRed = true
  654. }
  655. if v.SubCategoryName == "时间线" && timeLineRed {
  656. list[k].IsRed = true
  657. }
  658. if v.VideoUrl != "" {
  659. list[k].IsHaveVideo = true
  660. }
  661. id := strconv.Itoa(timeLineCategoryId)
  662. list[k].ImgUrlPc = mapCategoryUrl[id]
  663. if mapCategoryUrl[id] == "" {
  664. if detail.ChartPermissionId == utils.YI_YAO_ID {
  665. list[k].ImgUrlPc = utils.YI_YAO_QI_TA
  666. }
  667. }
  668. }
  669. resp := new(models.TimeLineReportListResp)
  670. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  671. resp.List = list
  672. resp.Paging = page
  673. br.Ret = 200
  674. br.Success = true
  675. br.Msg = "获取成功"
  676. br.Data = resp
  677. }
  678. }
  679. // @Title 置顶/取消置顶
  680. // @Description 置顶
  681. // @Param request body models.CygxIndustryTopRep true "type json string"
  682. // @Success 200
  683. // @router /top [post]
  684. func (this *ReportController) ArticleCollect() {
  685. br := new(models.BaseResponse).Init()
  686. defer func() {
  687. this.Data["json"] = br
  688. this.ServeJSON()
  689. }()
  690. user := this.User
  691. if user == nil {
  692. br.Msg = "请重新登录"
  693. br.Ret = 408
  694. return
  695. }
  696. uid := user.UserId
  697. var req models.CygxIndustryTopRep
  698. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  699. if err != nil {
  700. br.Msg = "参数解析异常!"
  701. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  702. return
  703. }
  704. industrialManagementId := req.IndustrialManagementId
  705. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  706. if err != nil {
  707. br.Msg = "获取数据失败!"
  708. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  709. return
  710. }
  711. if countIndustrial == 0 {
  712. br.Msg = "产业不存在!"
  713. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  714. return
  715. }
  716. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  717. if err != nil {
  718. br.Msg = "获取数据失败!"
  719. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  720. return
  721. }
  722. resp := new(models.ArticleCollectResp)
  723. if count <= 0 {
  724. item := new(models.CygxIndustryTop)
  725. item.IndustrialManagementId = req.IndustrialManagementId
  726. item.UserId = uid
  727. item.CreateTime = time.Now()
  728. _, err = models.AddCygxIndustryTop(item)
  729. if err != nil {
  730. br.Msg = "置顶失败"
  731. br.ErrMsg = "置顶失败,Err:" + err.Error()
  732. return
  733. }
  734. br.Msg = "置顶成功"
  735. resp.Status = 1
  736. } else {
  737. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  738. if err != nil {
  739. br.Msg = "取消置顶失败"
  740. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  741. return
  742. }
  743. br.Msg = "已取消置顶"
  744. resp.Status = 2
  745. }
  746. br.Ret = 200
  747. br.Success = true
  748. br.Data = resp
  749. }
  750. // @Title 关注/取消关注产业
  751. // @Description 关注/取消关注 接口
  752. // @Param request body models.CygxIndustryFllowRep true "type json string"
  753. // @Success 200
  754. // @router /fllow [post]
  755. func (this *ReportController) Fllow() {
  756. br := new(models.BaseResponse).Init()
  757. defer func() {
  758. this.Data["json"] = br
  759. this.ServeJSON()
  760. }()
  761. user := this.User
  762. if user == nil {
  763. br.Msg = "请重新登录"
  764. br.Ret = 408
  765. return
  766. }
  767. uid := user.UserId
  768. var req models.CygxIndustryFllowRep
  769. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  770. if err != nil {
  771. br.Msg = "参数解析异常!"
  772. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  773. return
  774. }
  775. industrialManagementId := req.IndustrialManagementId
  776. var condition string
  777. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  778. if err != nil {
  779. br.Msg = "获取数据失败!"
  780. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  781. return
  782. }
  783. if countIndustrial == 0 {
  784. br.Msg = "产业不存在!"
  785. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  786. return
  787. }
  788. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  789. if err != nil {
  790. br.Msg = "获取数据失败!"
  791. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  792. return
  793. }
  794. resp := new(models.CygxIndustryFllowResp)
  795. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  796. if countUser == 0 {
  797. resp.GoFollow = true
  798. }
  799. if count == 0 {
  800. item := new(models.CygxIndustryFllow)
  801. item.IndustrialManagementId = industrialManagementId
  802. item.UserId = uid
  803. item.Email = user.Email
  804. item.Mobile = user.Mobile
  805. item.RealName = user.RealName
  806. item.CompanyId = user.CompanyId
  807. item.CompanyName = user.CompanyName
  808. item.Type = 1
  809. item.CreateTime = time.Now()
  810. item.ModifyTime = time.Now()
  811. _, err = models.AddCygxIndustryFllow(item)
  812. if err != nil {
  813. br.Msg = "操作失败"
  814. br.ErrMsg = "操作失败,Err:" + err.Error()
  815. return
  816. }
  817. resp.Status = 1
  818. } else {
  819. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  820. if err != nil {
  821. br.Msg = "操作失败"
  822. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  823. return
  824. }
  825. }
  826. //处理是否关注全部赛道字段
  827. go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  828. br.Msg = "操作成功"
  829. br.Ret = 200
  830. br.Success = true
  831. br.Data = resp
  832. }
  833. // @Title 产业报告分类关联作者列表接口
  834. // @Description 获取产业报告分类关联作者列表接口
  835. // @Param ChartPermissionId query int true "分类ID"
  836. // @Param PageSize query int true "每页数据条数"
  837. // @Param CurrentIndex query int true "当前页页码,从1开始"
  838. // @Success 200 {object} models.CygxArticleDepartmentList
  839. // @router /industryListByDepartment [get]
  840. func (this *ReportController) IndustryListByDepartment() {
  841. br := new(models.BaseResponse).Init()
  842. defer func() {
  843. this.Data["json"] = br
  844. this.ServeJSON()
  845. }()
  846. user := this.User
  847. if user == nil {
  848. br.Msg = "请重新登录"
  849. br.Ret = 408
  850. return
  851. }
  852. uid := user.UserId
  853. pageSize, _ := this.GetInt("PageSize")
  854. currentIndex, _ := this.GetInt("CurrentIndex")
  855. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  856. var startSize int
  857. var condition string
  858. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  859. condition = ` AND a.publish_status=1 `
  860. if pageSize <= 0 {
  861. pageSize = utils.PageSize20
  862. }
  863. if currentIndex <= 0 {
  864. currentIndex = 1
  865. }
  866. startSize = paging.StartIndex(currentIndex, pageSize)
  867. total, err := models.GetArticleDepartmentCount(condition)
  868. page := paging.GetPaging(currentIndex, pageSize, total)
  869. resp := new(models.CygxArticleDepartmentList)
  870. userType, _, err := services.GetUserType(user.CompanyId)
  871. if err != nil {
  872. br.Msg = "获取信息失败"
  873. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  874. return
  875. }
  876. if userType == 1 {
  877. resp.Paging = page
  878. br.Ret = 200
  879. br.Success = true
  880. br.Msg = "获取成功"
  881. br.Data = resp
  882. return
  883. }
  884. resp.HaveResearch = true
  885. //获取作者信息,并排序
  886. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  887. if err != nil {
  888. br.Msg = "获取信息失败"
  889. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  890. return
  891. }
  892. for k, v := range list {
  893. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  894. if err != nil {
  895. br.Msg = "获取信息失败"
  896. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  897. return
  898. }
  899. for k2, v2 := range artList {
  900. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  901. if err != nil {
  902. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  903. br.ErrMsg = "获取失败,Err:" + err.Error()
  904. return
  905. }
  906. var subjectNamesNew string
  907. if len(subjectNames) > 0 {
  908. slice := strings.Split(subjectNames, "/")
  909. for k3, v3 := range slice {
  910. if k3 < 4 {
  911. subjectNamesNew += v3 + "/"
  912. }
  913. }
  914. }
  915. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  916. if err != nil && err.Error() != utils.ErrNoRow() {
  917. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  918. br.ErrMsg = "获取失败,Err:" + err.Error()
  919. return
  920. }
  921. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  922. artList[k2].SubjectName = subjectNamesNew
  923. artList[k2].DepartmentId = v.DepartmentId
  924. if subjectNamesNew == "" {
  925. artList[k2].IndustryName = industryName
  926. } else {
  927. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  928. }
  929. if artList[k2].IsReport == "1" {
  930. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  931. } else {
  932. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  933. }
  934. }
  935. list[k].List = artList
  936. if v.FollowNum > 0 {
  937. list[k].IsMyFollow = true
  938. }
  939. }
  940. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  941. if err != nil {
  942. br.Msg = "获取信息失败"
  943. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  944. return
  945. }
  946. if len(listnNew) > 0 {
  947. for _, v := range listnNew {
  948. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  949. Management := new(models.IndustrialManagementIdInt)
  950. if firstStr == 0 {
  951. Management.IndustryName = v.IndustryName
  952. } else {
  953. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  954. if err != nil {
  955. br.Msg = "获取信息失败"
  956. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  957. return
  958. }
  959. var subjectNamesNew string
  960. for _, v1 := range listSub {
  961. subjectNamesNew += v1.SubjectName + "/"
  962. }
  963. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  964. Management.IndustryName = subjectNamesNew
  965. }
  966. Management.IndustrialManagementId = v.IndustrialManagementId
  967. Management.ArticleId = v.ArticleId
  968. resp.ListnNew = append(resp.ListnNew, Management)
  969. }
  970. }
  971. resp.List = list
  972. resp.Paging = page
  973. br.Ret = 200
  974. br.Success = true
  975. br.Msg = "获取成功"
  976. br.Data = resp
  977. }
  978. // @Title 关注作者/取消关注作者
  979. // @Description 关注作者/取消关注作者 接口
  980. // @Param request body models.CygxArticleDepartmentId true "type json string"
  981. // @Success 200
  982. // @router /fllowDepartment [post]
  983. func (this *ReportController) FllowDepartment() {
  984. br := new(models.BaseResponse).Init()
  985. defer func() {
  986. this.Data["json"] = br
  987. this.ServeJSON()
  988. }()
  989. user := this.User
  990. if user == nil {
  991. br.Msg = "请重新登录"
  992. br.Ret = 408
  993. return
  994. }
  995. uid := user.UserId
  996. var req models.CygxArticleDepartmentId
  997. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  998. if err != nil {
  999. br.Msg = "参数解析异常!"
  1000. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1001. return
  1002. }
  1003. departmentId := req.DepartmentId
  1004. var condition string
  1005. countDepartment, err := models.GetDepartmentCount(departmentId)
  1006. if err != nil {
  1007. br.Msg = "获取数据失败!"
  1008. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1009. return
  1010. }
  1011. if countDepartment == 0 {
  1012. br.Msg = "作者不存在!"
  1013. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  1014. return
  1015. }
  1016. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  1017. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1018. if err != nil {
  1019. br.Msg = "获取数据失败!"
  1020. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1021. return
  1022. }
  1023. resp := new(models.CygxArticleDepartmentFollowResp)
  1024. if countUser == 0 {
  1025. resp.GoFollow = true
  1026. }
  1027. if count == 0 {
  1028. item := new(models.CygxArticleDepartmentFollow)
  1029. item.DepartmentId = departmentId
  1030. item.UserId = uid
  1031. item.Email = user.Email
  1032. item.Mobile = user.Mobile
  1033. item.RealName = user.RealName
  1034. item.CompanyId = user.CompanyId
  1035. item.CompanyName = user.CompanyName
  1036. item.Type = 1
  1037. item.CreateTime = time.Now()
  1038. item.ModifyTime = time.Now()
  1039. _, err = models.AddArticleDepartmentFollow(item)
  1040. if err != nil {
  1041. br.Msg = "操作失败"
  1042. br.ErrMsg = "操作失败,Err:" + err.Error()
  1043. return
  1044. }
  1045. resp.Status = 1
  1046. } else {
  1047. var doType int
  1048. condition = ` AND type = 1`
  1049. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1050. if err != nil {
  1051. br.Msg = "操作失败!"
  1052. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1053. return
  1054. }
  1055. if count == 1 {
  1056. resp.Status = 2
  1057. doType = 2
  1058. } else {
  1059. resp.Status = 1
  1060. doType = 1
  1061. }
  1062. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  1063. if err != nil {
  1064. br.Msg = "操作失败"
  1065. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  1066. return
  1067. }
  1068. }
  1069. br.Msg = "操作成功"
  1070. br.Ret = 200
  1071. br.Success = true
  1072. br.Data = resp
  1073. }
  1074. // @Title 研选文章列表接口
  1075. // @Description 获取研选文章列表接口
  1076. // @Param PageSize query int true "每页数据条数"
  1077. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1078. // @Param ArticleId query int true "文章id"
  1079. // @Param DepartmentId query int true "作者ID"
  1080. // @Param IndustrialManagementId query int true "产业ID"
  1081. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1082. // @router /industry/reportList [get]
  1083. func (this *ReportController) ReportList() {
  1084. br := new(models.BaseResponse).Init()
  1085. defer func() {
  1086. this.Data["json"] = br
  1087. this.ServeJSON()
  1088. }()
  1089. user := this.User
  1090. if user == nil {
  1091. br.Msg = "请重新登录"
  1092. br.Ret = 408
  1093. return
  1094. }
  1095. uid := user.UserId
  1096. pageSize, _ := this.GetInt("PageSize")
  1097. currentIndex, _ := this.GetInt("CurrentIndex")
  1098. departmentId, _ := this.GetInt("DepartmentId")
  1099. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1100. articleId, _ := this.GetInt("ArticleId")
  1101. var condition string
  1102. var startSize int
  1103. if pageSize <= 0 {
  1104. pageSize = utils.PageSize20
  1105. }
  1106. if currentIndex <= 0 {
  1107. currentIndex = 1
  1108. }
  1109. startSize = paging.StartIndex(currentIndex, pageSize)
  1110. var pars []interface{}
  1111. var total int
  1112. resp := new(models.ReportArticleWhichIndustrialRepList)
  1113. page := paging.GetPaging(currentIndex, pageSize, total)
  1114. userType, _, err := services.GetUserType(user.CompanyId)
  1115. if err != nil {
  1116. br.Msg = "获取信息失败"
  1117. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1118. return
  1119. }
  1120. if userType == 1 {
  1121. resp.Paging = page
  1122. br.Ret = 200
  1123. br.Success = true
  1124. br.Msg = "获取成功"
  1125. br.Data = resp
  1126. return
  1127. }
  1128. resp.HaveResearch = true
  1129. if departmentId > 0 {
  1130. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  1131. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  1132. if err != nil {
  1133. br.Msg = "获取信息失败"
  1134. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1135. return
  1136. }
  1137. resp.NickName = detail.NickName
  1138. }
  1139. if industrialManagementId > 0 {
  1140. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  1141. }
  1142. if articleId > 0 {
  1143. detail, err := models.GetArticleDetailById(articleId)
  1144. if err != nil {
  1145. br.Msg = "获取信息失败"
  1146. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1147. return
  1148. }
  1149. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  1150. }
  1151. total, err = models.GetWhichDepartmentCount(condition)
  1152. if err != nil {
  1153. br.Msg = "获取信息失败"
  1154. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1155. return
  1156. }
  1157. page = paging.GetPaging(currentIndex, pageSize, total)
  1158. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1159. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1160. if err != nil {
  1161. br.Msg = "获取失败"
  1162. br.ErrMsg = "获取失败,Err:" + err.Error()
  1163. return
  1164. }
  1165. for k, v := range list {
  1166. if v.Readnum == 0 {
  1167. list[k].IsRed = true
  1168. }
  1169. list[k].IsResearch = true
  1170. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1171. if err != nil {
  1172. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1173. br.ErrMsg = "获取失败,Err:" + err.Error()
  1174. return
  1175. }
  1176. var subjectNamesNew string
  1177. if len(subjectNames) > 0 {
  1178. slice := strings.Split(subjectNames, "/")
  1179. for k3, v3 := range slice {
  1180. if k3 < 4 {
  1181. subjectNamesNew += v3 + "/"
  1182. }
  1183. }
  1184. }
  1185. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1186. if err != nil && err.Error() != utils.ErrNoRow() {
  1187. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1188. br.ErrMsg = "获取失败,Err:" + err.Error()
  1189. return
  1190. }
  1191. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1192. list[k].SubjectName = subjectNamesNew
  1193. if subjectNamesNew != "" {
  1194. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1195. } else {
  1196. list[k].IndustryName = industryName
  1197. }
  1198. resp.IndustryName = industryName
  1199. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1200. }
  1201. resp.List = list
  1202. resp.Paging = page
  1203. br.Ret = 200
  1204. br.Success = true
  1205. br.Msg = "获取成功"
  1206. br.Data = resp
  1207. }
  1208. // @Title 研选最新主题关键词文章列表接口
  1209. // @Description 获取研选最新主题关键词文章列表接口
  1210. // @Param PageSize query int true "每页数据条数"
  1211. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1212. // @Param ArticleId query int true "文章id"
  1213. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1214. // @router /industry/reportListNew [get]
  1215. func (this *ReportController) ReportListNew() {
  1216. br := new(models.BaseResponse).Init()
  1217. defer func() {
  1218. this.Data["json"] = br
  1219. this.ServeJSON()
  1220. }()
  1221. user := this.User
  1222. if user == nil {
  1223. br.Msg = "请重新登录"
  1224. br.Ret = 408
  1225. return
  1226. }
  1227. uid := user.UserId
  1228. pageSize, _ := this.GetInt("PageSize")
  1229. currentIndex, _ := this.GetInt("CurrentIndex")
  1230. articleId, _ := this.GetInt("ArticleId")
  1231. var condition string
  1232. var startSize int
  1233. if pageSize <= 0 {
  1234. pageSize = utils.PageSize20
  1235. }
  1236. if currentIndex <= 0 {
  1237. currentIndex = 1
  1238. }
  1239. startSize = paging.StartIndex(currentIndex, pageSize)
  1240. var pars []interface{}
  1241. var total int
  1242. resp := new(models.ReportArticleWhichIndustrialRepList)
  1243. page := paging.GetPaging(currentIndex, pageSize, total)
  1244. userType, _, err := services.GetUserType(user.CompanyId)
  1245. if err != nil {
  1246. br.Msg = "获取信息失败"
  1247. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1248. return
  1249. }
  1250. if userType == 1 {
  1251. resp.Paging = page
  1252. br.Ret = 200
  1253. br.Success = true
  1254. br.Msg = "获取成功"
  1255. br.Data = resp
  1256. return
  1257. }
  1258. resp.HaveResearch = true
  1259. if articleId > 0 {
  1260. detail, err := models.GetArticleDetailById(articleId)
  1261. if err != nil {
  1262. br.Msg = "获取信息失败"
  1263. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1264. return
  1265. }
  1266. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  1267. if firstStr == 0 {
  1268. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  1269. } else {
  1270. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  1271. }
  1272. }
  1273. total, err = models.GetWhichDepartmentCount(condition)
  1274. if err != nil {
  1275. br.Msg = "获取信息失败"
  1276. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1277. return
  1278. }
  1279. page = paging.GetPaging(currentIndex, pageSize, total)
  1280. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1281. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1282. if err != nil {
  1283. br.Msg = "获取失败"
  1284. br.ErrMsg = "获取失败,Err:" + err.Error()
  1285. return
  1286. }
  1287. for k, v := range list {
  1288. if v.Readnum == 0 {
  1289. list[k].IsRed = true
  1290. }
  1291. list[k].IsResearch = true
  1292. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1293. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1294. if err != nil {
  1295. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1296. br.ErrMsg = "获取失败,Err:" + err.Error()
  1297. return
  1298. }
  1299. var subjectNamesNew string
  1300. if len(subjectNames) > 0 {
  1301. slice := strings.Split(subjectNames, "/")
  1302. for k3, v3 := range slice {
  1303. if k3 < 4 {
  1304. subjectNamesNew += v3 + "/"
  1305. }
  1306. }
  1307. }
  1308. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1309. if err != nil && err.Error() != utils.ErrNoRow() {
  1310. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1311. br.ErrMsg = "获取失败,Err:" + err.Error()
  1312. return
  1313. }
  1314. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1315. list[k].SubjectName = subjectNamesNew
  1316. if subjectNamesNew != "" {
  1317. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1318. } else {
  1319. list[k].IndustryName = industryName
  1320. }
  1321. resp.IndustryName = industryName
  1322. }
  1323. resp.List = list
  1324. resp.Paging = page
  1325. br.Ret = 200
  1326. br.Success = true
  1327. br.Msg = "获取成功"
  1328. br.Data = resp
  1329. }
  1330. // @Title 是否展示绝密内参
  1331. // @Description 获取是否展示绝密内参接口
  1332. // @Param request body models.IsShow true "type json string"
  1333. // @Success 200
  1334. // @router /isShow [get]
  1335. func (this *ReportController) IsShow() {
  1336. br := new(models.BaseResponse).Init()
  1337. defer func() {
  1338. this.Data["json"] = br
  1339. this.ServeJSON()
  1340. }()
  1341. user := this.User
  1342. if user == nil {
  1343. br.Msg = "请重新登录"
  1344. br.Ret = 408
  1345. return
  1346. }
  1347. var resp models.IsShow
  1348. IsShowFreeButton, err := services.GetfreeButtonIsShow(user)
  1349. if err != nil {
  1350. br.Msg = "获取失败"
  1351. br.ErrMsg = "获取失败,GetfreeButtonIsShow Err:" + err.Error()
  1352. return
  1353. }
  1354. resp.IsShowChart = true
  1355. //resp.IsShowResearch = true
  1356. resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
  1357. resp.ActivitySpecialExplain = utils.ACTIVITY_SPECIAL_EXPLAIN
  1358. //resp.YanXuan_Explain = true
  1359. resp.IsShowFreeButton = IsShowFreeButton
  1360. //mobile := user.Mobile
  1361. //if mobile == "" {
  1362. // br.Ret = 200
  1363. // br.Success = true
  1364. // br.Data = resp
  1365. // return
  1366. //}
  1367. //total, _ := models.GetUserIsAdminCount(mobile)
  1368. //if total > 0 {
  1369. // resp.IsShowList = true
  1370. //}
  1371. resp.IsShowList = true
  1372. resp.SearchTxtList.SummarySearch = "全局搜索"
  1373. resp.SearchTxtList.ReportSearch = "全局搜索"
  1374. resp.SearchTxtList.YanXuanSearch = "全局搜索"
  1375. resp.SearchTxtList.ActivitySearch = "全局搜索"
  1376. resp.SearchTxtList.TabSearch = "请输入关键词"
  1377. resp.IsShow = true
  1378. br.Ret = 200
  1379. br.Success = true
  1380. br.Data = resp
  1381. }
  1382. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1383. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1384. // @Param PageSize query int true "每页数据条数"
  1385. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1386. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1387. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1388. // @router /reportList/byType [get]
  1389. func (this *ReportController) ReportListByType() {
  1390. br := new(models.BaseResponse).Init()
  1391. defer func() {
  1392. this.Data["json"] = br
  1393. this.ServeJSON()
  1394. }()
  1395. user := this.User
  1396. if user == nil {
  1397. br.Msg = "请重新登录"
  1398. br.Ret = 408
  1399. return
  1400. }
  1401. uid := user.UserId
  1402. pageSize, _ := this.GetInt("PageSize")
  1403. currentIndex, _ := this.GetInt("CurrentIndex")
  1404. reportType := this.GetString("ReportType")
  1405. var condition string
  1406. var startSize int
  1407. if pageSize <= 0 {
  1408. pageSize = utils.PageSize20
  1409. }
  1410. if currentIndex <= 0 {
  1411. currentIndex = 1
  1412. }
  1413. startSize = paging.StartIndex(currentIndex, pageSize)
  1414. var pars []interface{}
  1415. var total int
  1416. resp := new(models.CygxReportSelectionListPublicRep)
  1417. page := paging.GetPaging(currentIndex, pageSize, total)
  1418. var tbdb string
  1419. var readSql string
  1420. var reportTypeStr string
  1421. if reportType == "1" {
  1422. tbdb = "cygx_report_selection"
  1423. reportTypeStr = "bgjx"
  1424. } else if reportType == "2" {
  1425. tbdb = "cygx_research_summary"
  1426. reportTypeStr = "bzyjhz"
  1427. } else if reportType == "3" {
  1428. tbdb = "cygx_minutes_summary"
  1429. reportTypeStr = "szjyhz"
  1430. } else {
  1431. br.Msg = "请选择报告类型"
  1432. return
  1433. }
  1434. fmt.Println(tbdb)
  1435. condition = ` AND publish_status = 1 `
  1436. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1437. if err != nil {
  1438. br.Msg = "获取信息失败"
  1439. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1440. return
  1441. }
  1442. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1443. if reportType == "1" {
  1444. startSize = 0
  1445. pageSize = 1
  1446. total = 1
  1447. }
  1448. 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`
  1449. page = paging.GetPaging(currentIndex, pageSize, total)
  1450. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1451. if err != nil {
  1452. br.Msg = "获取失败"
  1453. br.ErrMsg = "获取失败,Err:" + err.Error()
  1454. return
  1455. }
  1456. for k, v := range list {
  1457. if reportType == "1" {
  1458. list[k].Abstract = v.UpdateDescription
  1459. }
  1460. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1461. if v.ReadNum == 0 {
  1462. list[k].IsRed = true
  1463. }
  1464. }
  1465. resp.List = list
  1466. resp.Paging = page
  1467. br.Ret = 200
  1468. br.Success = true
  1469. br.Msg = "获取成功"
  1470. br.Data = resp
  1471. }
  1472. // @Title 获取报告精选详情
  1473. // @Description 获取报告精选详情接口
  1474. // @Param ArticleId query int true "报告ID"
  1475. // @Success 200 {object} models.ReportSelectionLetailResp
  1476. // @router /reportSelection/detail [get]
  1477. func (this *ReportController) Detail() {
  1478. br := new(models.BaseResponse).Init()
  1479. defer func() {
  1480. this.Data["json"] = br
  1481. this.ServeJSON()
  1482. }()
  1483. user := this.User
  1484. if user == nil {
  1485. br.Msg = "请重新登录"
  1486. br.Ret = 408
  1487. return
  1488. }
  1489. uid := user.UserId
  1490. articleId, _ := this.GetInt("ArticleId")
  1491. if articleId < 0 {
  1492. br.Msg = "参数错误"
  1493. br.ErrMsg = "参数错误"
  1494. return
  1495. }
  1496. resp := new(models.ReportSelectionLetailResp)
  1497. //判断用户权限
  1498. hasPermission, err := services.GetUserhasPermission(user)
  1499. if err != nil {
  1500. br.Msg = "获取信息失败"
  1501. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1502. }
  1503. resp.HasPermission = hasPermission
  1504. if hasPermission != 1 {
  1505. br.Ret = 200
  1506. br.Success = true
  1507. br.Msg = "获取成功"
  1508. br.Data = resp
  1509. return
  1510. }
  1511. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1512. if err != nil {
  1513. br.Msg = "获取信息失败"
  1514. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1515. return
  1516. }
  1517. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1518. existMap := make(map[int]int)
  1519. var items []*models.ReportSelectionChartPermission
  1520. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1521. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1522. if err != nil {
  1523. br.Msg = "获取失败"
  1524. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1525. return
  1526. }
  1527. //var itemLogs []*models.CygxReportSelectionLogDetail
  1528. for _, v := range listLog {
  1529. item := new(models.ReportSelectionChartPermission)
  1530. if existMap[v.ChartPermissionId] == 0 {
  1531. item.PermissionName = v.PermissionName + "领域深度报告和调研"
  1532. item.IcoLink = v.IcoLink
  1533. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1534. if err != nil && err.Error() != utils.ErrNoRow() {
  1535. br.Msg = "获取信息失败"
  1536. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1537. return
  1538. }
  1539. for k2, v2 := range listSonLog {
  1540. if v2.IndustrialManagementId != "" {
  1541. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1542. if err != nil && err.Error() != utils.ErrNoRow() {
  1543. br.Msg = "获取信息失败"
  1544. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1545. return
  1546. }
  1547. listSonLog[k2].List = listIndustrial
  1548. }
  1549. }
  1550. item.List = listSonLog
  1551. items = append(items, item)
  1552. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1553. }
  1554. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1555. }
  1556. historyRecord := new(models.CygxReportHistoryRecord)
  1557. historyRecord.UserId = uid
  1558. historyRecord.ArticleId = articleId
  1559. historyRecord.CreateTime = time.Now()
  1560. historyRecord.Mobile = user.Mobile
  1561. historyRecord.Email = user.Email
  1562. historyRecord.CompanyId = user.CompanyId
  1563. historyRecord.CompanyName = user.CompanyName
  1564. historyRecord.ReportType = "bgjx"
  1565. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1566. if err != nil && err.Error() != utils.ErrNoRow() {
  1567. br.Msg = "获取信息失败"
  1568. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1569. return
  1570. }
  1571. historyRecord.RealName = user.RealName
  1572. if sellerItem != nil {
  1573. historyRecord.SellerName = sellerItem.RealName
  1574. }
  1575. go models.AddCygxReportHistoryRecord(historyRecord)
  1576. resp.List = items
  1577. resp.Detail = detail
  1578. br.Ret = 200
  1579. br.Success = true
  1580. br.Msg = "获取成功"
  1581. br.Data = resp
  1582. }
  1583. // @Title 获取本周研究汇总详情
  1584. // @Description 获取本周研究汇总详情接口
  1585. // @Param ArticleId query int true "报告ID"
  1586. // @Success 200 {object} models.ResearchSummaryLetailResp
  1587. // @router /researchSummary/detail [get]
  1588. func (this *ReportController) ResearchDetail() {
  1589. br := new(models.BaseResponse).Init()
  1590. defer func() {
  1591. this.Data["json"] = br
  1592. this.ServeJSON()
  1593. }()
  1594. user := this.User
  1595. if user == nil {
  1596. br.Msg = "请重新登录"
  1597. br.Ret = 408
  1598. return
  1599. }
  1600. uid := user.UserId
  1601. articleId, _ := this.GetInt("ArticleId")
  1602. if articleId < 0 {
  1603. br.Msg = "参数错误"
  1604. br.ErrMsg = "参数错误"
  1605. return
  1606. }
  1607. resp := new(models.ResearchSummaryLetailResp)
  1608. //判断用户权限
  1609. hasPermission, err := services.GetUserhasPermission(user)
  1610. if err != nil {
  1611. br.Msg = "获取信息失败"
  1612. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1613. }
  1614. resp.HasPermission = hasPermission
  1615. if hasPermission != 1 {
  1616. br.Ret = 200
  1617. br.Success = true
  1618. br.Msg = "获取成功"
  1619. br.Data = resp
  1620. return
  1621. }
  1622. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1623. if err != nil {
  1624. br.Msg = "获取信息失败"
  1625. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1626. return
  1627. }
  1628. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1629. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1630. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1631. if err != nil {
  1632. br.Msg = "获取失败"
  1633. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1634. return
  1635. }
  1636. listArticleType, err := models.GetCygxArticleTypeList()
  1637. if err != nil {
  1638. br.Msg = "获取失败"
  1639. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1640. return
  1641. }
  1642. for k, v := range listFirst {
  1643. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1644. if err != nil && err.Error() != utils.ErrNoRow() {
  1645. br.Msg = "获取信息失败"
  1646. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1647. return
  1648. }
  1649. for k2, v2 := range listSecond {
  1650. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1651. if err != nil && err.Error() != utils.ErrNoRow() {
  1652. br.Msg = "获取信息失败"
  1653. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1654. return
  1655. }
  1656. for _, vType := range listArticleType {
  1657. if v2.ChartPermissionId == vType.YanxPermissionId {
  1658. listSecond[k2].IcoLink = vType.IcoLinkM
  1659. listSecond[k2].PermissionName = vType.YanxPermissionName
  1660. }
  1661. }
  1662. //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1663. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1664. // listSecond[k2].PermissionName = "买方研选纪要"
  1665. //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1666. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1667. // listSecond[k2].PermissionName = "买方研选观点"
  1668. //}
  1669. if len(listThird) > 0 {
  1670. for k3, v3 := range listThird {
  1671. if v3.VideoUrl != "" {
  1672. listThird[k3].IsHaveVideo = true
  1673. }
  1674. if v3.ReportLink == "0" {
  1675. listThird[k3].ReportLink = ""
  1676. }
  1677. }
  1678. listSecond[k2].List = listThird
  1679. }
  1680. }
  1681. if len(listSecond) > 0 {
  1682. listFirst[k].List = listSecond
  1683. }
  1684. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1685. if v.Type == "SDBG" {
  1686. listFirst[k].ListName = "深度报告"
  1687. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1688. } else if v.Type == "BZCHJH" {
  1689. listFirst[k].ListName = "本周晨会精华"
  1690. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1691. } else if v.Type == "CYDYJY" {
  1692. listFirst[k].ListName = "产业调研纪要"
  1693. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1694. } else if v.Type == "SSGS" {
  1695. listFirst[k].ListName = "上市公司调研纪要篇"
  1696. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1697. } else if v.Type == "SJDP" {
  1698. listFirst[k].ListName = "事件点评"
  1699. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1700. } else if v.Type == "YANX" {
  1701. listFirst[k].ListName = "买方研选"
  1702. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1703. }
  1704. }
  1705. historyRecord := new(models.CygxReportHistoryRecord)
  1706. historyRecord.UserId = uid
  1707. historyRecord.ArticleId = articleId
  1708. historyRecord.CreateTime = time.Now()
  1709. historyRecord.Mobile = user.Mobile
  1710. historyRecord.Email = user.Email
  1711. historyRecord.CompanyId = user.CompanyId
  1712. historyRecord.CompanyName = user.CompanyName
  1713. historyRecord.ReportType = "bzyjhz"
  1714. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1715. if err != nil && err.Error() != utils.ErrNoRow() {
  1716. br.Msg = "获取信息失败"
  1717. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1718. return
  1719. }
  1720. historyRecord.RealName = user.RealName
  1721. if sellerItem != nil {
  1722. historyRecord.SellerName = sellerItem.RealName
  1723. }
  1724. go models.AddCygxReportHistoryRecord(historyRecord)
  1725. resp.List = listFirst
  1726. resp.Detail = detail
  1727. br.Ret = 200
  1728. br.Success = true
  1729. br.Msg = "获取成功"
  1730. br.Data = resp
  1731. }
  1732. // @Title 上周纪要汇总内容详情
  1733. // @Description 获取上周纪要汇总内容详情接口
  1734. // @Param ArticleId query int true "报告ID"
  1735. // @Success 200 {object} models.MinutesSummaryLetailResp
  1736. // @router /minutesSummary/detailv4 [get]
  1737. func (this *ReportController) MinutesDetailV4() {
  1738. br := new(models.BaseResponse).Init()
  1739. defer func() {
  1740. this.Data["json"] = br
  1741. this.ServeJSON()
  1742. }()
  1743. user := this.User
  1744. if user == nil {
  1745. br.Msg = "请重新登录"
  1746. br.Ret = 408
  1747. return
  1748. }
  1749. uid := user.UserId
  1750. articleId, _ := this.GetInt("ArticleId")
  1751. if articleId < 0 {
  1752. br.Msg = "参数错误"
  1753. br.ErrMsg = "参数错误"
  1754. return
  1755. }
  1756. resp := new(models.MinutesSummaryLetailRespV4)
  1757. //判断用户权限
  1758. hasPermission, err := services.GetUserhasPermission(user)
  1759. if err != nil {
  1760. br.Msg = "获取信息失败"
  1761. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1762. }
  1763. resp.HasPermission = hasPermission
  1764. if hasPermission != 1 {
  1765. br.Ret = 200
  1766. br.Success = true
  1767. br.Msg = "获取成功"
  1768. br.Data = resp
  1769. return
  1770. }
  1771. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1772. if err != nil {
  1773. br.Msg = "获取信息失败"
  1774. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1775. return
  1776. }
  1777. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1778. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1779. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1780. if err != nil {
  1781. br.Msg = "获取失败"
  1782. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1783. return
  1784. }
  1785. for k, v := range listFirst {
  1786. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1787. if err != nil && err.Error() != utils.ErrNoRow() {
  1788. br.Msg = "获取信息失败"
  1789. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1790. return
  1791. }
  1792. for k2, v2 := range listSecond {
  1793. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1794. if err != nil && err.Error() != utils.ErrNoRow() {
  1795. br.Msg = "获取信息失败"
  1796. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1797. return
  1798. }
  1799. if len(listThird) > 0 {
  1800. for k3, v3 := range listThird {
  1801. if v3.VideoUrl != "" {
  1802. listThird[k3].IsHaveVideo = true
  1803. }
  1804. if v3.ReportLink == "0" {
  1805. listThird[k3].ReportLink = ""
  1806. }
  1807. }
  1808. listSecond[k2].List = listThird
  1809. }
  1810. }
  1811. if len(listSecond) > 0 {
  1812. listFirst[k].List = listSecond
  1813. }
  1814. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1815. if v.Type == "CYDYJY" {
  1816. listFirst[k].ListName = "产业调研纪要"
  1817. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1818. } else if v.Type == "SSGS" {
  1819. listFirst[k].ListName = "上市公司调研纪要篇"
  1820. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1821. } else if v.Type == "YANX" {
  1822. listFirst[k].ListName = "买方研选纪要"
  1823. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1824. }
  1825. }
  1826. historyRecord := new(models.CygxReportHistoryRecord)
  1827. historyRecord.UserId = uid
  1828. historyRecord.ArticleId = articleId
  1829. historyRecord.CreateTime = time.Now()
  1830. historyRecord.Mobile = user.Mobile
  1831. historyRecord.Email = user.Email
  1832. historyRecord.CompanyId = user.CompanyId
  1833. historyRecord.CompanyName = user.CompanyName
  1834. historyRecord.ReportType = "szjyhz"
  1835. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1836. if err != nil && err.Error() != utils.ErrNoRow() {
  1837. br.Msg = "获取信息失败"
  1838. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1839. return
  1840. }
  1841. historyRecord.RealName = user.RealName
  1842. if sellerItem != nil {
  1843. historyRecord.SellerName = sellerItem.RealName
  1844. }
  1845. go models.AddCygxReportHistoryRecord(historyRecord)
  1846. resp.List = listFirst
  1847. resp.Detail = detail
  1848. br.Ret = 200
  1849. br.Success = true
  1850. br.Msg = "获取成功"
  1851. br.Data = resp
  1852. }
  1853. // @Title 上周纪要汇总内容详情
  1854. // @Description 获取上周纪要汇总内容详情接口
  1855. // @Param ArticleId query int true "报告ID"
  1856. // @Success 200 {object} models.MinutesSummaryLetailResp
  1857. // @router /minutesSummary/detail [get]
  1858. func (this *ReportController) MinutesDetail() {
  1859. br := new(models.BaseResponse).Init()
  1860. defer func() {
  1861. this.Data["json"] = br
  1862. this.ServeJSON()
  1863. }()
  1864. user := this.User
  1865. if user == nil {
  1866. br.Msg = "请重新登录"
  1867. br.Ret = 408
  1868. return
  1869. }
  1870. uid := user.UserId
  1871. articleId, _ := this.GetInt("ArticleId")
  1872. if articleId < 0 {
  1873. br.Msg = "参数错误"
  1874. br.ErrMsg = "参数错误"
  1875. return
  1876. }
  1877. resp := new(models.MinutesSummaryLetailResp)
  1878. //判断用户权限
  1879. hasPermission, err := services.GetUserhasPermission(user)
  1880. if err != nil {
  1881. br.Msg = "获取信息失败"
  1882. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1883. }
  1884. resp.HasPermission = hasPermission
  1885. if hasPermission != 1 {
  1886. br.Ret = 200
  1887. br.Success = true
  1888. br.Msg = "获取成功"
  1889. br.Data = resp
  1890. return
  1891. }
  1892. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1893. if err != nil {
  1894. br.Msg = "获取信息失败"
  1895. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1896. return
  1897. }
  1898. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1899. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1900. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  1901. if err != nil {
  1902. br.Msg = "获取失败"
  1903. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1904. return
  1905. }
  1906. for k, v := range listLog {
  1907. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  1908. if err != nil && err.Error() != utils.ErrNoRow() {
  1909. br.Msg = "获取信息失败"
  1910. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1911. return
  1912. }
  1913. if len(listSonLog) > 0 {
  1914. listLog[k].List = listSonLog
  1915. for k2, v2 := range listSonLog {
  1916. if v2.ReportLink == "0" {
  1917. listSonLog[k2].ReportLink = ""
  1918. }
  1919. }
  1920. }
  1921. }
  1922. historyRecord := new(models.CygxReportHistoryRecord)
  1923. historyRecord.UserId = uid
  1924. historyRecord.ArticleId = articleId
  1925. historyRecord.CreateTime = time.Now()
  1926. historyRecord.Mobile = user.Mobile
  1927. historyRecord.Email = user.Email
  1928. historyRecord.CompanyId = user.CompanyId
  1929. historyRecord.CompanyName = user.CompanyName
  1930. historyRecord.ReportType = "szjyhz"
  1931. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1932. if err != nil && err.Error() != utils.ErrNoRow() {
  1933. br.Msg = "获取信息失败"
  1934. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1935. return
  1936. }
  1937. historyRecord.RealName = user.RealName
  1938. if sellerItem != nil {
  1939. historyRecord.SellerName = sellerItem.RealName
  1940. }
  1941. go models.AddCygxReportHistoryRecord(historyRecord)
  1942. resp.List = listLog
  1943. resp.Detail = detail
  1944. br.Ret = 200
  1945. br.Success = true
  1946. br.Msg = "获取成功"
  1947. br.Data = resp
  1948. }
  1949. // @Title 获取路演精华详情
  1950. // @Description 获取路演精华详情接口
  1951. // @Param ArticleId query int true "报告ID"
  1952. // @Success 200 {object} models.RoadshowDetailResp
  1953. // @router /roadshowEssence/detail [get]
  1954. func (this *ReportController) RoadshowDetail() {
  1955. br := new(models.BaseResponse).Init()
  1956. defer func() {
  1957. this.Data["json"] = br
  1958. this.ServeJSON()
  1959. }()
  1960. user := this.User
  1961. if user == nil {
  1962. br.Msg = "请登录"
  1963. br.ErrMsg = "请登录,用户信息为空"
  1964. br.Ret = 408
  1965. return
  1966. }
  1967. uid := user.UserId
  1968. articleId, err := this.GetInt("ArticleId")
  1969. if articleId <= 0 {
  1970. br.Msg = "文章不存在"
  1971. br.ErrMsg = "文章不存在,文章ID错误"
  1972. return
  1973. }
  1974. detail := new(models.ReportDetailRoadshow)
  1975. hasPermission := 0
  1976. hasFree := 0
  1977. //判断是否已经申请过
  1978. applyCount, err := models.GetApplyRecordCount(uid)
  1979. if err != nil && err.Error() != utils.ErrNoRow() {
  1980. br.Msg = "获取信息失败"
  1981. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1982. return
  1983. }
  1984. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1985. if user.CompanyId > 1 {
  1986. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1987. if err != nil {
  1988. br.Msg = "获取信息失败"
  1989. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1990. return
  1991. }
  1992. detail, err = models.GetReportRoadshowDetailById(articleId)
  1993. if err != nil {
  1994. br.Msg = "获取信息失败"
  1995. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1996. return
  1997. }
  1998. detail.Body = html.UnescapeString(detail.Body)
  1999. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  2000. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  2001. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  2002. if detail.ReportLink == "0" {
  2003. detail.ReportLink = ""
  2004. }
  2005. if companyPermission == "" {
  2006. if applyCount > 0 {
  2007. hasPermission = 5
  2008. } else {
  2009. hasPermission = 2
  2010. }
  2011. hasFree = 2
  2012. goto Loop
  2013. } else {
  2014. hasFree = 1
  2015. var articlePermissionPermissionName string
  2016. articlePermissionPermissionName = detail.CategoryName
  2017. var hasPersion bool
  2018. slice := strings.Split(articlePermissionPermissionName, ",")
  2019. for _, v := range slice {
  2020. if strings.Contains(companyPermission, v) {
  2021. hasPersion = true
  2022. }
  2023. }
  2024. if hasPersion {
  2025. hasPermission = 1
  2026. historyRecord := new(models.CygxArticleHistoryRecord)
  2027. historyRecord.UserId = uid
  2028. historyRecord.ArticleId = articleId
  2029. historyRecord.CreateTime = time.Now()
  2030. historyRecord.Mobile = user.Mobile
  2031. historyRecord.Email = user.Email
  2032. historyRecord.CompanyId = user.CompanyId
  2033. historyRecord.CompanyName = user.CompanyName
  2034. go models.AddCygxArticleHistoryRecord(historyRecord)
  2035. } else { //无该行业权限
  2036. hasPermission = 3
  2037. }
  2038. if hasPermission == 1 {
  2039. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  2040. if !utils.Rc.IsExist(key) {
  2041. //新增浏览记录
  2042. record := new(models.CygxArticleViewRecord)
  2043. record.UserId = uid
  2044. record.ArticleId = articleId
  2045. record.CreateTime = time.Now()
  2046. record.Mobile = user.Mobile
  2047. record.Email = user.Email
  2048. record.CompanyId = user.CompanyId
  2049. record.CompanyName = user.CompanyName
  2050. go models.AddCygxArticleViewRecord(record)
  2051. utils.Rc.Put(key, 1, 5*time.Second)
  2052. models.ModifyReportLastViewTime(uid)
  2053. }
  2054. }
  2055. }
  2056. } else { //潜在客户
  2057. if applyCount > 0 {
  2058. hasPermission = 5
  2059. } else {
  2060. hasPermission = 4
  2061. }
  2062. }
  2063. Loop:
  2064. if hasPermission != 1 {
  2065. detail.Body = ""
  2066. detail.Abstract = ""
  2067. }
  2068. resp := new(models.RoadshowDetailResp)
  2069. resp.HasPermission = hasPermission
  2070. resp.HasFree = hasFree
  2071. resp.Detail = detail
  2072. br.Ret = 200
  2073. br.Success = true
  2074. br.Msg = "获取成功"
  2075. br.Data = resp
  2076. }
  2077. // @Title 产业文章列表接口
  2078. // @Description 获取产业文章列表接口
  2079. // @Param KeyWord query string true "搜索关键词"
  2080. // @Success 200 {object} models.CygxIndustrySearchList
  2081. // @router /industryAndArticle/list [get]
  2082. func (this *ReportController) IndustryAndArticleList() {
  2083. br := new(models.BaseResponse).Init()
  2084. defer func() {
  2085. this.Data["json"] = br
  2086. this.ServeJSON()
  2087. }()
  2088. user := this.User
  2089. if user == nil {
  2090. br.Msg = "请重新登录"
  2091. br.Ret = 408
  2092. return
  2093. }
  2094. uid := user.UserId
  2095. keyWord := this.GetString("KeyWord")
  2096. orderSrt := "update_time DESC"
  2097. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2098. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2099. if err != nil {
  2100. br.Msg = "获取信息失败"
  2101. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2102. return
  2103. }
  2104. for k, v := range list {
  2105. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2106. if err != nil {
  2107. br.Msg = "获取信息失败"
  2108. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2109. return
  2110. }
  2111. list[k].IndustrialSubjectList = industrialSubjectList
  2112. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2113. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2114. if err != nil {
  2115. br.Msg = "获取信息失败"
  2116. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2117. return
  2118. }
  2119. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2120. }
  2121. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2122. if err != nil {
  2123. br.Msg = "获取失败"
  2124. br.ErrMsg = "获取失败,Err:" + err.Error()
  2125. return
  2126. }
  2127. for k2, v2 := range artList {
  2128. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  2129. if err != nil {
  2130. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2131. br.ErrMsg = "获取失败,Err:" + err.Error()
  2132. return
  2133. }
  2134. var subjectNamesNew string
  2135. if len(subjectNames) > 0 {
  2136. slice := strings.Split(subjectNames, "/")
  2137. for k3, v3 := range slice {
  2138. if k3 < 4 {
  2139. subjectNamesNew += v3 + "/"
  2140. }
  2141. }
  2142. }
  2143. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  2144. if err != nil && err.Error() != utils.ErrNoRow() {
  2145. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2146. br.ErrMsg = "获取失败,Err:" + err.Error()
  2147. return
  2148. }
  2149. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2150. artList[k2].SubjectName = subjectNamesNew
  2151. if subjectNamesNew == "" {
  2152. artList[k2].IndustryName = industryName
  2153. } else {
  2154. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  2155. }
  2156. }
  2157. if keyWord != "" {
  2158. keyWordItem := new(models.CygxUserSearchKeyWord)
  2159. keyWordItem.UserId = user.UserId
  2160. keyWordItem.KeyWord = keyWord
  2161. keyWordItem.PageType = "ReortSearch"
  2162. keyWordItem.CreateTime = time.Now()
  2163. go models.AddUserSearchKeyWord(keyWordItem)
  2164. }
  2165. resp := new(models.CygxIndustrySearchList)
  2166. resp.ArtList = artList
  2167. resp.IndList = list
  2168. br.Ret = 200
  2169. br.Success = true
  2170. br.Msg = "获取成功"
  2171. br.Data = resp
  2172. }
  2173. // @Title 产业报告分类关联作者列表接口Pc端
  2174. // @Description 获取产业报告分类关联作者列表接口Pc端
  2175. // @Param ChartPermissionId query int true "分类ID"
  2176. // @Param KeyWord query string true "搜索关键词"
  2177. // @Param PageSize query int true "每页数据条数"
  2178. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2179. // @Success 200 {object} models.CygxArticleDepartmentListPc
  2180. // @router /industryListByDepartmentPc [get]
  2181. func (this *ReportController) IndustryListByDepartmentPc() {
  2182. br := new(models.BaseResponse).Init()
  2183. defer func() {
  2184. this.Data["json"] = br
  2185. this.ServeJSON()
  2186. }()
  2187. user := this.User
  2188. if user == nil {
  2189. br.Msg = "请重新登录"
  2190. br.Ret = 408
  2191. return
  2192. }
  2193. uid := user.UserId
  2194. pageSize, _ := this.GetInt("PageSize")
  2195. currentIndex, _ := this.GetInt("CurrentIndex")
  2196. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  2197. keyWord := this.GetString("KeyWord")
  2198. var startSize int
  2199. var condition string
  2200. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  2201. if pageSize <= 0 {
  2202. pageSize = utils.PageSize20
  2203. }
  2204. if currentIndex <= 0 {
  2205. currentIndex = 1
  2206. }
  2207. var articleIdGroup string
  2208. if keyWord != "" {
  2209. //获取标的关联的文章ID
  2210. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  2211. if err != nil {
  2212. br.Msg = "获取信息失败"
  2213. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2214. return
  2215. }
  2216. //获取产业关联的标的
  2217. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  2218. if err != nil {
  2219. br.Msg = "获取信息失败"
  2220. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  2221. return
  2222. }
  2223. if articleIdSub != "" && articleIdInd != "" {
  2224. articleIdGroup = articleIdSub + "," + articleIdInd
  2225. } else if articleIdSub != "" && articleIdInd == "" {
  2226. articleIdGroup = articleIdSub
  2227. } else if articleIdSub == "" && articleIdInd != "" {
  2228. articleIdGroup = articleIdInd
  2229. }
  2230. slice := strings.Split(keyWord, "/")
  2231. if len(slice) > 1 {
  2232. var subjectIds string
  2233. for _, v := range slice {
  2234. subjectId, err := models.GetcygxIndustrialSubjectByName(v)
  2235. if err != nil && err.Error() != utils.ErrNoRow() {
  2236. br.Msg = "获取信息失败"
  2237. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2238. return
  2239. }
  2240. if subjectId != "" {
  2241. subjectIds += subjectId + ","
  2242. }
  2243. }
  2244. subjectIds = strings.TrimRight(subjectIds, ",")
  2245. if len(subjectIds) > 0 {
  2246. articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
  2247. if err != nil {
  2248. br.Msg = "获取信息失败"
  2249. br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
  2250. return
  2251. }
  2252. if articleIdGroup != "" {
  2253. if articleBySub != "" {
  2254. articleIdGroup += "," + articleBySub
  2255. }
  2256. } else {
  2257. articleIdGroup = articleBySub
  2258. }
  2259. }
  2260. }
  2261. }
  2262. if articleIdGroup != "" {
  2263. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  2264. }
  2265. startSize = paging.StartIndex(currentIndex, pageSize)
  2266. total, err := models.GetArticleDepartmentCount(condition)
  2267. page := paging.GetPaging(currentIndex, pageSize, total)
  2268. resp := new(models.CygxArticleDepartmentListPc)
  2269. userType, _, err := services.GetUserType(user.CompanyId)
  2270. if err != nil {
  2271. br.Msg = "获取信息失败"
  2272. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  2273. return
  2274. }
  2275. if userType == 1 {
  2276. resp.Paging = page
  2277. br.Ret = 200
  2278. br.Success = true
  2279. br.Msg = "获取成功"
  2280. br.Data = resp
  2281. return
  2282. }
  2283. resp.HaveResearch = true
  2284. //获取作者信息,并排序
  2285. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  2286. if err != nil {
  2287. br.Msg = "获取信息失败"
  2288. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2289. return
  2290. }
  2291. for k, v := range list {
  2292. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  2293. if err != nil {
  2294. br.Msg = "获取信息失败"
  2295. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2296. return
  2297. }
  2298. for k2, v2 := range artList {
  2299. if artList[k2].IsReport == "1" {
  2300. artList[k2].Title = v2.Title
  2301. } else {
  2302. artList[k2].Title = v2.Title
  2303. }
  2304. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2305. }
  2306. list[k].List = artList
  2307. if v.FollowNum > 0 {
  2308. list[k].IsMyFollow = true
  2309. }
  2310. }
  2311. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  2312. if err != nil {
  2313. br.Msg = "获取信息失败"
  2314. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2315. return
  2316. }
  2317. if len(listnNew) > 0 {
  2318. for _, v := range listnNew {
  2319. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  2320. Management := new(models.IndustrialManagementIdInt)
  2321. if firstStr == 0 {
  2322. Management.IndustryName = v.IndustryName
  2323. } else {
  2324. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  2325. if err != nil {
  2326. br.Msg = "获取信息失败"
  2327. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  2328. return
  2329. }
  2330. var subjectNamesNew string
  2331. for _, v1 := range listSub {
  2332. subjectNamesNew += v1.SubjectName + "/"
  2333. }
  2334. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2335. Management.IndustryName = subjectNamesNew
  2336. }
  2337. Management.IndustrialManagementId = v.IndustrialManagementId
  2338. Management.ArticleId = v.ArticleId
  2339. resp.ListnNew = append(resp.ListnNew, Management)
  2340. }
  2341. }
  2342. resp.List = list
  2343. resp.Paging = page
  2344. br.Ret = 200
  2345. br.Success = true
  2346. br.Msg = "获取成功"
  2347. br.Data = resp
  2348. }
  2349. // @Title 产业文章列表接口Pc端
  2350. // @Description 获取产业文章列表接口Pc端
  2351. // @Param KeyWord query string true "搜索关键词"
  2352. // @Success 200 {object} models.CygxIndustrySearchListPc
  2353. // @router /industryAndArticle/listPc [get]
  2354. func (this *ReportController) IndustryAndArticleListPc() {
  2355. br := new(models.BaseResponse).Init()
  2356. defer func() {
  2357. this.Data["json"] = br
  2358. this.ServeJSON()
  2359. }()
  2360. user := this.User
  2361. if user == nil {
  2362. br.Msg = "请重新登录"
  2363. br.Ret = 408
  2364. return
  2365. }
  2366. uid := user.UserId
  2367. keyWord := this.GetString("KeyWord")
  2368. resp := new(models.CygxIndustrySearchListPc)
  2369. orderSrt := "update_time DESC"
  2370. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2371. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2372. if err != nil {
  2373. br.Msg = "获取信息失败"
  2374. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2375. return
  2376. }
  2377. for k, v := range list {
  2378. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2379. if err != nil {
  2380. br.Msg = "获取信息失败"
  2381. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2382. return
  2383. }
  2384. list[k].IndustrialSubjectList = industrialSubjectList
  2385. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2386. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2387. if err != nil {
  2388. br.Msg = "获取信息失败"
  2389. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2390. return
  2391. }
  2392. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2393. }
  2394. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2395. if err != nil {
  2396. br.Msg = "获取失败"
  2397. br.ErrMsg = "获取失败,Err:" + err.Error()
  2398. return
  2399. }
  2400. if len(artList) > 0 {
  2401. var articleIds string
  2402. for _, v := range artList {
  2403. articleIds += strconv.Itoa(v.ArticleId) + ","
  2404. }
  2405. articleIds = strings.TrimRight(articleIds, ",")
  2406. if articleIds != "" {
  2407. condition = ` AND a.article_id IN (` + articleIds + `)`
  2408. DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
  2409. if err != nil {
  2410. br.Msg = "获取信息失败"
  2411. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2412. return
  2413. }
  2414. for k, v := range DepartmentList {
  2415. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
  2416. if err != nil {
  2417. br.Msg = "获取信息失败"
  2418. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2419. return
  2420. }
  2421. for k2, v2 := range artList {
  2422. if artList[k2].IsReport == "1" {
  2423. artList[k2].Title = v2.Title
  2424. } else {
  2425. artList[k2].Title = v2.Title
  2426. }
  2427. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2428. }
  2429. DepartmentList[k].List = artList
  2430. if v.FollowNum > 0 {
  2431. DepartmentList[k].IsMyFollow = true
  2432. }
  2433. }
  2434. resp.DepartmentList = DepartmentList
  2435. }
  2436. }
  2437. if keyWord != "" {
  2438. keyWordItem := new(models.CygxUserSearchKeyWord)
  2439. keyWordItem.UserId = user.UserId
  2440. keyWordItem.KeyWord = keyWord
  2441. keyWordItem.PageType = "ReortSearch"
  2442. keyWordItem.CreateTime = time.Now()
  2443. go models.AddUserSearchKeyWord(keyWordItem)
  2444. }
  2445. resp.IndList = list
  2446. br.Ret = 200
  2447. br.Success = true
  2448. br.Msg = "获取成功"
  2449. br.Data = resp
  2450. }
  2451. // @Title 报告搜索
  2452. // @Description 报告搜索接口
  2453. // @Param KeyWord query string true "搜索关键词"
  2454. // @Success 200 {object} models.ReoprtSearchResp
  2455. // @router /searchReport [get]
  2456. func (this *ReportController) SearchReport() {
  2457. br := new(models.BaseResponse).Init()
  2458. defer func() {
  2459. this.Data["json"] = br
  2460. this.ServeJSON()
  2461. }()
  2462. user := this.User
  2463. if user == nil {
  2464. br.Msg = "请重新登录"
  2465. br.Ret = 408
  2466. return
  2467. }
  2468. keyWord := this.GetString("KeyWord")
  2469. var condition string
  2470. var sqlGroup string
  2471. //匹配报告标题、
  2472. 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 `
  2473. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2474. //对应产业名称、标的名称。
  2475. listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2476. if err != nil {
  2477. br.Msg = "获取信息失败"
  2478. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2479. return
  2480. }
  2481. for k, v := range listYx {
  2482. listYx[k].Source = 2
  2483. if v.MyCollectNum > 0 {
  2484. listYx[k].IsCollect = true
  2485. }
  2486. }
  2487. listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2488. if err != nil {
  2489. br.Msg = "获取信息失败"
  2490. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2491. return
  2492. }
  2493. for k, v := range listHz {
  2494. listHz[k].Source = 1
  2495. if v.MyCollectNum > 0 {
  2496. listHz[k].IsCollect = true
  2497. }
  2498. }
  2499. if keyWord != "" {
  2500. keyWordItem := new(models.CygxUserSearchKeyWord)
  2501. keyWordItem.UserId = user.UserId
  2502. keyWordItem.KeyWord = keyWord
  2503. keyWordItem.PageType = "ReortSearch"
  2504. keyWordItem.CreateTime = time.Now()
  2505. go models.AddUserSearchKeyWord(keyWordItem)
  2506. //go services.AddUserSearchLog(user, keyWord, 5)
  2507. }
  2508. if len(listYx) == 0 {
  2509. listYx = make([]*models.ArticleCollectionResp, 0)
  2510. }
  2511. if len(listHz) == 0 {
  2512. listHz = make([]*models.ArticleCollectionResp, 0)
  2513. }
  2514. resp := new(models.ReoprtSearchResp)
  2515. resp.ListYx = listYx
  2516. resp.ListHz = listHz
  2517. br.Ret = 200
  2518. br.Success = true
  2519. br.Msg = "获取成功"
  2520. br.Data = resp
  2521. }
  2522. // @Title 资源包搜索
  2523. // @Description 资源包搜索接口
  2524. // @Param KeyWord query string true "搜索关键词"
  2525. // @Success 200 {object} models.SearchResourceResp
  2526. // @router /searchResource [get]
  2527. func (this *ReportController) SearchResource() {
  2528. br := new(models.BaseResponse).Init()
  2529. defer func() {
  2530. this.Data["json"] = br
  2531. this.ServeJSON()
  2532. }()
  2533. user := this.User
  2534. if user == nil {
  2535. br.Msg = "请重新登录"
  2536. br.Ret = 408
  2537. return
  2538. }
  2539. uid := user.UserId
  2540. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2541. if err != nil {
  2542. br.Msg = "获取失败"
  2543. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2544. return
  2545. }
  2546. fllowMap := make(map[int]int)
  2547. if len(fllowList) > 0 {
  2548. for _, v := range fllowList {
  2549. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2550. }
  2551. }
  2552. keyWord := this.GetString("KeyWord")
  2553. var condition string
  2554. var conditionOr string
  2555. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2556. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2557. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2558. listHz, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  2559. if err != nil {
  2560. br.Msg = "获取信息失败"
  2561. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2562. return
  2563. }
  2564. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2565. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2566. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2567. listYx, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  2568. if err != nil {
  2569. br.Msg = "获取信息失败"
  2570. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2571. return
  2572. }
  2573. //合并产业关联的标的
  2574. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2575. if err != nil {
  2576. br.Msg = "获取信息失败"
  2577. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2578. return
  2579. }
  2580. industrialIdArr := make([]int, 0)
  2581. for k, v := range listHz {
  2582. listHz[k].Source = 1
  2583. if fllowMap[v.IndustrialManagementId] > 0 {
  2584. listHz[k].IsFollw = true
  2585. }
  2586. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2587. }
  2588. for k, v := range listYx {
  2589. listYx[k].Source = 2
  2590. if fllowMap[v.IndustrialManagementId] > 0 {
  2591. listYx[k].IsFollw = true
  2592. }
  2593. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2594. }
  2595. if len(industrialIdArr) > 0 {
  2596. //合并产业关联的标的
  2597. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2598. if err != nil {
  2599. br.Msg = "获取信息失败"
  2600. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2601. return
  2602. }
  2603. mapIndustrial := make(map[string]int)
  2604. for _, v := range listSubjcet {
  2605. for k2, v2 := range listYx {
  2606. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2607. listYx[k2].IndustrialSubjectList = append(listYx[k2].IndustrialSubjectList, v)
  2608. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2609. }
  2610. }
  2611. for k2, v2 := range listHz {
  2612. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2613. listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
  2614. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2615. }
  2616. }
  2617. }
  2618. }
  2619. if keyWord != "" {
  2620. keyWordItem := new(models.CygxUserSearchKeyWord)
  2621. keyWordItem.UserId = user.UserId
  2622. keyWordItem.KeyWord = keyWord
  2623. keyWordItem.PageType = "ReortSearch"
  2624. keyWordItem.CreateTime = time.Now()
  2625. go models.AddUserSearchKeyWord(keyWordItem)
  2626. }
  2627. resp := new(models.SearchResourceResp)
  2628. if len(listYx) == 0 {
  2629. listYx = make([]*models.IndustrialManagementHotResp, 0)
  2630. }
  2631. if len(listHz) == 0 {
  2632. listHz = make([]*models.IndustrialManagementHotResp, 0)
  2633. }
  2634. resp.ListYx = listYx
  2635. resp.ListHz = listHz
  2636. br.Ret = 200
  2637. br.Success = true
  2638. br.Msg = "获取成功"
  2639. br.Data = resp
  2640. }
  2641. // @Title 报告搜索、资源包搜索接口
  2642. // @Description 报告搜索、资源包搜索接口接口
  2643. // @Param KeyWord query string true "搜索关键词"
  2644. // @Param PageSize query int true "每页数据条数"
  2645. // @Success 200 {object} models.SearchReportAndResourceResp
  2646. // @router /searchReportAndResource [get]
  2647. func (this *ReportController) SearchReportAndResource() {
  2648. br := new(models.BaseResponse).Init()
  2649. defer func() {
  2650. this.Data["json"] = br
  2651. this.ServeJSON()
  2652. }()
  2653. user := this.User
  2654. if user == nil {
  2655. br.Msg = "请重新登录"
  2656. br.Ret = 408
  2657. return
  2658. }
  2659. uid := user.UserId
  2660. keyWord := this.GetString("KeyWord")
  2661. pageSize, _ := this.GetInt("PageSize")
  2662. var condition string
  2663. var sqlGroup string
  2664. //匹配报告标题、
  2665. 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 `
  2666. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2667. if pageSize > 0 {
  2668. sqlGroup += ` LIMIT 5 `
  2669. } else {
  2670. sqlGroup += ` LIMIT 100 `
  2671. }
  2672. ListYxReport, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+condition+sqlGroup, user.UserId)
  2673. if err != nil {
  2674. br.Msg = "获取信息失败"
  2675. br.ErrMsg = "获取研选文章列表失败,Err:" + err.Error()
  2676. return
  2677. }
  2678. ListHzReport, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+condition+sqlGroup, user.UserId)
  2679. if err != nil {
  2680. br.Msg = "获取信息失败"
  2681. br.ErrMsg = "获取弘则报告文章列表失败,Err:" + err.Error()
  2682. return
  2683. }
  2684. keyWordArr, err := services.GetIndustryMapNameSliceV3(keyWord)
  2685. if err != nil {
  2686. br.Msg = "获取失败"
  2687. br.ErrMsg = "获取分词失败,GetIndustryMapNameSliceV3 Err: " + err.Error()
  2688. return
  2689. }
  2690. keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  2691. var keyWordIk string
  2692. if len(keyWordArr) > 1 {
  2693. keyWordIk = services.KeyWordArrSqlRegexp(keyWordArr)
  2694. var conditionIk string
  2695. var sqlGroupIk string
  2696. conditionIk = `AND ( a.title REGEXP '` + keyWordIk + `' OR a.annotation REGEXP '` + keyWordIk + `' OR a.abstract REGEXP '` + keyWordIk + `') AND a.publish_status = 1 `
  2697. sqlGroupIk = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2698. if pageSize > 0 {
  2699. sqlGroupIk += ` LIMIT 5 `
  2700. } else {
  2701. sqlGroupIk += ` LIMIT 20 `
  2702. }
  2703. //研选的联想词列表
  2704. ListYxReportIk, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+conditionIk+sqlGroupIk, user.UserId)
  2705. if err != nil && err.Error() != utils.ErrNoRow() {
  2706. br.Msg = "获取信息失败"
  2707. br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2708. return
  2709. }
  2710. if len(ListYxReportIk) > 0 {
  2711. for _, v := range ListYxReportIk {
  2712. ListYxReport = append(ListYxReport, v)
  2713. }
  2714. }
  2715. //弘则的联想词列表
  2716. ListHzReportIk, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+conditionIk+sqlGroupIk, user.UserId)
  2717. if err != nil && err.Error() != utils.ErrNoRow() {
  2718. br.Msg = "获取信息失败"
  2719. br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2720. return
  2721. }
  2722. if len(ListHzReportIk) > 0 {
  2723. for _, v := range ListHzReportIk {
  2724. ListHzReport = append(ListHzReport, v)
  2725. }
  2726. }
  2727. }
  2728. for k, v := range ListHzReport {
  2729. ListHzReport[k].Source = 1
  2730. if v.MyCollectNum > 0 {
  2731. ListHzReport[k].IsCollect = true
  2732. }
  2733. }
  2734. for k, v := range ListYxReport {
  2735. ListYxReport[k].Source = 2
  2736. if v.MyCollectNum > 0 {
  2737. ListYxReport[k].IsCollect = true
  2738. }
  2739. }
  2740. var articleIds string
  2741. for _, v := range ListHzReport {
  2742. articleIds += strconv.Itoa(v.ArticleId) + ","
  2743. }
  2744. for _, v := range ListYxReport {
  2745. articleIds += strconv.Itoa(v.ArticleId) + ","
  2746. }
  2747. articleIds = strings.TrimRight(articleIds, ",")
  2748. silcearticleIds := strings.Split(articleIds, ",")
  2749. var parsindustrial []interface{}
  2750. parsindustrial = make([]interface{}, 0)
  2751. articleIdList := make([]string, 0)
  2752. for _, v := range silcearticleIds {
  2753. articleIdList = append(articleIdList, v)
  2754. }
  2755. conditionindustrial := ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` ) `
  2756. parsindustrial = append(parsindustrial, articleIdList)
  2757. industrialList, err := models.GetIndustrialListByarticleId(parsindustrial, conditionindustrial)
  2758. if err != nil {
  2759. return
  2760. }
  2761. industrialMap := make(map[int][]*models.IndustrialManagementResp)
  2762. if len(industrialList) > 0 {
  2763. for _, v := range industrialList {
  2764. item := new(models.IndustrialManagementResp)
  2765. //item.ArticleId = v.ArticleId
  2766. item.IndustrialManagementId = v.IndustrialManagementId
  2767. item.IndustryName = v.IndustryName
  2768. item.ChartPermissionId = v.ChartPermissionId
  2769. industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
  2770. }
  2771. }
  2772. for k, v := range ListHzReport {
  2773. if len(industrialMap[v.ArticleId]) > 0 {
  2774. ListHzReport[k].List = industrialMap[v.ArticleId]
  2775. } else {
  2776. ListHzReport[k].List = make([]*models.IndustrialManagementResp, 0)
  2777. }
  2778. }
  2779. for k, v := range ListYxReport {
  2780. if len(industrialMap[v.ArticleId]) > 0 {
  2781. ListYxReport[k].List = industrialMap[v.ArticleId]
  2782. } else {
  2783. ListYxReport[k].List = make([]*models.IndustrialManagementResp, 0)
  2784. }
  2785. }
  2786. //获取文章关联的产业
  2787. if len(ListYxReport) == 0 {
  2788. ListYxReport = make([]*models.ArticleCollectionResp, 0)
  2789. }
  2790. if len(ListHzReport) == 0 {
  2791. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  2792. }
  2793. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2794. if err != nil {
  2795. br.Msg = "获取失败"
  2796. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2797. return
  2798. }
  2799. fllowMap := make(map[int]int)
  2800. if len(fllowList) > 0 {
  2801. for _, v := range fllowList {
  2802. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2803. }
  2804. }
  2805. condition = ` AND a.publish_status = 1 AND a.article_type_id NOT IN (` + utils.YAN_XUAN_ARTICLE_TYPE_IDS + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  2806. listHzResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  2807. if err != nil {
  2808. br.Msg = "获取信息失败"
  2809. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2810. return
  2811. }
  2812. condition = ` AND a.publish_status = 1 AND a.article_type_id IN (` + utils.YAN_XUAN_ARTICLE_TYPE_IDS + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  2813. listYxResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  2814. if err != nil {
  2815. br.Msg = "获取信息失败"
  2816. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2817. return
  2818. }
  2819. //合并产业关联的标的
  2820. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2821. if err != nil {
  2822. br.Msg = "获取信息失败"
  2823. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2824. return
  2825. }
  2826. industrialIdArr := make([]int, 0)
  2827. nowTime := time.Now().Local()
  2828. threeMonBefore := nowTime.AddDate(0, -3, 0)
  2829. mapHot := make(map[string]int)
  2830. hotCondition := ` ORDER BY sum_num DESC `
  2831. listHot, err := models.GetThemeHeatList(user.UserId, hotCondition, 0, 3)
  2832. if err != nil {
  2833. br.Msg = "获取信息失败"
  2834. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2835. return
  2836. }
  2837. for _, v := range listHot {
  2838. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2839. mapHot[v.IndustryName] = v.IndustrialManagementId
  2840. }
  2841. orderSrt := "man.recommended_index DESC,update_time DESC"
  2842. for k, v := range listHzResource {
  2843. // 关联报告发布时间均在3个月内则标记New
  2844. if v.MinReportTime != "" {
  2845. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  2846. if e != nil {
  2847. err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  2848. return
  2849. }
  2850. if t.After(threeMonBefore) {
  2851. listHzResource[k].IsNew = true
  2852. }
  2853. }
  2854. //弘则资源包不展示hot标签
  2855. //if mapHot[v.IndustryName] > 0 {
  2856. // listHzResource[k].IsHot = true
  2857. //}
  2858. listHzResource[k].Source = 1
  2859. if fllowMap[v.IndustrialManagementId] > 0 {
  2860. listHzResource[k].IsFollw = true
  2861. }
  2862. industrialIdSlice := make([]int, 0)
  2863. articleIdArr := make([]int, 0)
  2864. industrialIdSlice = append(industrialIdSlice, v.IndustrialManagementId)
  2865. listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdSlice)
  2866. if err != nil && err.Error() != utils.ErrNoRow() {
  2867. return
  2868. }
  2869. for _, v := range listUpdateTime {
  2870. articleIdArr = append(articleIdArr, v.ArticleId)
  2871. }
  2872. if err != nil {
  2873. return
  2874. }
  2875. mapHistroyArticleId := make(map[int]int)
  2876. if user.UserId > 0 {
  2877. listArticleHistory, e := models.GetUserToArticleHistory(user.UserId, articleIdArr)
  2878. if e != nil && e.Error() != utils.ErrNoRow() {
  2879. err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  2880. return
  2881. }
  2882. for _, v := range listArticleHistory {
  2883. mapHistroyArticleId[v.ArticleId] = v.ArticleId
  2884. }
  2885. }
  2886. condition2 := ` AND man.industry_name LIKE '%` + keyWord + `%' `
  2887. list, err := models.GetIndustrialManagementAll(uid, condition2, orderSrt, 0, 20)
  2888. if err != nil {
  2889. br.Msg = "获取信息失败"
  2890. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2891. return
  2892. }
  2893. mapUPdateTime := make(map[int]string)
  2894. //获取这些产业下最新更新的文章
  2895. //时间线的更新时间
  2896. // maptimelineUPdateTime := make(map[int]string)
  2897. listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
  2898. if err != nil && err.Error() != utils.ErrNoRow() {
  2899. return
  2900. }
  2901. for _, v := range listtimelinePublishdate {
  2902. if mapUPdateTime[v.IndustrialManagementId] != "" {
  2903. if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  2904. mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
  2905. }
  2906. }
  2907. }
  2908. //mapHistroyArticleId := make(map[int]int)
  2909. //if userId > 0 {
  2910. // listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
  2911. // if e != nil && e.Error() != utils.ErrNoRow() {
  2912. // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  2913. // return
  2914. // }
  2915. // for _, v := range listArticleHistory {
  2916. // mapHistroyArticleId[v.ArticleId] = v.ArticleId
  2917. // }
  2918. //}
  2919. var industrialIds string
  2920. for _, id := range industrialIdArr {
  2921. industrialIds += strconv.Itoa(id) + ","
  2922. }
  2923. industrialIds = strings.TrimRight(industrialIds, ",")
  2924. articleList, err := models.GetReportIndustrialReadNumList(user.UserId, industrialIds, user.CreatedTime)
  2925. mapHistroyindustrialId := make(map[int]int)
  2926. for _, v := range articleList {
  2927. mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
  2928. }
  2929. //nowTime := time.Now().Local()
  2930. //threeMonBefore := nowTime.AddDate(0, -3, 0)
  2931. //查询用户今天是否看过时间线
  2932. //haveMorningMeeting := false
  2933. //var morningMeetingTime string
  2934. recrodList, err := models.GetTimeLineRecordAllCount(user.UserId, time.Now().Format(utils.FormatDate))
  2935. if err != nil {
  2936. return
  2937. }
  2938. var industrialManagementIdstr string
  2939. industrialIdMap := make(map[string]time.Time)
  2940. for _, v := range recrodList {
  2941. industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
  2942. if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok{
  2943. if createTime.Before(v.CreateTime) {
  2944. industrialIdMap[industrialManagementIdstr] = v.CreateTime
  2945. }
  2946. }else {
  2947. industrialIdMap[industrialManagementIdstr] = v.CreateTime
  2948. }
  2949. }
  2950. mmList, err := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
  2951. if err != nil {
  2952. return
  2953. }
  2954. morningMeetingTimeMap := make(map[int]time.Time)
  2955. for _, v := range mmList {
  2956. morningMeetingTimeMap[v.IndustryId] = v.CreateTime
  2957. }
  2958. timeLineRedMap := make(map[int]bool, 0)
  2959. for _, industrialId := range industrialIdArr {
  2960. if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok{
  2961. if createTime.Before(morningMeetingTimeMap[industrialId]) {
  2962. timeLineRedMap[industrialId] = true
  2963. }
  2964. }
  2965. }
  2966. for k, v := range list {
  2967. list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  2968. if user.UserId > 0 {
  2969. //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  2970. if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  2971. if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  2972. list[k].IsRed = true
  2973. }
  2974. }
  2975. } else {
  2976. if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  2977. list[k].IsRed = true
  2978. }
  2979. list[k].IsFollow = 0
  2980. }
  2981. list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  2982. if user.UserId > 0 {
  2983. //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  2984. if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  2985. if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  2986. list[k].IsRed = true
  2987. }
  2988. }
  2989. } else {
  2990. if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  2991. list[k].IsRed = true
  2992. }
  2993. list[k].IsFollow = 0
  2994. }
  2995. }
  2996. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2997. }
  2998. for k, v := range listYxResource {
  2999. // 关联报告发布时间均在3个月内则标记New
  3000. if v.MinReportTime != "" {
  3001. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3002. if e != nil {
  3003. err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3004. return
  3005. }
  3006. if t.After(threeMonBefore) {
  3007. listYxResource[k].IsNew = true
  3008. }
  3009. }
  3010. if mapHot[v.IndustryName] > 0 {
  3011. listYxResource[k].IsHot = true
  3012. }
  3013. listYxResource[k].Source = 2
  3014. if fllowMap[v.IndustrialManagementId] > 0 {
  3015. listYxResource[k].IsFollw = true
  3016. }
  3017. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3018. }
  3019. if len(industrialIdArr) > 0 {
  3020. //查询产业视频
  3021. industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
  3022. // 获取默认图配置
  3023. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  3024. if e != nil {
  3025. br.Msg = "获取视频默认配置图失败"
  3026. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  3027. return
  3028. }
  3029. videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialIdArr)
  3030. if err != nil {
  3031. br.Msg = "产业视频列表失败"
  3032. br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
  3033. return
  3034. }
  3035. for _, v := range videoList {
  3036. tmp := &models.MicroVideoSimpleInfo{
  3037. Id: v.VideoId,
  3038. Title: "5min逻辑【" + v.IndustryName + "】解析",
  3039. ResourceUrl: v.VideoUrl,
  3040. BackgroundImg: v.ImgUrl,
  3041. PlaySeconds: v.VideoDuration,
  3042. DetailImgUrl: v.DetailImgUrl,
  3043. ChartPermissionName: v.ChartPermissionName,
  3044. ChartPermissionId: v.ChartPermissionId,
  3045. }
  3046. if tmp.BackgroundImg == "" {
  3047. tmp.BackgroundImg = videoMap[v.ChartPermissionId]
  3048. }
  3049. industrialVideoMap[v.IndustryId] = tmp
  3050. }
  3051. //查询权限
  3052. // 用户权限
  3053. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  3054. if e != nil {
  3055. br.Msg = "获取失败"
  3056. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  3057. return
  3058. }
  3059. for k, v := range listHzResource {
  3060. //展示产业视频
  3061. if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
  3062. au := new(models.UserPermissionAuthInfo)
  3063. au.SellerName = authInfo.SellerName
  3064. au.SellerMobile = authInfo.SellerMobile
  3065. au.HasPermission = authInfo.HasPermission
  3066. au.OperationMode = authInfo.OperationMode
  3067. if au.HasPermission == 1 {
  3068. // 非宏观权限进一步判断是否有权限
  3069. if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  3070. au.HasPermission = 2
  3071. }
  3072. }
  3073. // 无权限的弹框提示
  3074. if au.HasPermission != 1 {
  3075. if au.OperationMode == services.UserPermissionOperationModeCall {
  3076. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  3077. } else {
  3078. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  3079. }
  3080. video.ResourceUrl = ""
  3081. }
  3082. listHzResource[k].AuthInfo = au
  3083. listHzResource[k].IndustryVideo = video
  3084. }
  3085. }
  3086. //合并产业关联的标的
  3087. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  3088. if err != nil {
  3089. br.Msg = "获取信息失败"
  3090. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3091. return
  3092. }
  3093. //严选的产业只关联研选下面的标的
  3094. var yxcondition string
  3095. var yxPer []interface{}
  3096. yxcondition = ` AND ag.article_id >= ?`
  3097. yxPer = append(yxPer, utils.SummaryArticleId)
  3098. listYxAticleSubject, err := models.GetSubjectArticleGroupManagementList(yxcondition, yxPer)
  3099. if err != nil && err.Error() != utils.ErrNoRow() {
  3100. br.Msg = "获取信息失败"
  3101. br.ErrMsg = "获取研选报告关联的标的信息失败,GetSubjectArticleGroupManagementListErr:" + err.Error()
  3102. return
  3103. }
  3104. mapYxSubject := make(map[int]int)
  3105. for _, v := range listYxAticleSubject {
  3106. mapYxSubject[v.IndustrialSubjectId] = v.IndustrialSubjectId
  3107. }
  3108. mapIndustrial := make(map[string]int)
  3109. for _, v := range listSubjcet {
  3110. for k2, v2 := range listYxResource {
  3111. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 && mapYxSubject[v.IndustrialSubjectId] > 0 {
  3112. listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
  3113. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  3114. }
  3115. }
  3116. for k2, v2 := range listHzResource {
  3117. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  3118. listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
  3119. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  3120. }
  3121. }
  3122. }
  3123. }
  3124. resp := new(models.SearchReportAndResourceResp)
  3125. if len(listYxResource) == 0 {
  3126. listYxResource = make([]*models.IndustrialManagementHotResp, 0)
  3127. }
  3128. if len(listHzResource) == 0 {
  3129. listHzResource = make([]*models.IndustrialManagementHotResp, 0)
  3130. }
  3131. if keyWord != "" {
  3132. keyWordItem := new(models.CygxUserSearchKeyWord)
  3133. keyWordItem.UserId = user.UserId
  3134. keyWordItem.KeyWord = keyWord
  3135. keyWordItem.PageType = "ReortSearch"
  3136. keyWordItem.CreateTime = time.Now()
  3137. go models.AddUserSearchKeyWord(keyWordItem)
  3138. //go services.AddUserSearchLog(user, keyWord, 5)
  3139. }
  3140. resp.ListHzResource = listHzResource
  3141. resp.ListYxResource = listYxResource
  3142. resp.ListYxReport = ListYxReport
  3143. resp.ListHzReport = ListHzReport
  3144. br.Ret = 200
  3145. br.Success = true
  3146. br.Msg = "获取成功"
  3147. br.Data = resp
  3148. }
  3149. // @Title 产业报告公司列表
  3150. // @Description 获取产业报告公司列表接口
  3151. // @Param ChartPermissionId query int true "行业id"
  3152. // @Success 200 {object} models.IndustrialManagementList
  3153. // @router /home/stockName [get]
  3154. func (this *ReportController) StockNameList() {
  3155. br := new(models.BaseResponse).Init()
  3156. defer func() {
  3157. this.Data["json"] = br
  3158. this.ServeJSON()
  3159. }()
  3160. user := this.User
  3161. if user == nil {
  3162. br.Msg = "请重新登录"
  3163. br.Ret = 408
  3164. return
  3165. }
  3166. //uid := user.UserId
  3167. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  3168. list, err := models.GetSummaryArticle(chartPermissionId)
  3169. if err != nil {
  3170. br.Msg = "获取综述报告公司名称失败"
  3171. br.ErrMsg = "获取综述报告公司名称失败,Err:" + err.Error()
  3172. return
  3173. }
  3174. var respList []*models.SummaryArticleStock
  3175. for _, item := range list {
  3176. sliceSubjects := strings.Split(item.Stock, "/")
  3177. if len(sliceSubjects) > 0 {
  3178. for i, vSubject := range sliceSubjects {
  3179. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  3180. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  3181. subject := sliceXiahuaxian[0]
  3182. if i > 0 {
  3183. newItem := models.SummaryArticleStock{
  3184. Id: item.Id,
  3185. ArticleId: item.ArticleId,
  3186. Stock: subject,
  3187. }
  3188. respList = append(respList, &newItem)
  3189. } else {
  3190. item.Stock = subject
  3191. respList = append(respList, item)
  3192. }
  3193. }
  3194. }
  3195. //index := strings.Index(item.Stock, "(")
  3196. //item.Stock = item.Stock[:index]
  3197. //if strings.Contains(item.Stock, "-B"){
  3198. // item.Stock = strings.Replace(item.Stock, "-B", "", -1)
  3199. //}
  3200. //if strings.Contains(item.Stock, "-W"){
  3201. // item.Stock = strings.Replace(item.Stock, "-W", "", -1)
  3202. //}
  3203. }
  3204. resp := new(models.SummaryArticleStockResp)
  3205. resp.List = respList
  3206. br.Ret = 200
  3207. br.Success = true
  3208. br.Msg = "获取成功"
  3209. br.Data = resp
  3210. }
  3211. // @Title 文章留言接口
  3212. // @Description 文章留言接口
  3213. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  3214. // @Success 200 {object} models.TacticsListResp
  3215. // @router /commentAdd [post]
  3216. func (this *ReportController) CommentAdd() {
  3217. br := new(models.BaseResponse).Init()
  3218. defer func() {
  3219. this.Data["json"] = br
  3220. this.ServeJSON()
  3221. }()
  3222. user := this.User
  3223. if user == nil {
  3224. br.Msg = "请重新登录"
  3225. br.Ret = 408
  3226. return
  3227. }
  3228. var req models.AddCygxArticleCommentReq
  3229. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3230. if err != nil {
  3231. br.Msg = "参数解析异常!"
  3232. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3233. return
  3234. }
  3235. if req.ArticleId <= 0 {
  3236. br.Msg = "文章不存在"
  3237. br.ErrMsg = "文章不存在,文章ID错误"
  3238. return
  3239. }
  3240. if req.Content == "" {
  3241. br.Msg = "建议内容不可为空"
  3242. return
  3243. }
  3244. content := req.Content
  3245. itemToken, err := services.WxGetToken()
  3246. if err != nil {
  3247. br.Msg = "GetWxAccessToken Err:" + err.Error()
  3248. return
  3249. }
  3250. if itemToken.AccessToken == "" {
  3251. br.Msg = "accessToken is empty"
  3252. return
  3253. }
  3254. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  3255. if err != nil {
  3256. br.Msg = "内容校验失败!"
  3257. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  3258. return
  3259. }
  3260. if commerr.ErrCode != 0 {
  3261. br.Msg = "内容违规,请重新提交!"
  3262. br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  3263. return
  3264. }
  3265. articleId := req.ArticleId
  3266. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  3267. if articleInfo == nil {
  3268. br.Msg = "操作失败"
  3269. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3270. return
  3271. }
  3272. if errInfo != nil {
  3273. br.Msg = "操作失败"
  3274. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3275. return
  3276. }
  3277. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  3278. if err != nil {
  3279. br.Msg = "提交失败!"
  3280. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3281. return
  3282. }
  3283. if companyDetail == nil {
  3284. br.Msg = "提交失败!"
  3285. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  3286. return
  3287. }
  3288. item := models.CygxArticleComment{
  3289. UserId: user.UserId,
  3290. ArticleId: req.ArticleId,
  3291. CreateTime: time.Now(),
  3292. Mobile: user.Mobile,
  3293. Email: user.Email,
  3294. CompanyId: user.CompanyId,
  3295. CompanyName: companyDetail.CompanyName,
  3296. Content: content,
  3297. Title: articleInfo.Title,
  3298. }
  3299. _, err = models.AddArticleComment(&item)
  3300. if err != nil {
  3301. br.Msg = "提交失败"
  3302. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  3303. return
  3304. }
  3305. //获取销售信息
  3306. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  3307. //if err != nil && err.Error() != utils.ErrNoRow() {
  3308. // br.Msg = "提交失败"
  3309. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  3310. // return
  3311. //}
  3312. //// 给所属销售发送消息
  3313. //var openIdList []*models.OpenIdList
  3314. //if sellerItem != nil {
  3315. // list, _ := models.GetWxOpenIdByMobileList(sellerItem.Mobile)
  3316. // for _, idList := range list {
  3317. // openIdList = append(openIdList, idList)
  3318. // }
  3319. // if openIdList != nil {
  3320. // // 给芳姐发消息
  3321. // cnf, _ := models.GetConfigByCode("tpl_msg")
  3322. // if cnf != nil {
  3323. // list, _ := models.GetWxOpenIdByMobileList(cnf.ConfigValue)
  3324. // for _, idList := range list {
  3325. // openIdList = append(openIdList, idList)
  3326. // }
  3327. // }
  3328. // if articleId > 1000000 {
  3329. // //发给汪洋
  3330. // list, _ := models.GetWxOpenIdByMobileList(utils.ActSendMsgMobile)
  3331. // for _, idList := range list {
  3332. // openIdList = append(openIdList, idList)
  3333. // }
  3334. // }
  3335. // services.SendCommentWxTemplateMsg(articleInfo.Title, user.CompanyName, user.RealName, sellerItem.RealName, item.CreateTime.Format(utils.FormatDateTime), req.Content, openIdList, req.ArticleId)
  3336. // }
  3337. //}
  3338. services.SendCommentWxTemplateMsg(req, user, articleInfo)
  3339. br.Ret = 200
  3340. br.Success = true
  3341. br.Msg = "提交成功"
  3342. }
  3343. // @Title 记录用户浏览音频回放接口
  3344. // @Description 记录用户浏览音频回放接口
  3345. // @Param request body models.ArticleIdReq true "type json string"
  3346. // @Success Ret=200 操作成功
  3347. // @router /voiceHistory/add [post]
  3348. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  3349. br := new(models.BaseResponse).Init()
  3350. defer func() {
  3351. this.Data["json"] = br
  3352. this.ServeJSON()
  3353. }()
  3354. user := this.User
  3355. if user == nil {
  3356. br.Msg = "请登录"
  3357. br.ErrMsg = "请登录,用户信息为空"
  3358. br.Ret = 408
  3359. return
  3360. }
  3361. uid := user.UserId
  3362. var req models.ArticleIdReq
  3363. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3364. if err != nil {
  3365. br.Msg = "参数解析异常!"
  3366. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3367. return
  3368. }
  3369. articleId := req.ArticleId
  3370. playSeconds := req.PlaySeconds
  3371. pageRouter := req.PageRouter
  3372. if pageRouter == "本周研究汇总" {
  3373. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  3374. if articleInfo == nil {
  3375. br.Msg = "操作失败"
  3376. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3377. return
  3378. }
  3379. if errInfo != nil {
  3380. br.Msg = "操作失败"
  3381. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3382. return
  3383. }
  3384. var sellerName string
  3385. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3386. if err != nil {
  3387. br.Msg = "报名失败!"
  3388. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3389. return
  3390. }
  3391. item := models.CygxResearchSummaryVoiceHistory{
  3392. ArticleId: articleId,
  3393. UserId: uid,
  3394. CreateTime: time.Now(),
  3395. Mobile: user.Mobile,
  3396. Email: user.Email,
  3397. CompanyId: user.CompanyId,
  3398. CompanyName: user.CompanyName,
  3399. RealName: user.RealName,
  3400. SellerName: sellerName,
  3401. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3402. ModifyTime: time.Now(),
  3403. }
  3404. if playSeconds != 0 {
  3405. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  3406. if err != nil {
  3407. br.Msg = "操作失败"
  3408. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3409. return
  3410. }
  3411. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3412. if err != nil {
  3413. br.Msg = "更新失败"
  3414. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3415. return
  3416. }
  3417. } else {
  3418. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  3419. if err != nil {
  3420. br.Msg = "操作失败"
  3421. br.ErrMsg = "操作失败,Err:" + err.Error()
  3422. return
  3423. }
  3424. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  3425. if err != nil {
  3426. br.Msg = "更新失败"
  3427. br.ErrMsg = "更新失败,Err:" + err.Error()
  3428. return
  3429. }
  3430. }
  3431. } else if pageRouter == "上周纪要汇总" {
  3432. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  3433. if articleInfo == nil {
  3434. br.Msg = "操作失败"
  3435. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3436. return
  3437. }
  3438. if errInfo != nil {
  3439. br.Msg = "操作失败"
  3440. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3441. return
  3442. }
  3443. var sellerName string
  3444. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3445. if err != nil {
  3446. br.Msg = "报名失败!"
  3447. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3448. return
  3449. }
  3450. item := models.CygxMinutesSummaryVoiceHistory{
  3451. ArticleId: articleId,
  3452. UserId: uid,
  3453. CreateTime: time.Now(),
  3454. Mobile: user.Mobile,
  3455. Email: user.Email,
  3456. CompanyId: user.CompanyId,
  3457. CompanyName: user.CompanyName,
  3458. RealName: user.RealName,
  3459. SellerName: sellerName,
  3460. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3461. ModifyTime: time.Now(),
  3462. }
  3463. if playSeconds != 0 {
  3464. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  3465. if err != nil {
  3466. br.Msg = "操作失败"
  3467. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3468. return
  3469. }
  3470. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3471. if err != nil {
  3472. br.Msg = "更新失败"
  3473. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3474. return
  3475. }
  3476. } else {
  3477. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  3478. if err != nil {
  3479. br.Msg = "操作失败"
  3480. br.ErrMsg = "操作失败,Err:" + err.Error()
  3481. return
  3482. }
  3483. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  3484. if err != nil {
  3485. br.Msg = "更新失败"
  3486. br.ErrMsg = "更新失败,Err:" + err.Error()
  3487. return
  3488. }
  3489. }
  3490. } else if pageRouter == "报告精选" {
  3491. articleInfo, errInfo := models.GetCygxReportSelectionInfoById(articleId)
  3492. if articleInfo == nil {
  3493. br.Msg = "操作失败"
  3494. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3495. return
  3496. }
  3497. if errInfo != nil {
  3498. br.Msg = "操作失败"
  3499. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3500. return
  3501. }
  3502. var sellerName string
  3503. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3504. if err != nil {
  3505. br.Msg = "报名失败!"
  3506. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3507. return
  3508. }
  3509. item := models.CygxReportSelectionVoiceHistory{
  3510. ArticleId: articleId,
  3511. UserId: uid,
  3512. CreateTime: time.Now(),
  3513. Mobile: user.Mobile,
  3514. Email: user.Email,
  3515. CompanyId: user.CompanyId,
  3516. CompanyName: user.CompanyName,
  3517. RealName: user.RealName,
  3518. SellerName: sellerName,
  3519. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3520. ModifyTime: time.Now(),
  3521. }
  3522. if playSeconds != 0 {
  3523. lastItem, err := models.GetLastCygxReportSelectionVoiceHistory(articleId, user.UserId)
  3524. if err != nil {
  3525. br.Msg = "操作失败"
  3526. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3527. return
  3528. }
  3529. err = models.UpdateLastCygxReportSelectionVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3530. if err != nil {
  3531. br.Msg = "更新失败"
  3532. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3533. return
  3534. }
  3535. } else {
  3536. err = models.AddCygxReportSelectionVoiceHistory(&item)
  3537. if err != nil {
  3538. br.Msg = "操作失败"
  3539. br.ErrMsg = "操作失败,Err:" + err.Error()
  3540. return
  3541. }
  3542. err = models.UpdateReportSelectionVoiceCounts(articleId)
  3543. if err != nil {
  3544. br.Msg = "更新失败"
  3545. br.ErrMsg = "更新失败,Err:" + err.Error()
  3546. return
  3547. }
  3548. }
  3549. }
  3550. br.Ret = 200
  3551. br.Success = true
  3552. br.Msg = "操作成功"
  3553. return
  3554. }