report.go 110 KB

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