report.go 105 KB

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