report.go 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137
  1. package report
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. report_chapter_type_cache "hongze/hongze_yb/cache/report_chapter_type"
  7. "hongze/hongze_yb/global"
  8. "hongze/hongze_yb/models/response"
  9. "hongze/hongze_yb/models/response/purchase"
  10. "hongze/hongze_yb/models/tables/chart_permission_search_key_word_mapping"
  11. "hongze/hongze_yb/models/tables/company_product"
  12. "hongze/hongze_yb/models/tables/daily_base_column"
  13. "hongze/hongze_yb/models/tables/rddp/chart_permission"
  14. "hongze/hongze_yb/models/tables/rddp/chart_permission_chapter_mapping"
  15. "hongze/hongze_yb/models/tables/rddp/classify"
  16. "hongze/hongze_yb/models/tables/rddp/classify_menu"
  17. "hongze/hongze_yb/models/tables/rddp/report"
  18. "hongze/hongze_yb/models/tables/rddp/report_chapter"
  19. "hongze/hongze_yb/models/tables/rddp/report_chapter_ticker"
  20. "hongze/hongze_yb/models/tables/rddp/report_ppt_img"
  21. "hongze/hongze_yb/models/tables/rddp/smart_report_resource"
  22. "hongze/hongze_yb/models/tables/report_chapter_type"
  23. "hongze/hongze_yb/models/tables/report_chapter_type_permission"
  24. "hongze/hongze_yb/models/tables/user_report_chapter_set"
  25. "hongze/hongze_yb/models/tables/yb_road_video"
  26. "hongze/hongze_yb/services"
  27. "hongze/hongze_yb/services/collection"
  28. "hongze/hongze_yb/services/company"
  29. elasticService "hongze/hongze_yb/services/elastic"
  30. "hongze/hongze_yb/services/user"
  31. "hongze/hongze_yb/utils"
  32. "html"
  33. "sort"
  34. "strconv"
  35. "strings"
  36. "time"
  37. )
  38. // GetLatestClassReport 已购列表最新报告
  39. func GetLatestClassReport(permissionIds []int, userId uint64) (purchaseList []*purchase.PurchaseListItem, err error) {
  40. var errMsg string
  41. defer func() {
  42. if sysErr := recover(); sysErr != nil {
  43. err = errors.New("系统错误")
  44. global.LOG.Critical(fmt.Sprintf("GetLatestClassReport: userId=%d, err:%s,sysErr:%s", userId, err.Error(), sysErr))
  45. }
  46. if err != nil {
  47. global.LOG.Critical(fmt.Sprintf("GetLatestClassReport: userId=%d, err:%s, errMsg:%s", userId, err.Error(), errMsg))
  48. }
  49. }()
  50. //获取所有分类信息
  51. classifys, err := classify.GetSimpleAll()
  52. if err != nil {
  53. errMsg = err.Error()
  54. err = errors.New("分类查询出错")
  55. return
  56. }
  57. classifyFirstIconMap := make(map[int]string)
  58. //classifySecondNameMap := make(map[int]int)
  59. classifyFirstIdMap := make(map[int]bool)
  60. classifySecondIdMap := make(map[int]bool)
  61. for _, v := range classifys {
  62. if v.ParentId == 0 {
  63. classifyFirstIdMap[v.Id] = true
  64. classifyFirstIconMap[v.Id] = v.YbIconUrl
  65. } else {
  66. classifySecondIdMap[v.Id] = true
  67. //classifySecondNameMap[v.Id] = v.Id
  68. }
  69. }
  70. //获取最新的晨报
  71. dayReport, err := report.GetLatestDay()
  72. if err != nil {
  73. errMsg = err.Error()
  74. err = errors.New("晨报查询出错")
  75. return
  76. }
  77. //获取最新的有权限的周报
  78. //typeIds, err := report_chapter_type.GetEffectTypeID()
  79. typeIds, err := report_chapter_type_cache.GetEffectTypeID()
  80. if err != nil {
  81. errMsg = err.Error()
  82. err = errors.New("晨报查询出错")
  83. return
  84. }
  85. weekReport, err := GetLatestWeek(permissionIds, typeIds)
  86. if err != nil {
  87. errMsg = err.Error()
  88. err = errors.New("周报查询出错")
  89. return
  90. }
  91. // 有权限的二级分类
  92. var reports []*report.Report
  93. var classifyIdSeconds []int
  94. classifyIdSecondMap := make(map[int]bool)
  95. // 获取晨报和周报以外的其他报告
  96. // 获取有权限的二级分类
  97. chartPermissions, err := chart_permission_search_key_word_mapping.GetChartPermissionByFrom("rddp")
  98. if err != nil {
  99. errMsg = err.Error()
  100. err = errors.New("分类权限查询出错")
  101. return
  102. }
  103. if len(chartPermissions) > 0 {
  104. for _, v := range chartPermissions {
  105. for _, myPerId := range permissionIds {
  106. if v.ChartPermissionId == myPerId {
  107. if classifySecondIdMap[v.ClassifyId] {
  108. if _, ok := classifyIdSecondMap[v.ClassifyId]; !ok {
  109. classifyIdSeconds = append(classifyIdSeconds, v.ClassifyId)
  110. classifyIdSecondMap[v.ClassifyId] = true
  111. }
  112. }
  113. break
  114. }
  115. }
  116. }
  117. }
  118. reports, err = report.GetLatestClassReportsByClassifyIdSeconds(classifyIdSeconds)
  119. if err != nil {
  120. errMsg = err.Error()
  121. err = errors.New("二级分类最新报告查询出错")
  122. return
  123. }
  124. if dayReport.Id > 0 {
  125. reports = append(reports, dayReport)
  126. }
  127. if weekReport != nil && weekReport.Id > 0 {
  128. reports = append(reports, weekReport)
  129. }
  130. //获取未读数
  131. unReadItem, tErr := GetUnRead(classifyIdSeconds, userId)
  132. if tErr != nil {
  133. err = tErr
  134. return
  135. }
  136. if len(reports) > 0 {
  137. otherLatestItem := new(purchase.PurchaseListItem)
  138. // 处理其他报告()
  139. for _, v := range reports {
  140. temp := new(purchase.PurchaseListItem)
  141. temp.ReportId = v.Id
  142. temp.ClassifyIdFirst = v.ClassifyIdFirst
  143. temp.ClassifyNameFirst = v.ClassifyNameFirst
  144. temp.Stage = v.Stage
  145. temp.Title = v.Title
  146. temp.ClassifyIdSecond = v.ClassifyIdSecond
  147. temp.ClassifyNameSecond = v.ClassifyNameSecond
  148. temp.Time = v.PublishTime
  149. if temp.ClassifyNameFirst == "大事点评" || temp.ClassifyNameFirst == "会议纪要" || temp.ClassifyNameFirst == "年报合集" {
  150. if otherLatestItem.Time.Format(utils.FormatDateTime) > v.PublishTime.Format(utils.FormatDateTime) {
  151. continue
  152. }
  153. temp.Unread = unReadItem["大事点评"] + unReadItem["会议纪要"] + unReadItem["年报合集"]
  154. temp.Content = fmt.Sprintf("【第%d期|FICC】%s", temp.Stage, temp.ClassifyNameFirst)
  155. temp.ImgUrl = "https://hzstatic.hzinsights.com/static/yb_wx/purchase_icon_other.png"
  156. otherLatestItem = temp
  157. }
  158. }
  159. for _, v := range reports {
  160. if v.ClassifyNameFirst != "晨报" && v.ClassifyNameFirst != "周报" {
  161. // 报告的分类不存在
  162. if !classifyFirstIdMap[v.ClassifyIdFirst] || !classifyIdSecondMap[v.ClassifyIdSecond] {
  163. continue
  164. }
  165. }
  166. temp := new(purchase.PurchaseListItem)
  167. temp.ReportId = v.Id
  168. temp.ClassifyIdFirst = v.ClassifyIdFirst
  169. temp.ClassifyNameFirst = v.ClassifyNameFirst
  170. temp.Stage = v.Stage
  171. temp.Title = v.Title
  172. temp.ClassifyIdSecond = v.ClassifyIdSecond
  173. temp.ClassifyNameSecond = v.ClassifyNameSecond
  174. temp.Time = v.PublishTime
  175. temp.Unread = unReadItem[temp.ClassifyNameFirst]
  176. if imgUrl, ok := classifyFirstIconMap[temp.ClassifyIdFirst]; ok {
  177. temp.ImgUrl = imgUrl
  178. }
  179. if temp.ClassifyNameFirst == "晨报" || temp.ClassifyNameFirst == "周报" { //晨报或者周报,查询最新的章节信息
  180. temp.Content = fmt.Sprintf("【第%d期|FICC】%s", temp.Stage, temp.Title)
  181. } else if temp.ClassifyNameFirst == "大事点评" || temp.ClassifyNameFirst == "会议纪要" || temp.ClassifyNameFirst == "年报合集" {
  182. continue
  183. } else {
  184. if temp.ClassifyNameFirst != temp.ClassifyNameSecond { //包含二级分类
  185. temp.Content = fmt.Sprintf("【第%d期|FICC| %s】%s", temp.Stage, temp.ClassifyNameSecond, temp.ClassifyNameFirst)
  186. } else { //无二级分类
  187. temp.Content = fmt.Sprintf("【第%d期|FICC】%s", temp.Stage, temp.ClassifyNameFirst)
  188. }
  189. }
  190. purchaseList = append(purchaseList, temp)
  191. }
  192. if otherLatestItem.ReportId > 0 {
  193. purchaseList = append(purchaseList, otherLatestItem)
  194. }
  195. }
  196. return
  197. }
  198. // GetPurchaseDetail 已购详情页面
  199. func GetPurchaseDetail(permissionIds []int, userId uint64, classifyIdFirst int, pageIndex, pageSize int) (ret *purchase.DetailResp, err error) {
  200. var errMsg string
  201. defer func() {
  202. if err != nil {
  203. global.LOG.Critical(fmt.Sprintf("GetPurchaseDetail: userId=%d, err:%s, errMsg:%s", userId, err.Error(), errMsg))
  204. }
  205. }()
  206. var reports []*report.Report
  207. var weekReportIds []int
  208. classifyInfo, err := classify.GetByClassifyId(classifyIdFirst)
  209. if err != nil {
  210. errMsg = err.Error()
  211. err = errors.New("分类查询出错")
  212. return
  213. }
  214. if classifyInfo.Id == 0 {
  215. err = errors.New("分类不存在")
  216. return
  217. }
  218. classifyNameFirst := classifyInfo.ClassifyName
  219. offset := (pageIndex - 1) * pageSize
  220. var total int64
  221. var classifyIdSeconds []int
  222. if classifyNameFirst == "晨报" {
  223. //分类获取
  224. reports, err = report.GetListByClassifyIdFirst(classifyIdFirst, offset, pageSize)
  225. if err != nil {
  226. errMsg = err.Error()
  227. err = errors.New("晨报查询出错")
  228. return
  229. }
  230. total, err = report.GetListCountByClassifyIdFirst(classifyIdFirst)
  231. if err != nil {
  232. errMsg = err.Error()
  233. err = errors.New("查询报告总数出错")
  234. return
  235. }
  236. } else {
  237. if classifyNameFirst == "周报" {
  238. newTypeIds, tErr := GetWeekTypeIdsByPermissionIds(permissionIds, []int{})
  239. if tErr != nil {
  240. return
  241. }
  242. weekReportIds, err = report_chapter.GetReportIdsByTypeIdsAndClass(newTypeIds, classifyNameFirst)
  243. //分类获取
  244. reports, err = report.GetListByIDsAndClassifyIdFirst(weekReportIds, classifyIdFirst, offset, pageSize)
  245. if err != nil {
  246. return
  247. }
  248. total, err = report.GetListCountByIDsAndClassifyIdFirst(weekReportIds, classifyIdFirst)
  249. if err != nil {
  250. errMsg = err.Error()
  251. err = errors.New("查询报告总数出错")
  252. return
  253. }
  254. } else {
  255. //获取有权限的二级分类
  256. var classifyNameSeconds []string
  257. chartPermissions, tErr := chart_permission_search_key_word_mapping.GetChartPermissionByFrom("rddp")
  258. if tErr != nil {
  259. errMsg = tErr.Error()
  260. err = errors.New("分类权限查询出错")
  261. return
  262. }
  263. if len(chartPermissions) > 0 {
  264. for _, v := range chartPermissions {
  265. for _, myPerId := range permissionIds {
  266. if v.ChartPermissionId == myPerId {
  267. if classifyNameFirst == "大事点评" || classifyNameFirst == "会议纪要" || classifyNameFirst == "年报合集" {
  268. if v.KeyWord == "大事点评" || v.KeyWord == "会议纪要" || v.KeyWord == "年报合集" { //筛选出用户有权限的二级分类ID
  269. classifyNameSeconds = append(classifyNameSeconds, v.KeyWord)
  270. }
  271. } else {
  272. classifyNameSeconds = append(classifyNameSeconds, v.KeyWord)
  273. }
  274. break
  275. }
  276. }
  277. }
  278. }
  279. //获取所有二级分类的id
  280. if classifyNameFirst == "大事点评" || classifyNameFirst == "会议纪要" || classifyNameFirst == "年报合集" {
  281. classifyIdSeconds, tErr = classify.GetOtherSecondIds([]string{"大事点评", "会议纪要", "年报合集"})
  282. } else {
  283. classifyIdSeconds, tErr = classify.GetIdsByClassifyNameAndParentId(classifyNameSeconds, classifyIdFirst)
  284. }
  285. if tErr != nil {
  286. errMsg = tErr.Error()
  287. err = errors.New("二级分类查询出错")
  288. return
  289. }
  290. if len(classifyIdSeconds) > 0 {
  291. //分类获取
  292. reports, err = report.GetListByClassifyIdSeconds(classifyIdSeconds, offset, pageSize)
  293. if err != nil {
  294. return
  295. }
  296. total, err = report.GetListCountByClassifyIdSeconds(classifyIdSeconds)
  297. if err != nil {
  298. errMsg = err.Error()
  299. err = errors.New("查询报告总数出错")
  300. return
  301. }
  302. }
  303. }
  304. }
  305. var list []*purchase.Detail
  306. ret = new(purchase.DetailResp)
  307. if len(reports) > 0 {
  308. var viewReportIds []int
  309. for _, v := range reports {
  310. viewReportIds = append(viewReportIds, v.Id)
  311. temp := new(purchase.Detail)
  312. temp.ReportId = v.Id
  313. temp.ClassifyIdFirst = v.ClassifyIdFirst
  314. temp.ClassifyNameFirst = v.ClassifyNameFirst
  315. temp.Title = v.Title
  316. temp.ClassifyIdSecond = v.ClassifyIdSecond
  317. temp.ClassifyNameSecond = v.ClassifyNameSecond
  318. temp.Stage = v.Stage
  319. temp.ImgUrl = classifyInfo.YbBgUrl
  320. if temp.ClassifyNameFirst == "晨报" || temp.ClassifyNameFirst == "周报" { //晨报或者周报,查询最新的章节信息
  321. temp.Content = fmt.Sprintf("【第%d期|FICC】%s", temp.Stage, temp.Title)
  322. temp.TopName = temp.Title
  323. } else {
  324. if temp.ClassifyNameFirst != temp.ClassifyNameSecond { //包含二级分类
  325. temp.Content = fmt.Sprintf("【第%d期|FICC| %s】%s", temp.Stage, temp.ClassifyNameSecond, temp.ClassifyNameFirst)
  326. temp.TopName = temp.ClassifyNameSecond
  327. } else {
  328. temp.Content = fmt.Sprintf("【第%d期|FICC】%s", temp.Stage, temp.ClassifyNameFirst)
  329. temp.TopName = temp.ClassifyNameFirst
  330. }
  331. }
  332. temp.Time = v.PublishTime
  333. list = append(list, temp)
  334. }
  335. }
  336. ret.List = list
  337. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  338. // 执行一个协程任务,新增用户浏览记录
  339. //_, tErr := BatchInsertReportView(weekReportIds, userId, classifyNameFirst, classifyIdSeconds)
  340. go BatchInsertReportView(userId, weekReportIds, classifyNameFirst, classifyIdSeconds)
  341. /*if tErr != nil {
  342. err = tErr
  343. return
  344. }*/
  345. return
  346. }
  347. // 获取报告详情
  348. func GetReportDetail(userinfo user.UserInfo, reportId int) (reportDetail response.ReportDetail, err error) {
  349. var errMsg string
  350. defer func() {
  351. if err != nil {
  352. global.LOG.Critical(fmt.Sprintf("GetReportDetail: userId=%d, err:%s, errMsg:%s", userinfo.UserID, err.Error(), errMsg))
  353. }
  354. }()
  355. // 判断用户状态是否是正常和永续
  356. var productAuthOk bool
  357. companyProduct, err := company_product.GetByCompany2ProductId(userinfo.CompanyID, 1)
  358. if err == utils.ErrNoRow {
  359. err = nil
  360. }
  361. if err != nil {
  362. errMsg = err.Error()
  363. err = errors.New("查询用户购买产品出错")
  364. return
  365. }
  366. if companyProduct != nil {
  367. // 无FICC权限的客户不可见
  368. if companyProduct.CompanyProductID > 0 {
  369. // 已购或者试用用户可见
  370. if strings.Contains("永续,正式", companyProduct.Status) || (companyProduct.Status == "试用" && companyProduct.IsSuspend != 1) {
  371. productAuthOk = true
  372. }
  373. }
  374. }
  375. reportInfo, err := report.GetByReportId(reportId)
  376. if err != nil {
  377. errMsg = err.Error()
  378. err = errors.New("报告查询出错")
  379. return
  380. }
  381. if reportInfo.Id == 0 {
  382. err = errors.New("报告不存在")
  383. return
  384. }
  385. if reportInfo.State != 2 && reportInfo.State != 6 {
  386. err = errors.New("报告未发布")
  387. return
  388. }
  389. // 获取最小分类
  390. minClassifyId, _, err := GetMinClassify(reportInfo)
  391. // 判断报告是否属于专栏报告
  392. firstClassify, e := classify.GetByClassifyId(reportInfo.ClassifyIdFirst)
  393. if e != nil {
  394. err = errors.New("报告一级分类有误")
  395. return
  396. }
  397. // 最小分类
  398. var minClassify *classify.Classify
  399. if reportInfo.ClassifyIdFirst == minClassifyId {
  400. minClassify = firstClassify
  401. } else {
  402. minClassify, e = classify.GetByClassifyId(minClassifyId)
  403. if e != nil {
  404. err = errors.New("报告最小层级分类有误")
  405. return
  406. }
  407. }
  408. //判断权限
  409. var authOk bool
  410. var permissionCheckInfo response.PermissionCheckInfo
  411. //var vaildWeekTypeIds []int
  412. var reportChapterIdList []int
  413. if reportInfo.HasChapter == 1 {
  414. if reportInfo.ClassifyNameFirst == "晨报" {
  415. authOk, permissionCheckInfo, err = CheckDayReportPermission(userinfo, productAuthOk)
  416. } else {
  417. authOk, permissionCheckInfo, _, reportChapterIdList, err = CheckWeekReportPermission(userinfo, reportId, productAuthOk)
  418. }
  419. } else {
  420. authOk, permissionCheckInfo, err = CheckReportPermission(userinfo, reportId, productAuthOk)
  421. }
  422. if err != nil {
  423. return
  424. }
  425. reportItem := new(response.ReportItem)
  426. reportItem.ReportId = reportInfo.Id
  427. reportItem.Title = reportInfo.Title
  428. reportItem.PublishTime = reportInfo.PublishTime
  429. reportItem.ClassifyNameFirst = reportInfo.ClassifyNameFirst
  430. reportItem.ClassifyNameSecond = reportInfo.ClassifyNameSecond
  431. reportItem.Stage = reportInfo.Stage
  432. reportItem.Abstract = reportInfo.Abstract
  433. reportItem.ContentSub = html.UnescapeString(reportInfo.ContentSub)
  434. reportItem.Frequency = reportInfo.Frequency
  435. reportItem.VideoName = reportInfo.VideoName
  436. reportItem.HasChapter = reportInfo.HasChapter
  437. reportItem.ReportLayout = reportInfo.ReportLayout
  438. reportItem.HeadImg = reportInfo.HeadImg
  439. reportItem.EndImg = reportInfo.EndImg
  440. reportItem.CanvasColor = reportInfo.CanvasColor
  441. // 版头版尾样式
  442. {
  443. if reportInfo.HeadResourceId > 0 {
  444. headResource, tmpErr := smart_report_resource.GetResourceItemById(reportInfo.HeadResourceId)
  445. if tmpErr != nil && tmpErr != utils.ErrNoRow {
  446. err = tmpErr
  447. return
  448. }
  449. if headResource != nil && headResource.ResourceID > 0 {
  450. reportItem.HeadImg = headResource.ImgURL
  451. reportItem.HeadStyle = headResource.Style
  452. }
  453. }
  454. if reportInfo.EndResourceId > 0 {
  455. endResource, tmpErr := smart_report_resource.GetResourceItemById(reportInfo.EndResourceId)
  456. if tmpErr != nil && tmpErr != utils.ErrNoRow {
  457. err = tmpErr
  458. return
  459. }
  460. if endResource != nil && endResource.ResourceID > 0 {
  461. reportItem.EndImg = endResource.ImgURL
  462. reportItem.EndStyle = endResource.Style
  463. }
  464. }
  465. }
  466. if reportInfo.VideoName == "" && reportInfo.VideoUrl != "" {
  467. reportItem.VideoName = reportInfo.Title
  468. }
  469. reportItem.VideoSize = reportInfo.VideoSize
  470. reportItem.VideoPlaySeconds = reportInfo.VideoPlaySeconds
  471. reportItem.Author = reportInfo.Author
  472. // 分享背景图取二级分类配图, 二级没有配图时使用一级配图, 一级也没有使用默认图
  473. reportItem.ShareBgImg = utils.DEFAULT_REPORT_SHARE_BG_IMG
  474. secondClassify, e := classify.GetByClassifyId(reportInfo.ClassifyIdSecond)
  475. if e != nil {
  476. err = errors.New("报告二级分类有误")
  477. return
  478. }
  479. if secondClassify.YbShareBgImg != "" {
  480. reportItem.ShareBgImg = secondClassify.YbShareBgImg
  481. } else {
  482. if firstClassify.YbShareBgImg != "" {
  483. reportItem.ShareBgImg = firstClassify.YbShareBgImg
  484. }
  485. }
  486. var reportTypeList []*response.ReportChapterListItem
  487. if reportInfo.HasChapter == 1 {
  488. //(晨报和周报的banner图)
  489. if reportInfo.ClassifyNameFirst == "晨报" {
  490. reportItem.BannerUrl = utils.ALIYUN_YBIMG_HOST + "report_banner_day.jpg"
  491. } else {
  492. reportItem.BannerUrl = utils.ALIYUN_YBIMG_HOST + "report_banner_week.jpg"
  493. }
  494. // 如果还没有配置banner图,则取晨报的
  495. if reportItem.BannerUrl == `` {
  496. reportItem.BannerUrl = utils.ALIYUN_YBIMG_HOST + "report_banner_day.jpg"
  497. }
  498. if authOk {
  499. reportTypeList, err = GetChapterListByReportChapterIdList(reportInfo.ClassifyNameFirst, reportInfo.Id, reportChapterIdList)
  500. if err != nil {
  501. return
  502. }
  503. }
  504. } else {
  505. // 音频播放条图片用分类图片
  506. reportItem.VideoImg = utils.HZ_DEFAULT_AVATAR
  507. permissionIds, tmpErr := chart_permission_search_key_word_mapping.GetChartPermissionIdsByKeyWord(reportInfo.ClassifyIdSecond)
  508. if tmpErr != nil {
  509. errMsg = tmpErr.Error()
  510. err = errors.New("查询报告权限失败")
  511. return
  512. }
  513. if len(permissionIds) > 0 {
  514. chartPermission, tmpErr := chart_permission.GetListByIds(permissionIds)
  515. if tmpErr != nil {
  516. errMsg = tmpErr.Error()
  517. err = errors.New("查询品种信息失败")
  518. return
  519. }
  520. lenChart := len(chartPermission)
  521. for i := 0; i < lenChart; i++ {
  522. if chartPermission[i].YbImgUrl != "" {
  523. reportItem.VideoImg = utils.ALIYUN_YBIMG_HOST + chartPermission[i].YbImgUrl
  524. break
  525. }
  526. }
  527. }
  528. }
  529. //如果有权限则展示content
  530. var likeNum int64
  531. var likeEnabled int8
  532. if authOk {
  533. go AddViewRecord(userinfo, reportInfo.Id, reportInfo.ClassifyNameFirst, 0)
  534. reportItem.Content = html.UnescapeString(reportInfo.Content)
  535. reportItem.VideoUrl = reportInfo.VideoUrl
  536. //查询点赞数
  537. likeNum, likeEnabled, _ = services.GetReportLikeByReportIdOldReportId(userinfo.UserID, reportInfo.Id, 0, 0, 0)
  538. }
  539. //处理章节品种,音频开关
  540. {
  541. chapterSetList, err := user_report_chapter_set.GetUserReportChapterSet(userinfo.UserID)
  542. if err != nil {
  543. return reportDetail, err
  544. }
  545. setList := make([]*user_report_chapter_set.UserReportChapterSet, 0)
  546. reportTypeLen := len(reportTypeList)
  547. if len(chapterSetList) == 0 {
  548. for _, v := range reportTypeList {
  549. setItem := new(user_report_chapter_set.UserReportChapterSet)
  550. setItem.UserId = userinfo.UserID
  551. setItem.TypeId = v.TypeId
  552. setItem.TypeName = v.TypeName
  553. setItem.CreateTime = time.Now()
  554. setItem.ModifyTime = time.Now()
  555. setItem.IsClose = 0
  556. setList = append(setList, setItem)
  557. }
  558. } else {
  559. chapterSetMap := make(map[int]int)
  560. for _, v := range chapterSetList {
  561. chapterSetMap[v.TypeId] = v.IsClose
  562. }
  563. for i := 0; i < reportTypeLen; i++ {
  564. typeItem := reportTypeList[i]
  565. if findIsClose, ok := chapterSetMap[typeItem.TypeId]; ok {
  566. reportTypeList[i].IsClose = findIsClose
  567. } else {
  568. setItem := new(user_report_chapter_set.UserReportChapterSet)
  569. setItem.UserId = userinfo.UserID
  570. setItem.TypeId = typeItem.TypeId
  571. setItem.TypeName = typeItem.TypeName
  572. setItem.CreateTime = time.Now()
  573. setItem.ModifyTime = time.Now()
  574. setItem.IsClose = 0
  575. setList = append(setList, setItem)
  576. }
  577. }
  578. }
  579. if len(setList) > 0 {
  580. err = user_report_chapter_set.AddUserReportChapterSet(setList)
  581. if err != nil {
  582. return reportDetail, err
  583. }
  584. }
  585. }
  586. //新增用户访问日志
  587. go AddUserAccessRecord(userinfo, reportInfo.Id, reportInfo.ClassifyNameFirst, 0, authOk)
  588. reportDetail.ReportInfo = reportItem
  589. reportDetail.ReportChapterList = reportTypeList
  590. reportDetail.PermissionCheck = &permissionCheckInfo
  591. reportDetail.AuthOk = authOk
  592. reportDetail.LikeNum = likeNum
  593. reportDetail.LikeEnabled = likeEnabled
  594. reportDetail.ReportShowType = int(firstClassify.ShowType)
  595. reportDetail.ReportDetailShowType = int(minClassify.ReportDetailShowType)
  596. // 如果分类配置是列表展示,那么就移除content内容
  597. if minClassify.ReportDetailShowType == 2 {
  598. for _, v := range reportTypeList {
  599. v.Content = ``
  600. }
  601. } else {
  602. for _, v := range reportTypeList {
  603. v.Content = html.UnescapeString(v.Content)
  604. }
  605. }
  606. // 收藏
  607. collectionId, e := collection.GetUserCollectByItem(int(userinfo.UserID), collection.CollectionTypeReport, reportId, 0)
  608. if e != nil {
  609. err = e
  610. return
  611. }
  612. reportDetail.CollectionId = collectionId
  613. // 绑定的路演视频
  614. roadVideo, e := yb_road_video.GetItemByReportId(reportId)
  615. if e != nil && e != utils.ErrNoRow {
  616. err = e
  617. return
  618. }
  619. if roadVideo != nil && roadVideo.RoadVideoID > 0 {
  620. reportDetail.RoadVideoId = roadVideo.RoadVideoID
  621. }
  622. return
  623. }
  624. // CheckReportPermission 验证用户查看报告的权限
  625. func CheckReportPermission(userInfo user.UserInfo, reportId int, productAuthOk bool) (authOk bool, permissionCheckInfo response.PermissionCheckInfo, err error) {
  626. var permissionIds []int
  627. if productAuthOk {
  628. permissionIds, err = chart_permission_chapter_mapping.GetPermissionIdsByReportId(reportId, "rddp")
  629. if err != nil && err != utils.ErrNoRow {
  630. return
  631. }
  632. }
  633. authOk, permissionCheckInfo, _, err = company.GetCheckPermission(userInfo.CompanyID, int(userInfo.UserID), permissionIds)
  634. return
  635. }
  636. // GetReportList 获取报告列表
  637. func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classifyIdSecond, pageIndex, pageSize, classifyMenuId int) (ret *response.ReportList, err error) {
  638. var errMsg string
  639. defer func() {
  640. if err != nil {
  641. global.LOG.Critical(fmt.Sprintf("GetReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  642. }
  643. }()
  644. // 判断用户状态是否是正常和永续
  645. var productAuthOk bool
  646. companyProduct, err := company_product.GetByCompany2ProductId(user.CompanyID, 1)
  647. if err == utils.ErrNoRow {
  648. err = nil
  649. }
  650. if err != nil {
  651. errMsg = err.Error()
  652. err = errors.New("查询用户购买产品出错")
  653. return
  654. }
  655. if companyProduct != nil {
  656. // 无FICC权限的客户不可见
  657. if companyProduct.CompanyProductID > 0 {
  658. // 已购或者试用用户可见
  659. if strings.Contains("永续,正式", companyProduct.Status) || (companyProduct.Status == "试用" && companyProduct.IsSuspend != 1) {
  660. productAuthOk = true
  661. }
  662. }
  663. }
  664. var condition string
  665. pars := make([]interface{}, 0)
  666. classifyParent, err := classify.GetByClassifyId(classifyIdFirst)
  667. if err != nil {
  668. errMsg = err.Error()
  669. err = errors.New("分类查询出错")
  670. return
  671. }
  672. if classifyParent.Id == 0 {
  673. err = errors.New("该分类不存在")
  674. return
  675. }
  676. condition = `classify_id_first = ? and state IN (2, 6)`
  677. pars = append(pars, classifyIdFirst)
  678. // 子目录
  679. menuClassifyIds := make([]int, 0)
  680. menuClassifyLen := 0
  681. if classifyMenuId > 0 {
  682. ids, e := classify_menu.GetClassifyIdsByMenuId(classifyMenuId)
  683. if e != nil {
  684. err = errors.New("获取子目录关联分类信息失败, Err: " + e.Error())
  685. return
  686. }
  687. menuClassifyIds = ids
  688. menuClassifyLen = len(menuClassifyIds)
  689. if menuClassifyLen == 0 {
  690. condition += ` AND 1 = 2`
  691. }
  692. }
  693. permissionMap := make(map[int][]int)
  694. checkPermissionMap := make(map[int]bool)
  695. //permissionImageMap := make(map[string]string)
  696. chartPermissionImageMap := make(map[int]string)
  697. var classifyIdSeconds []int
  698. //var reportImgUrl string
  699. chartPermissionList, err := chart_permission.GetFiccListExceptTacticByProductId()
  700. if err != nil {
  701. errMsg = err.Error()
  702. err = errors.New("分类查询出错")
  703. return
  704. }
  705. if len(chartPermissionList) > 0 {
  706. for _, v := range chartPermissionList {
  707. chartPermissionImageMap[int(v.ChartPermissionID)] = v.YbImgUrl
  708. }
  709. }
  710. if classifyIdSecond > 0 && keyWord == "" {
  711. classifyInfo, tErr := classify.GetByClassifyId(classifyIdSecond)
  712. if tErr != nil {
  713. errMsg = tErr.Error()
  714. err = errors.New("分类查询出错")
  715. return
  716. }
  717. if classifyInfo.Id == 0 {
  718. err = errors.New("该二级分类不存在")
  719. return
  720. }
  721. condition += " AND classify_id_second = ?"
  722. pars = append(pars, classifyIdSecond)
  723. //查询二级分类对应的权限
  724. permissionIds, tErr := chart_permission_search_key_word_mapping.GetChartPermissionIdsByKeyWord(classifyIdSecond)
  725. if tErr != nil {
  726. errMsg = tErr.Error()
  727. err = errors.New("分类权限查询出错")
  728. return
  729. }
  730. permissionMap[classifyInfo.Id] = permissionIds
  731. //if len(permissionIds) > 0 {
  732. // for _, v := range permissionIds {
  733. // reportImgUrl = chartPermissionImageMap[v]
  734. // }
  735. //}
  736. } else {
  737. if classifyParent.HasChild == 0 {
  738. //reportImgUrl = chartPermissionImageMap[1]
  739. classifyIdSeconds = append(classifyIdSeconds, 0)
  740. }
  741. chartPermissions, tErr := chart_permission_search_key_word_mapping.GetChartPermissionByFrom("rddp")
  742. if tErr != nil {
  743. errMsg = tErr.Error()
  744. err = errors.New("分类权限查询出错")
  745. return
  746. }
  747. if len(chartPermissions) > 0 {
  748. for _, v := range chartPermissions {
  749. permissionMap[v.ClassifyId] = append(permissionMap[v.ClassifyId], v.ChartPermissionId)
  750. //permissionImageMap[v.KeyWord] = chartPermissionImageMap[v.ChartPermissionId]
  751. }
  752. }
  753. //获取二级分类的所有头像
  754. classifyList, tErr := classify.GetListByPid(classifyIdFirst)
  755. if tErr != nil {
  756. errMsg = tErr.Error()
  757. err = errors.New("二级分类查询出错")
  758. return
  759. }
  760. // 子目录
  761. if menuClassifyLen > 0 {
  762. classifyIdSeconds = append(classifyIdSeconds, menuClassifyIds...)
  763. } else {
  764. for _, v := range classifyList {
  765. classifyIdSeconds = append(classifyIdSeconds, v.Id)
  766. }
  767. }
  768. if len(classifyIdSeconds) == 0 && classifyParent.ClassifyName != "晨报" && classifyParent.ClassifyName != "周报" {
  769. ret = new(response.ReportList)
  770. ret.Paging = response.GetPaging(pageIndex, pageSize, 0)
  771. return
  772. }
  773. condition += ` AND classify_id_second IN ? `
  774. pars = append(pars, classifyIdSeconds)
  775. }
  776. // 获取有效的权限id列表
  777. var validPermissionIdList []int
  778. if productAuthOk {
  779. validPermissionIdList, err = company.GetValidPermissionIdListByCompany2ProductId(user.CompanyID, 1)
  780. if err != nil && err != utils.ErrNoRow {
  781. errMsg = err.Error()
  782. err = errors.New("查询分类出错")
  783. return
  784. }
  785. }
  786. if len(validPermissionIdList) > 0 {
  787. for cid, perIds := range permissionMap {
  788. checkLoop:
  789. for _, checkId := range perIds {
  790. for _, validPerid := range validPermissionIdList {
  791. if checkId == validPerid {
  792. checkPermissionMap[cid] = true
  793. break checkLoop
  794. }
  795. }
  796. }
  797. }
  798. }
  799. var total int64
  800. var list []*report.Report
  801. if keyWord == "" {
  802. offset := (pageIndex - 1) * pageSize
  803. list, err = report.GetReportList(condition, pars, offset, pageSize)
  804. if err != nil {
  805. errMsg = err.Error()
  806. err = errors.New("报告查询出错")
  807. return
  808. }
  809. total, err = report.GetReportListCount(condition, pars)
  810. if err != nil {
  811. errMsg = err.Error()
  812. err = errors.New("查询报告总数出错")
  813. return
  814. }
  815. } else {
  816. if classifyIdSecond > 0 {
  817. classifyIdSeconds = append(classifyIdSeconds, classifyIdSecond)
  818. }
  819. if classifyParent.ClassifyName == "晨报" || classifyParent.ClassifyName == "周报" {
  820. classifyIdSeconds = append(classifyIdSeconds, 0)
  821. }
  822. // 子目录
  823. if menuClassifyLen > 0 {
  824. classifyIdSeconds = append(classifyIdSeconds, menuClassifyIds...)
  825. }
  826. searchResp, total1, tErr := elasticService.ReportListSearch(keyWord, classifyIdFirst, classifyIdSeconds, pageIndex, pageSize)
  827. if tErr != nil {
  828. errMsg = tErr.Error()
  829. err = errors.New("查询失败")
  830. return
  831. }
  832. total = int64(total1)
  833. if searchResp.Hits != nil && total > 0 {
  834. var reportIds []int
  835. for _, v := range searchResp.Hits.Hits {
  836. temp := new(report.Report)
  837. itemJson, tmpErr := v.Source.MarshalJSON()
  838. if tmpErr != nil {
  839. errMsg = tmpErr.Error()
  840. err = errors.New("解析出错")
  841. return
  842. }
  843. reportItem := new(response.EsReportItem)
  844. tmpErr = json.Unmarshal(itemJson, &reportItem)
  845. if tmpErr != nil {
  846. errMsg = tmpErr.Error()
  847. err = errors.New("解析json出错")
  848. return
  849. }
  850. temp.Id = reportItem.ReportId
  851. reportIds = append(reportIds, reportItem.ReportId)
  852. temp.ClassifyIdFirst = reportItem.ClassifyIdFirst
  853. temp.ClassifyNameFirst = reportItem.ClassifyNameFirst
  854. temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
  855. temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
  856. if reportItem.ClassifyIdSecond > 0 && reportItem.ClassifyIdSecond != reportItem.ClassifyId {
  857. temp.ClassifyIdThird = reportItem.ClassifyId
  858. temp.ClassifyNameThird = reportItem.ClassifyName
  859. }
  860. if len(v.Highlight["ClassifyNameSecond"]) > 0 {
  861. temp.ClassifyNameSecond = v.Highlight["ClassifyNameSecond"][0]
  862. }
  863. temp.Abstract = reportItem.Abstract
  864. stageInt, _ := strconv.Atoi(reportItem.StageStr)
  865. temp.Stage = stageInt
  866. temp.StageStr = reportItem.StageStr
  867. temp.Title = reportItem.Title
  868. temp.PublishTime, err = time.ParseInLocation(utils.FormatDateTime, reportItem.PublishTime, time.Local)
  869. if len(v.Highlight["Title"]) > 0 {
  870. temp.Title = v.Highlight["Title"][0]
  871. }
  872. if len(v.Highlight["Abstract"]) > 0 {
  873. temp.Abstract = v.Highlight["Abstract"][0]
  874. }
  875. if len(v.Highlight["StageStr"]) > 0 {
  876. temp.StageStr = v.Highlight["StageStr"][0]
  877. }
  878. list = append(list, temp)
  879. }
  880. reportInfoList, tmpErr := report.GetByReportIds(reportIds)
  881. if tmpErr != nil {
  882. errMsg = tmpErr.Error()
  883. err = errors.New("查询报告出错")
  884. return
  885. }
  886. reportListMap := make(map[int]*report.Report)
  887. for _, temp := range reportInfoList {
  888. reportListMap[temp.Id] = temp
  889. }
  890. for k, reportDetail := range list {
  891. if v, ok := reportListMap[reportDetail.Id]; ok {
  892. list[k].CreateTime = v.CreateTime
  893. }
  894. }
  895. }
  896. }
  897. var reportList []*response.ReportListItem
  898. if len(list) > 0 {
  899. // 封面图
  900. classifyList, e := classify.GetClassifyList()
  901. if e != nil {
  902. err = errors.New("获取报告分类列表失败" + e.Error())
  903. return
  904. }
  905. listImgMap := make(map[int]string)
  906. classifyNameMap := make(map[int]string)
  907. classifyMap := make(map[int]*classify.Classify)
  908. classifyLen := len(classifyList)
  909. for i := 0; i < classifyLen; i++ {
  910. listImgMap[classifyList[i].Id] = classifyList[i].YbListImg
  911. classifyNameMap[classifyList[i].Id] = classifyList[i].ClassifyName
  912. classifyMap[classifyList[i].Id] = classifyList[i]
  913. }
  914. var videoReportIds []int
  915. videoMap := make(map[int][]*response.VideoListItem)
  916. weekAuthMap := make(map[int]bool)
  917. // 判断周报权限\查询章节报告的音频列表
  918. videoMap, weekAuthMap, errMsg, err = GetReportChapterVideoList(validPermissionIdList, classifyParent.ClassifyName, list, user.UserID)
  919. if err != nil {
  920. return
  921. }
  922. // 如果是晨报,那么就要过滤掉weekAuthMap的授权
  923. if classifyParent.ClassifyName == "晨报" && productAuthOk {
  924. weekAuthMap = map[int]bool{}
  925. } else {
  926. //查询所有权限typeID
  927. //如果存在可以查看的章节ID
  928. for _, reportInfo := range list {
  929. if reportInfo.HasChapter == 1 {
  930. videoReportIds = append(videoReportIds, reportInfo.Id)
  931. }
  932. }
  933. }
  934. // 以下分类图标特殊处理 =_=!
  935. //reportImgMap := map[string]string{
  936. // "晨报": "report_list_chen.png",
  937. // "周报": "report_list_zhou.png",
  938. // "月报": "report_list_yue.png",
  939. // "大事点评": "report_list_dashidianping.png",
  940. // "会议纪要": "report_list_huiyijiyao.png",
  941. // "年报合集": "report_list_nianbaoheji.png",
  942. //}
  943. for _, reportInfo := range list {
  944. reportItem := new(response.ReportListItem)
  945. reportItem.ReportId = reportInfo.Id
  946. reportItem.HasChapter = reportInfo.HasChapter
  947. reportItem.VideoUrl = reportInfo.VideoUrl
  948. reportItem.VideoName = reportInfo.VideoName
  949. reportItem.VideoPlaySeconds = reportInfo.VideoPlaySeconds
  950. // 样式限制行数
  951. reportItem.Title = "<div style=\"-webkit-line-clamp: 2;-webkit-box-orient: vertical;display: -webkit-box;overflow: hidden;text-overflow: ellipsis;\">" + reportInfo.Title + "</div>"
  952. reportItem.PublishTime = reportInfo.PublishTime
  953. //reportItem.ClassifyNameFirst = reportInfo.ClassifyNameFirst
  954. //reportItem.ClassifyNameSecond = reportInfo.ClassifyNameSecond
  955. reportItem.ClassifyNameFirst = classifyNameMap[reportInfo.ClassifyIdFirst]
  956. reportItem.ClassifyNameSecond = classifyNameMap[reportInfo.ClassifyIdSecond]
  957. reportItem.ClassifyIdFirst = reportInfo.ClassifyIdFirst
  958. reportItem.ClassifyIdSecond = reportInfo.ClassifyIdSecond
  959. reportItem.ClassifyIdThird = reportInfo.ClassifyIdThird
  960. reportItem.ClassifyNameThird = reportInfo.ClassifyNameThird
  961. reportItem.Stage = reportInfo.Stage
  962. reportItem.Abstract = reportInfo.Abstract
  963. if reportInfo.Abstract != "" {
  964. reportItem.Abstract = "<div style=\"display: -webkit-box;overflow: hidden;text-overflow: ellipsis;word-break: break-all;-webkit-box-orient: vertical;-webkit-line-clamp: 1;\">" + reportInfo.Abstract + "</div>"
  965. }
  966. reportItem.Author = reportInfo.Author
  967. stageStr := reportInfo.StageStr
  968. if stageStr == "" {
  969. stageStr = strconv.Itoa(reportInfo.Stage)
  970. }
  971. reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】", stageStr, reportItem.ClassifyNameSecond)
  972. if reportItem.ClassifyNameThird != `` {
  973. reportItem.TitleInfo = fmt.Sprintf("%s|%s】", reportItem.TitleInfo, reportItem.ClassifyNameThird)
  974. }
  975. //trimClassifyNameSecond := utils.TrimHtml(reportInfo.ClassifyNameSecond)
  976. if reportItem.ClassifyNameFirst == "晨报" || reportItem.ClassifyNameFirst == "周报" || classifyIdSecond > 0 {
  977. //reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + reportImgUrl
  978. reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】", stageStr, reportItem.ClassifyNameFirst)
  979. }
  980. //else if url, ok := permissionImageMap[trimClassifyNameSecond]; ok {
  981. // reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + url
  982. //}
  983. //if img, ok := reportImgMap[reportInfo.ClassifyNameFirst]; ok {
  984. // reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + img
  985. //}
  986. // 封面图-默认取二级分类的图片,二级分类图片没有(如晨周报)则取一级
  987. coverImg := listImgMap[reportInfo.ClassifyIdSecond]
  988. if coverImg == "" {
  989. coverImg = listImgMap[reportInfo.ClassifyIdFirst]
  990. }
  991. reportItem.ReportImgUrl = coverImg
  992. reportItem.VideoImg = reportItem.ReportImgUrl
  993. if reportItem.HasChapter == 1 {
  994. if classifyParent.ClassifyName == "晨报" && productAuthOk {
  995. // 查询当前晨报的所有音频
  996. if vList, ok := videoMap[reportInfo.Id]; ok {
  997. for _, vd := range vList {
  998. vd.VideoImg = reportItem.ReportImgUrl
  999. }
  1000. reportItem.VideoList = vList
  1001. }
  1002. reportItem.AuthOk = productAuthOk
  1003. } else {
  1004. if wAuth, ok := weekAuthMap[reportInfo.Id]; ok {
  1005. reportItem.AuthOk = wAuth
  1006. if wAuth {
  1007. // 查询当前晨报的所有音频
  1008. if vList, ok2 := videoMap[reportInfo.Id]; ok2 {
  1009. for _, vd := range vList {
  1010. vd.VideoImg = reportItem.ReportImgUrl
  1011. }
  1012. reportItem.VideoList = vList
  1013. }
  1014. }
  1015. }
  1016. }
  1017. } else if authOk, ok := checkPermissionMap[reportInfo.ClassifyIdSecond]; ok && authOk {
  1018. if reportInfo.VideoUrl != "" {
  1019. videoTemp := new(response.VideoListItem)
  1020. videoTemp.VideoUrl = reportInfo.VideoUrl
  1021. videoTemp.VideoName = reportInfo.VideoName
  1022. if reportInfo.VideoName == "" {
  1023. videoTemp.VideoName = reportInfo.Title
  1024. }
  1025. videoTemp.VideoPlaySeconds = reportInfo.VideoPlaySeconds
  1026. videoTemp.VideoImg = reportItem.ReportImgUrl
  1027. reportItem.VideoList = append(reportItem.VideoList, videoTemp)
  1028. }
  1029. reportItem.AuthOk = authOk
  1030. }
  1031. // 报告详情展示形式
  1032. {
  1033. minClassifyId := reportItem.ClassifyIdThird
  1034. if minClassifyId <= 0 {
  1035. minClassifyId = reportItem.ClassifyIdSecond
  1036. }
  1037. if minClassifyId <= 0 {
  1038. minClassifyId = reportItem.ClassifyIdFirst
  1039. }
  1040. if tmpClassify, ok := classifyMap[minClassifyId]; ok {
  1041. reportItem.ReportDetailShowType = int(tmpClassify.ReportDetailShowType)
  1042. }
  1043. }
  1044. reportList = append(reportList, reportItem)
  1045. }
  1046. }
  1047. ret = new(response.ReportList)
  1048. ret.List = reportList
  1049. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1050. return
  1051. }
  1052. // GetCollectReportList 首页展示报告汇总列表
  1053. func GetCollectReportList(user user.UserInfo, chartPermissionId, pageIndex, pageSize int) (ret *response.ReportCollectResp, err error) {
  1054. var errMsg string
  1055. defer func() {
  1056. if err != nil {
  1057. global.LOG.Critical(fmt.Sprintf("GetCollectReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1058. }
  1059. }()
  1060. // 查询权限的基本信息
  1061. permissionInfo, err := chart_permission.GetByChartPermissionId(chartPermissionId)
  1062. if err != nil {
  1063. errMsg = err.Error()
  1064. err = errors.New("查询权限出错")
  1065. return
  1066. }
  1067. if permissionInfo.ChartPermissionID == 0 {
  1068. err = errors.New("权限不存在")
  1069. return
  1070. }
  1071. // 除了晨报和周报以外的其他报告
  1072. classifyIdList, err := chart_permission_search_key_word_mapping.GetClassifyIdsByChartPermissionId(chartPermissionId, "rddp")
  1073. if err != nil {
  1074. errMsg = err.Error()
  1075. err = errors.New("查询权限对应的分类出错")
  1076. return
  1077. }
  1078. var firstClassifyIdList, secondClassifyIdList, thirdClassifyIdList []int
  1079. {
  1080. classifyList, tmpErr := classify.GetListByClassifyIdList(classifyIdList)
  1081. if tmpErr != nil {
  1082. errMsg = tmpErr.Error()
  1083. err = errors.New("查询分类信息失败")
  1084. return
  1085. }
  1086. for _, v := range classifyList {
  1087. switch v.Level {
  1088. case 1:
  1089. firstClassifyIdList = append(firstClassifyIdList, v.Id)
  1090. case 2:
  1091. secondClassifyIdList = append(secondClassifyIdList, v.Id)
  1092. case 3:
  1093. thirdClassifyIdList = append(thirdClassifyIdList, v.Id)
  1094. }
  1095. }
  1096. }
  1097. var reportList []*response.ReportCollectListItem
  1098. list := response.ReportCollectListResp{}
  1099. var total int64
  1100. {
  1101. offset := (pageIndex - 1) * pageSize
  1102. reportList, err = report.GetReportCollectListByPermissionV1(chartPermissionId, firstClassifyIdList, secondClassifyIdList, thirdClassifyIdList, offset, pageSize)
  1103. if err != nil {
  1104. errMsg = err.Error()
  1105. err = errors.New("查询报告信息出错")
  1106. return
  1107. }
  1108. listMap := make(map[string]*response.ReportCollectList)
  1109. for _, v := range reportList {
  1110. v.ContentSub = GetReportContentSub(v.ContentSub, true)
  1111. if _, ok := listMap[v.PublishTime.Format("2006-01-02")]; !ok {
  1112. temp := new(response.ReportCollectList)
  1113. temp.Date = v.PublishTime.Format("2006-01-02")
  1114. listMap[v.PublishTime.Format("2006-01-02")] = temp
  1115. }
  1116. listMap[v.PublishTime.Format("2006-01-02")].SubList = append(listMap[v.PublishTime.Format("2006-01-02")].SubList, v)
  1117. }
  1118. for _, v := range listMap {
  1119. list = append(list, v)
  1120. }
  1121. total, err = report.GetReportCollectCountByPermissionV1(chartPermissionId, classifyIdList)
  1122. if err != nil {
  1123. errMsg = err.Error()
  1124. err = errors.New("查询报告总数出错")
  1125. return
  1126. }
  1127. if len(list) > 0 {
  1128. sort.Sort(list)
  1129. }
  1130. }
  1131. ret = new(response.ReportCollectResp)
  1132. ret.List = list
  1133. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1134. return
  1135. }
  1136. func GetCollectReportListBak(user user.UserInfo, chartPermissionId, pageIndex, pageSize int) (ret *response.ReportCollectResp, err error) {
  1137. var errMsg string
  1138. defer func() {
  1139. if err != nil {
  1140. global.LOG.Critical(fmt.Sprintf("GetCollectReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1141. }
  1142. }()
  1143. // 查询权限的基本信息
  1144. permissionInfo, err := chart_permission.GetByChartPermissionId(chartPermissionId)
  1145. if err != nil {
  1146. errMsg = err.Error()
  1147. err = errors.New("查询权限出错")
  1148. return
  1149. }
  1150. if permissionInfo.ChartPermissionID == 0 {
  1151. err = errors.New("权限不存在")
  1152. return
  1153. }
  1154. // 除了晨报和周报以外的其他报告
  1155. classifySecondIds, err := chart_permission_search_key_word_mapping.GetClassifyIdsByChartPermissionId(chartPermissionId, "rddp")
  1156. if err != nil {
  1157. errMsg = err.Error()
  1158. err = errors.New("查询权限对应的分类出错")
  1159. return
  1160. }
  1161. //var classifySecondIds []int
  1162. //if len(classifyNames) > 0 {
  1163. // classifySecondIds, err = classify.GetSecondIdsByClassifyNames(classifyNames)
  1164. // if err != nil {
  1165. // errMsg = err.Error()
  1166. // err = errors.New("查询分类出错")
  1167. // return
  1168. // }
  1169. //}
  1170. // 查询晨报和周报相对应的章节ID
  1171. reportChapterTypeIds, err := report_chapter_type_permission.GetTypeIdsByChartPermissionId(chartPermissionId)
  1172. if err != nil {
  1173. errMsg = err.Error()
  1174. err = errors.New("查询权限对应的章节出错")
  1175. return
  1176. }
  1177. var reportList []*response.ReportCollectListItem
  1178. list := response.ReportCollectListResp{}
  1179. var total int64
  1180. if len(reportChapterTypeIds) > 0 || len(classifySecondIds) > 0 {
  1181. offset := (pageIndex - 1) * pageSize
  1182. reportList, err = report.GetReportCollectListByPermission(classifySecondIds, reportChapterTypeIds, offset, pageSize)
  1183. if err != nil {
  1184. errMsg = err.Error()
  1185. err = errors.New("查询报告信息出错")
  1186. return
  1187. }
  1188. listMap := make(map[string]*response.ReportCollectList)
  1189. for _, v := range reportList {
  1190. v.ContentSub = GetReportContentSub(v.ContentSub, true)
  1191. if _, ok := listMap[v.PublishTime.Format("2006-01-02")]; !ok {
  1192. temp := new(response.ReportCollectList)
  1193. temp.Date = v.PublishTime.Format("2006-01-02")
  1194. listMap[v.PublishTime.Format("2006-01-02")] = temp
  1195. }
  1196. listMap[v.PublishTime.Format("2006-01-02")].SubList = append(listMap[v.PublishTime.Format("2006-01-02")].SubList, v)
  1197. }
  1198. for _, v := range listMap {
  1199. list = append(list, v)
  1200. }
  1201. total, err = report.GetReportCollectCountByPermission(classifySecondIds, reportChapterTypeIds)
  1202. if err != nil {
  1203. errMsg = err.Error()
  1204. err = errors.New("查询报告总数出错")
  1205. return
  1206. }
  1207. if len(list) > 0 {
  1208. sort.Sort(list)
  1209. }
  1210. }
  1211. ret = new(response.ReportCollectResp)
  1212. ret.List = list
  1213. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1214. return
  1215. }
  1216. func SearchReport(user user.UserInfo, keyWord string, pageIndex, pageSize int) (ret *response.ReportSearchResp, err error) {
  1217. var errMsg string
  1218. defer func() {
  1219. if err != nil {
  1220. global.LOG.Critical(fmt.Sprintf("SearchReport: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1221. }
  1222. }()
  1223. //查询正常状态的分类
  1224. classifys, err := classify.GetSimpleAll()
  1225. if err != nil {
  1226. errMsg = err.Error()
  1227. err = errors.New("分类查询出错")
  1228. return
  1229. }
  1230. classifyIdList := make([]int, 0)
  1231. var classifyIdFirsts []int
  1232. classifyIdSeconds := []int{0}
  1233. classifyMap := make(map[int]*classify.Classify)
  1234. for _, v := range classifys {
  1235. if v.ParentId == 0 {
  1236. classifyIdFirsts = append(classifyIdFirsts, v.Id)
  1237. } else {
  1238. classifyIdSeconds = append(classifyIdSeconds, v.Id)
  1239. }
  1240. classifyIdList = append(classifyIdList, v.Id)
  1241. classifyMap[v.Id] = v
  1242. }
  1243. keyWord = addAliasToKeyword(keyWord)
  1244. searchResp, total, err := elasticService.SearchReport(keyWord, classifyIdList, pageIndex, pageSize)
  1245. if err != nil {
  1246. errMsg = err.Error()
  1247. err = errors.New("查询失败")
  1248. return
  1249. }
  1250. var reportList []*response.ReportCollectListItem
  1251. if searchResp.Hits != nil {
  1252. for _, v := range searchResp.Hits.Hits {
  1253. temp := new(response.ReportCollectListItem)
  1254. itemJson, tmpErr := v.Source.MarshalJSON()
  1255. if tmpErr != nil {
  1256. errMsg = tmpErr.Error()
  1257. err = errors.New("解析出错")
  1258. return
  1259. }
  1260. reportItem := new(response.EsReportItem)
  1261. tmpErr = json.Unmarshal(itemJson, &reportItem)
  1262. if tmpErr != nil {
  1263. errMsg = tmpErr.Error()
  1264. err = errors.New("解析json出错")
  1265. return
  1266. }
  1267. temp.ReportId = reportItem.ReportId
  1268. temp.ReportChapterId = reportItem.ReportChapterId
  1269. temp.ClassifyIdFirst = reportItem.ClassifyIdFirst
  1270. temp.ClassifyNameFirst = reportItem.ClassifyNameFirst
  1271. temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
  1272. temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
  1273. temp.ClassifyId = reportItem.ClassifyId
  1274. temp.ClassifyName = reportItem.ClassifyName
  1275. temp.Title = reportItem.Title
  1276. temp.ContentSub = reportItem.BodyContent
  1277. temp.PublishTime, err = time.ParseInLocation(utils.FormatDateTime, reportItem.PublishTime, time.Local)
  1278. if len(v.Highlight["Title"]) > 0 {
  1279. temp.Title = v.Highlight["Title"][0]
  1280. }
  1281. if len(v.Highlight["BodyContent"]) > 0 {
  1282. temp.ContentSub = v.Highlight["BodyContent"][0]
  1283. }
  1284. //if len(v.Highlight["Categories"]) > 0 {
  1285. // if temp.ClassifyNameSecond != "" {
  1286. // temp.ClassifyNameSecond = "<span style=\"color:#E3B377\">"+temp.ClassifyNameSecond+"</span>"
  1287. // }
  1288. // if temp.ClassifyNameFirst != "" {
  1289. // temp.ClassifyNameFirst = "<span style=\"color:#E3B377\">"+temp.ClassifyNameFirst+"</span>"
  1290. // }
  1291. //}
  1292. temp.ContentSub = GetReportContentSub(temp.ContentSub, false)
  1293. if tmpClassify, ok := classifyMap[temp.ClassifyId]; ok {
  1294. temp.ReportDetailShowType = int(tmpClassify.ReportDetailShowType)
  1295. }
  1296. reportList = append(reportList, temp)
  1297. }
  1298. }
  1299. ret = new(response.ReportSearchResp)
  1300. ret.List = reportList
  1301. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1302. return
  1303. }
  1304. // GetTickerData 获取指标数据
  1305. func GetTickerData(user user.UserInfo, reportChapterId int) (ret *response.TickerData, err error) {
  1306. var errMsg string
  1307. defer func() {
  1308. if err != nil {
  1309. global.LOG.Critical(fmt.Sprintf("GetTickerData: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1310. }
  1311. }()
  1312. //查询章节类型
  1313. chapter, err := report_chapter.GetTypeIdById(reportChapterId)
  1314. if err != nil {
  1315. errMsg = err.Error()
  1316. err = errors.New("查询章节失败")
  1317. return
  1318. }
  1319. if chapter.ReportChapterId == 0 {
  1320. err = errors.New("章节不存在或者未发布")
  1321. return
  1322. }
  1323. tickers, err := report_chapter_ticker.GetTickerByChapterId(reportChapterId)
  1324. if err != nil {
  1325. errMsg = err.Error()
  1326. err = errors.New("查询章节指标失败")
  1327. return
  1328. }
  1329. var list []*response.TickerDataItem
  1330. if len(tickers) > 0 {
  1331. var tickerNames []string
  1332. for _, v := range tickers {
  1333. tickerNames = append(tickerNames, v.Ticker)
  1334. }
  1335. var dataList []*response.TickerDataItem
  1336. if chapter.TypeId == 17 {
  1337. dataList, err = daily_base_column.GetDataByBaseColumnTickers17(tickerNames)
  1338. } else {
  1339. dataList, err = daily_base_column.GetDataByBaseColumnTickers(tickerNames)
  1340. }
  1341. if err != nil {
  1342. errMsg = err.Error()
  1343. err = errors.New("查询指标数据失败")
  1344. return
  1345. }
  1346. chapterTypeInfo, tErr := report_chapter_type.GetTickerTitleByTypeId(chapter.TypeId)
  1347. if tErr != nil {
  1348. errMsg = tErr.Error()
  1349. err = errors.New("查询章节类型失败")
  1350. return
  1351. }
  1352. if len(dataList) >= 0 {
  1353. for _, v := range dataList {
  1354. temp := new(response.TickerDataItem)
  1355. temp.BaseColumnName = v.BaseColumnName
  1356. temp.Ticker = v.Ticker
  1357. temp.Date = v.Date
  1358. temp.TickerValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.TickerValue), 2)
  1359. temp.LastValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.LastValue), 2)
  1360. temp.MmValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.MmValue), 2)
  1361. temp.DdValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.DdValue), 2)
  1362. temp.WwValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.WwValue), 2)
  1363. list = append(list, temp)
  1364. }
  1365. }
  1366. tickerTitle := new(response.TickerTitleData)
  1367. tickerTitle.TickerTitle = chapterTypeInfo.TickerTitle
  1368. tickerTitle.ReportChapterTypeId = int(chapterTypeInfo.ReportChapterTypeId)
  1369. tickerTitle.ReportChapterTypeName = chapterTypeInfo.ReportChapterTypeName
  1370. tickerTitle.DataTableImage = fmt.Sprintf("http://hongze.oss-cn-shanghai.aliyuncs.com/data_table/%s.png", chapterTypeInfo.ReportChapterTypeKey)
  1371. ret = new(response.TickerData)
  1372. ret.List = list
  1373. ret.TickerTitle = tickerTitle
  1374. }
  1375. return
  1376. }
  1377. // GetReportContentSub 特殊处理contentSub
  1378. func GetReportContentSub(content string, scapeFlag bool) (contentSub string) {
  1379. if scapeFlag {
  1380. content = html.UnescapeString(content)
  1381. content = utils.TrimHtml(content) //只展示纯文本
  1382. }
  1383. contentSub = "<div style=\"-webkit-line-clamp: 3;-webkit-box-orient: vertical;display: -webkit-box;overflow: hidden;text-overflow: ellipsis;\">" + content + "</div>"
  1384. return
  1385. }
  1386. // addAliasToKeyword 品种别名
  1387. func addAliasToKeyword(keyword string) string {
  1388. if keyword == "" {
  1389. return ""
  1390. }
  1391. keywordArr := make([]string, 0)
  1392. keywordArr = append(keywordArr, keyword)
  1393. if strings.Contains(keyword, "沥青") || strings.Contains(keyword, "BU") {
  1394. keywordArr = append(keywordArr, "沥青", "BU")
  1395. }
  1396. if strings.Contains(keyword, "MEG") || strings.Contains(keyword, "EG") || strings.Contains(keyword, "乙二醇") {
  1397. keywordArr = append(keywordArr, "MEG", "EG", "乙二醇")
  1398. }
  1399. if strings.Contains(keyword, "聚酯") || strings.Contains(keyword, "长丝") || strings.Contains(keyword, "短纤") || strings.Contains(keyword, "瓶片") {
  1400. keywordArr = append(keywordArr, "聚酯", "长丝", "短纤", "瓶片")
  1401. }
  1402. if strings.Contains(keyword, "纯苯") || strings.Contains(keyword, "苯乙烯") || strings.Contains(keyword, "EB") {
  1403. keywordArr = append(keywordArr, "纯苯", "苯乙烯", "EB")
  1404. }
  1405. if strings.Contains(keyword, "甲醇") || strings.Contains(keyword, "MA") {
  1406. keywordArr = append(keywordArr, "甲醇", "MA")
  1407. }
  1408. if strings.Contains(keyword, "橡胶") || strings.Contains(keyword, "RU") {
  1409. keywordArr = append(keywordArr, "橡胶", "RU")
  1410. }
  1411. if strings.Contains(keyword, "聚乙烯") || strings.Contains(keyword, "PP") || strings.Contains(keyword, "PE") {
  1412. keywordArr = append(keywordArr, "聚乙烯", "PP", "PE")
  1413. }
  1414. if strings.Contains(keyword, "玻璃") || strings.Contains(keyword, "纯碱") || strings.Contains(keyword, "FG") || strings.Contains(keyword, "SA") {
  1415. keywordArr = append(keywordArr, "玻璃", "纯碱", "FG", "SA")
  1416. }
  1417. keyword = strings.Join(keywordArr, ",")
  1418. return keyword
  1419. }
  1420. // GetReportPptImgListByReportIdAndReportChapterId 首页展示报告汇总列表
  1421. func GetReportPptImgListByReportIdAndReportChapterId(reportId, reportChapterId int) (list []string, err error) {
  1422. list = make([]string, 0)
  1423. reportPptImgList, err := report_ppt_img.GetReportPptImgListByReportIdAndReportChapterId(reportId, reportChapterId)
  1424. for _, v := range reportPptImgList {
  1425. list = append(list, v.ImgURL)
  1426. }
  1427. return
  1428. }
  1429. // GetVarietyReportList 大宗商品报告列表
  1430. func GetVarietyReportList(user user.UserInfo, classifyId, chartPermissionId, pageIndex, pageSize int) (ret *response.ReportList, err error) {
  1431. var errMsg string
  1432. defer func() {
  1433. if err != nil {
  1434. global.LOG.Critical(fmt.Sprintf("GetCollectReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1435. }
  1436. }()
  1437. // 判断用户状态是否是正常和永续
  1438. var productAuthOk bool
  1439. companyProduct, err := company_product.GetByCompany2ProductId(user.CompanyID, 1)
  1440. if err == utils.ErrNoRow {
  1441. err = nil
  1442. }
  1443. if err != nil {
  1444. errMsg = err.Error()
  1445. err = errors.New("查询用户购买产品出错")
  1446. return
  1447. }
  1448. if companyProduct != nil {
  1449. // 无FICC权限的客户不可见
  1450. if companyProduct.CompanyProductID > 0 {
  1451. // 已购或者试用用户可见
  1452. if strings.Contains("永续,正式", companyProduct.Status) || (companyProduct.Status == "试用" && companyProduct.IsSuspend != 1) {
  1453. productAuthOk = true
  1454. }
  1455. }
  1456. }
  1457. // 查询权限的基本信息
  1458. permissionInfo, err := chart_permission.GetByChartPermissionId(chartPermissionId)
  1459. if err != nil {
  1460. errMsg = err.Error()
  1461. err = errors.New("查询权限出错")
  1462. return
  1463. }
  1464. if permissionInfo.ChartPermissionID == 0 {
  1465. err = errors.New("权限不存在")
  1466. return
  1467. }
  1468. //分类ids
  1469. var allClassifySecondIds []int
  1470. var classifySecondIds []int
  1471. allClassifySecondIds, err = chart_permission_search_key_word_mapping.GetClassifyIdsByChartPermissionId(chartPermissionId, "rddp")
  1472. if err != nil {
  1473. errMsg = err.Error()
  1474. err = errors.New("查询权限对应的分类出错")
  1475. return
  1476. }
  1477. //if len(classifyNames) > 0 {
  1478. // allClassifySecondIds, err = classify.GetSecondIdsByClassifyNames(classifyNames)
  1479. // if err != nil {
  1480. // errMsg = err.Error()
  1481. // err = errors.New("查询分类出错")
  1482. // return
  1483. // }
  1484. //}
  1485. //根据所选一级分类id查询二级分类
  1486. classifyChild, err := classify.GetChildByPid(classifyId)
  1487. if err != nil {
  1488. errMsg = err.Error()
  1489. err = errors.New("查询二级分类出错")
  1490. return
  1491. }
  1492. classifyMap := make(map[int]int, 0)
  1493. for _, c := range classifyChild {
  1494. classifyMap[c.Id] = c.Id
  1495. }
  1496. for _, id := range allClassifySecondIds {
  1497. if _, ok := classifyMap[id]; ok {
  1498. classifySecondIds = append(classifySecondIds, id)
  1499. }
  1500. }
  1501. listImgMap := make(map[int]string, 0)
  1502. for i := 0; i < len(classifyChild); i++ {
  1503. listImgMap[classifyChild[i].Id] = classifyChild[i].YbListImg
  1504. }
  1505. // 获取有效的权限id列表
  1506. var validPermissionIdList []int
  1507. if productAuthOk {
  1508. validPermissionIdList, err = company.GetValidPermissionIdListByCompany2ProductId(user.CompanyID, 1)
  1509. if err != nil && err != utils.ErrNoRow {
  1510. errMsg = err.Error()
  1511. err = errors.New("查询分类出错")
  1512. return
  1513. }
  1514. }
  1515. var authOk bool
  1516. if len(validPermissionIdList) > 0 {
  1517. checkLoop:
  1518. for _, validPerid := range validPermissionIdList {
  1519. if chartPermissionId == validPerid {
  1520. authOk = true
  1521. break checkLoop
  1522. }
  1523. }
  1524. }
  1525. //// 查询晨报和周报相对应的章节ID
  1526. //reportChapterTypeIds, err := report_chapter_type_permission.GetTypeIdsByChartPermissionId(chartPermissionId)
  1527. //if err != nil {
  1528. // errMsg = err.Error()
  1529. // err = errors.New("查询权限对应的章节出错")
  1530. // return
  1531. //}
  1532. var reportList []*report.Report
  1533. var total int64
  1534. if len(classifySecondIds) > 0 {
  1535. if productAuthOk {
  1536. offset := (pageIndex - 1) * pageSize
  1537. reportList, err = report.GetCommoditiesReportCollectListByPermission(classifySecondIds, offset, pageSize)
  1538. if err != nil {
  1539. errMsg = err.Error()
  1540. err = errors.New("查询报告信息出错")
  1541. return
  1542. }
  1543. total, err = report.GetCommoditiesReportCollectCountByPermission(classifySecondIds)
  1544. if err != nil {
  1545. errMsg = err.Error()
  1546. err = errors.New("查询报告总数出错")
  1547. return
  1548. }
  1549. }
  1550. }
  1551. var list []*response.ReportListItem
  1552. for _, r := range reportList {
  1553. // 封面图-默认取二级分类的图片,二级分类图片没有(如晨周报)则取一级
  1554. coverImg := listImgMap[r.ClassifyIdSecond]
  1555. if coverImg == "" {
  1556. coverImg = listImgMap[r.ClassifyIdFirst]
  1557. }
  1558. var VideoList []*response.VideoListItem
  1559. videoItem := response.VideoListItem{
  1560. VideoUrl: r.VideoUrl,
  1561. VideoName: r.VideoName,
  1562. VideoPlaySeconds: r.VideoPlaySeconds,
  1563. VideoImg: coverImg,
  1564. }
  1565. VideoList = append(VideoList, &videoItem)
  1566. stageStr := r.StageStr
  1567. if stageStr == "" {
  1568. stageStr = strconv.Itoa(r.Stage)
  1569. }
  1570. item := response.ReportListItem{
  1571. ReportId: r.Id,
  1572. ClassifyIdFirst: r.ClassifyIdFirst,
  1573. ClassifyNameFirst: r.ClassifyNameFirst,
  1574. ClassifyIdSecond: r.ClassifyIdSecond,
  1575. ClassifyNameSecond: r.ClassifyNameSecond,
  1576. Title: r.Title,
  1577. Abstract: r.Abstract,
  1578. Author: r.Author,
  1579. ReportImgUrl: coverImg,
  1580. PublishTime: r.PublishTime,
  1581. Stage: r.Stage,
  1582. VideoList: VideoList,
  1583. AuthOk: authOk,
  1584. TitleInfo: fmt.Sprintf("【第%s期|FICC|%s】", stageStr, r.ClassifyNameSecond),
  1585. }
  1586. list = append(list, &item)
  1587. }
  1588. ret = new(response.ReportList)
  1589. ret.List = list
  1590. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1591. return
  1592. }
  1593. // GetMinClassify
  1594. // @Description: 获取最小分类ID
  1595. // @author: Roc
  1596. // @datetime 2024-06-20 09:23:19
  1597. // @param reportInfo *models.Report
  1598. // @return minClassifyId int
  1599. // @return minClassifyName string
  1600. // @return err error
  1601. func GetMinClassify(reportInfo *report.Report) (minClassifyId int, minClassifyName string, err error) {
  1602. defer func() {
  1603. if err != nil {
  1604. global.FILE_LOG.Error("获取最小分类ID失败,报告ID:%d,Err:%s", reportInfo.Id, err.Error())
  1605. }
  1606. }()
  1607. minClassifyId = reportInfo.ClassifyIdThird
  1608. minClassifyName = reportInfo.ClassifyNameThird
  1609. if minClassifyId <= 0 {
  1610. minClassifyId = reportInfo.ClassifyIdSecond
  1611. minClassifyName = reportInfo.ClassifyNameSecond
  1612. }
  1613. if minClassifyId <= 0 {
  1614. minClassifyId = reportInfo.ClassifyIdFirst
  1615. minClassifyName = reportInfo.ClassifyNameFirst
  1616. }
  1617. if minClassifyId <= 0 {
  1618. err = errors.New("分类异常")
  1619. }
  1620. return
  1621. }
  1622. // GetCommoditiesReportList 获取大宗商品报告列表
  1623. //func GetCommoditiesReportList(user user.UserInfo, chartPermissionId, pageIndex, pageSize int) (ret *response.ReportList, err error) {
  1624. // var errMsg string
  1625. // defer func() {
  1626. // if err != nil {
  1627. // global.LOG.Critical(fmt.Sprintf("GetReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1628. // }
  1629. // }()
  1630. //
  1631. // // 判断用户状态是否是正常和永续
  1632. // var productAuthOk bool
  1633. // companyProduct, err := company_product.GetByCompany2ProductId(user.CompanyID, 1)
  1634. // if err == utils.ErrNoRow {
  1635. // err = nil
  1636. // }
  1637. // if err != nil {
  1638. // errMsg = err.Error()
  1639. // err = errors.New("查询用户购买产品出错")
  1640. // return
  1641. // }
  1642. // if companyProduct != nil {
  1643. // // 无FICC权限的客户不可见
  1644. // if companyProduct.CompanyProductID > 0 {
  1645. // // 已购或者试用用户可见
  1646. // if strings.Contains("永续,正式", companyProduct.Status) || (companyProduct.Status == "试用" && companyProduct.IsSuspend != 1) {
  1647. // productAuthOk = true
  1648. // }
  1649. // }
  1650. // }
  1651. //
  1652. // // 查询权限的基本信息
  1653. // permissionInfo, err := chart_permission.GetByChartPermissionId(chartPermissionId)
  1654. // if err != nil {
  1655. // errMsg = err.Error()
  1656. // err = errors.New("查询权限出错")
  1657. // return
  1658. // }
  1659. //
  1660. // if permissionInfo.ChartPermissionID == 0 {
  1661. // err = errors.New("权限不存在")
  1662. // return
  1663. // }
  1664. // // 除了晨报和周报以外的其他报告
  1665. // classifyNames, err := chart_permission_search_key_word_mapping.GetClassifyIdsByChartPermissionId(chartPermissionId, "two_week")
  1666. // if err != nil {
  1667. // errMsg = err.Error()
  1668. // err = errors.New("查询权限对应的分类出错")
  1669. // return
  1670. // }
  1671. //
  1672. // var classifySecondIds []int
  1673. // if len(classifyNames) > 0 {
  1674. // classifySecondIds, err = classify.GetSecondIdsByClassifyNames(classifyNames)
  1675. // if err != nil {
  1676. // errMsg = err.Error()
  1677. // err = errors.New("查询分类出错")
  1678. // return
  1679. // }
  1680. // }
  1681. //
  1682. // var condition string
  1683. // pars := make([]interface{}, 0)
  1684. //
  1685. // classifyParent, err := classify.GetByClassifyId(classifyIdFirst)
  1686. // if err != nil {
  1687. // errMsg = err.Error()
  1688. // err = errors.New("分类查询出错")
  1689. // return
  1690. // }
  1691. // if classifyParent.Id == 0 {
  1692. // err = errors.New("该分类不存在")
  1693. // return
  1694. // }
  1695. // condition = `classify_id_first = ? and state IN (2, 6)`
  1696. // pars = append(pars, classifyIdFirst)
  1697. // permissionMap := make(map[string][]int)
  1698. // checkPermissionMap := make(map[string]bool)
  1699. // permissionImageMap := make(map[string]string)
  1700. // chartPermissionImageMap := make(map[int]string)
  1701. // var classifyIdSeconds []int
  1702. // //var reportImgUrl string
  1703. //
  1704. // chartPermissionList, err := chart_permission.GetFiccListExceptTacticByProductId()
  1705. // if err != nil {
  1706. // errMsg = err.Error()
  1707. // err = errors.New("分类查询出错")
  1708. // return
  1709. // }
  1710. //
  1711. // if len(chartPermissionList) > 0 {
  1712. // for _, v := range chartPermissionList {
  1713. // chartPermissionImageMap[int(v.ChartPermissionID)] = v.YbImgUrl
  1714. // }
  1715. // }
  1716. //
  1717. // if classifyIdSecond > 0 && keyWord == "" {
  1718. // classifyInfo, tErr := classify.GetByClassifyId(classifyIdSecond)
  1719. // if tErr != nil {
  1720. // errMsg = tErr.Error()
  1721. // err = errors.New("分类查询出错")
  1722. // return
  1723. // }
  1724. // if classifyInfo.Id == 0 {
  1725. // err = errors.New("该二级分类不存在")
  1726. // return
  1727. // }
  1728. //
  1729. // condition += " AND classify_id_second = ?"
  1730. // pars = append(pars, classifyIdSecond)
  1731. // //查询二级分类对应的权限
  1732. // permissionIds, tErr := chart_permission_search_key_word_mapping.GetChartPermissionIdsByKeyWord(classifyInfo.ClassifyName)
  1733. // if tErr != nil {
  1734. // errMsg = tErr.Error()
  1735. // err = errors.New("分类权限查询出错")
  1736. // return
  1737. // }
  1738. // permissionMap[classifyInfo.ClassifyName] = permissionIds
  1739. // //if len(permissionIds) > 0 {
  1740. // // for _, v := range permissionIds {
  1741. // // reportImgUrl = chartPermissionImageMap[v]
  1742. // // }
  1743. // //}
  1744. //
  1745. // } else {
  1746. // if classifyParent.ClassifyName == "晨报" || classifyParent.ClassifyName == "周报" {
  1747. // //reportImgUrl = chartPermissionImageMap[1]
  1748. // classifyIdSeconds = append(classifyIdSeconds, 0)
  1749. // }
  1750. //
  1751. // chartPermissions, tErr := chart_permission_search_key_word_mapping.GetChartPermissionByFrom("rddp")
  1752. // if tErr != nil {
  1753. // errMsg = tErr.Error()
  1754. // err = errors.New("分类权限查询出错")
  1755. // return
  1756. // }
  1757. //
  1758. // if len(chartPermissions) > 0 {
  1759. // for _, v := range chartPermissions {
  1760. // permissionMap[v.KeyWord] = append(permissionMap[v.KeyWord], v.ChartPermissionId)
  1761. // permissionImageMap[v.KeyWord] = chartPermissionImageMap[v.ChartPermissionId]
  1762. // }
  1763. // }
  1764. //
  1765. // //获取二级分类的所有头像
  1766. // classifyList, tErr := classify.GetListByPid(classifyIdFirst)
  1767. // if tErr != nil {
  1768. // errMsg = tErr.Error()
  1769. // err = errors.New("二级分类查询出错")
  1770. // return
  1771. // }
  1772. //
  1773. // for _, v := range classifyList {
  1774. // classifyIdSeconds = append(classifyIdSeconds, v.Id)
  1775. // }
  1776. //
  1777. // if len(classifyIdSeconds) == 0 && classifyParent.ClassifyName != "晨报" && classifyParent.ClassifyName != "周报" {
  1778. // ret = new(response.ReportList)
  1779. // ret.Paging = response.GetPaging(pageIndex, pageSize, 0)
  1780. // return
  1781. // }
  1782. // condition += ` AND classify_id_second IN ? `
  1783. // pars = append(pars, classifyIdSeconds)
  1784. // }
  1785. //
  1786. // // 获取有效的权限id列表
  1787. // var validPermissionIdList []int
  1788. // if productAuthOk {
  1789. // validPermissionIdList, err = company.GetValidPermissionIdListByCompany2ProductId(user.CompanyID, 1)
  1790. // if err != nil && err != utils.ErrNoRow {
  1791. // errMsg = err.Error()
  1792. // err = errors.New("查询分类出错")
  1793. // return
  1794. // }
  1795. // }
  1796. //
  1797. // if len(validPermissionIdList) > 0 {
  1798. // for classifyName, perIds := range permissionMap {
  1799. // checkLoop:
  1800. // for _, checkId := range perIds {
  1801. // for _, validPerid := range validPermissionIdList {
  1802. // if checkId == validPerid {
  1803. // checkPermissionMap[classifyName] = true
  1804. // break checkLoop
  1805. // }
  1806. // }
  1807. // }
  1808. // }
  1809. // }
  1810. //
  1811. // var total int64
  1812. // var list []*report.Report
  1813. // if keyWord == "" {
  1814. // offset := (pageIndex - 1) * pageSize
  1815. // list, err = report.GetReportList(condition, pars, offset, pageSize)
  1816. // if err != nil {
  1817. // errMsg = err.Error()
  1818. // err = errors.New("报告查询出错")
  1819. // return
  1820. // }
  1821. // total, err = report.GetReportListCount(condition, pars)
  1822. // if err != nil {
  1823. // errMsg = err.Error()
  1824. // err = errors.New("查询报告总数出错")
  1825. // return
  1826. // }
  1827. // } else {
  1828. // if classifyIdSecond > 0 {
  1829. // classifyIdSeconds = append(classifyIdSeconds, classifyIdSecond)
  1830. // }
  1831. // if classifyParent.ClassifyName == "晨报" || classifyParent.ClassifyName == "周报" {
  1832. // classifyIdSeconds = append(classifyIdSeconds, 0)
  1833. // }
  1834. // searchResp, total1, tErr := elasticService.ReportListSearch(keyWord, classifyIdFirst, classifyIdSeconds, pageIndex, pageSize)
  1835. // if tErr != nil {
  1836. // errMsg = tErr.Error()
  1837. // err = errors.New("查询失败")
  1838. // return
  1839. // }
  1840. // total = int64(total1)
  1841. // if searchResp.Hits != nil && total > 0 {
  1842. // var reportIds []int
  1843. // for _, v := range searchResp.Hits.Hits {
  1844. // temp := new(report.Report)
  1845. // itemJson, tmpErr := v.Source.MarshalJSON()
  1846. // if tmpErr != nil {
  1847. // errMsg = tmpErr.Error()
  1848. // err = errors.New("解析出错")
  1849. // return
  1850. // }
  1851. // reportItem := new(response.EsReportItem)
  1852. // tmpErr = json.Unmarshal(itemJson, &reportItem)
  1853. // if tmpErr != nil {
  1854. // errMsg = tmpErr.Error()
  1855. // err = errors.New("解析json出错")
  1856. // return
  1857. // }
  1858. // temp.Id = reportItem.ReportId
  1859. // reportIds = append(reportIds, reportItem.ReportId)
  1860. // temp.ClassifyIdFirst = reportItem.ClassifyIdFirst
  1861. // temp.ClassifyNameFirst = reportItem.ClassifyNameFirst
  1862. // temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
  1863. // temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
  1864. // if len(v.Highlight["ClassifyNameSecond"]) > 0 {
  1865. // temp.ClassifyNameSecond = v.Highlight["ClassifyNameSecond"][0]
  1866. // }
  1867. // temp.Abstract = reportItem.Abstract
  1868. // stageInt, _ := strconv.Atoi(reportItem.StageStr)
  1869. // temp.Stage = stageInt
  1870. // temp.StageStr = reportItem.StageStr
  1871. // temp.Title = reportItem.Title
  1872. // temp.PublishTime, err = time.ParseInLocation(utils.FormatDateTime, reportItem.PublishTime, time.Local)
  1873. // if len(v.Highlight["Title"]) > 0 {
  1874. // temp.Title = v.Highlight["Title"][0]
  1875. // }
  1876. // if len(v.Highlight["Abstract"]) > 0 {
  1877. // temp.Abstract = v.Highlight["Abstract"][0]
  1878. // }
  1879. // if len(v.Highlight["StageStr"]) > 0 {
  1880. // temp.StageStr = v.Highlight["StageStr"][0]
  1881. // }
  1882. // list = append(list, temp)
  1883. // }
  1884. // reportInfoList, tmpErr := report.GetByReportIds(reportIds)
  1885. // if tmpErr != nil {
  1886. // errMsg = tmpErr.Error()
  1887. // err = errors.New("查询报告出错")
  1888. // return
  1889. // }
  1890. // reportListMap := make(map[int]*report.Report)
  1891. // for _, temp := range reportInfoList {
  1892. // reportListMap[temp.Id] = temp
  1893. // }
  1894. // for k, reportDetail := range list {
  1895. // if v, ok := reportListMap[reportDetail.Id]; ok {
  1896. // list[k].CreateTime = v.CreateTime
  1897. // }
  1898. // }
  1899. // }
  1900. // }
  1901. //
  1902. // var reportList []*response.ReportListItem
  1903. // if len(list) > 0 {
  1904. // // 封面图
  1905. // classifyList, e := classify.GetClassifyList()
  1906. // if e != nil {
  1907. // err = errors.New("获取报告分类列表失败" + e.Error())
  1908. // return
  1909. // }
  1910. // listImgMap := make(map[int]string, 0)
  1911. // classifyLen := len(classifyList)
  1912. // for i := 0; i < classifyLen; i++ {
  1913. // listImgMap[classifyList[i].Id] = classifyList[i].YbListImg
  1914. // }
  1915. //
  1916. // var videoReportIds []int
  1917. // videoMap := make(map[int][]*response.VideoListItem)
  1918. // weekAuthMap := make(map[int]bool)
  1919. // if classifyParent.ClassifyName == "晨报" && productAuthOk {
  1920. // //获取晨报的音频列表
  1921. // videoMap, _, errMsg, err = GetReportChapterVideoList(validPermissionIdList, classifyParent.ClassifyName, list)
  1922. // if err != nil {
  1923. // return
  1924. // }
  1925. // } else if classifyParent.ClassifyName == "周报" {
  1926. // //查询所有权限typeID
  1927. // //如果存在可以查看的章节ID
  1928. // for _, reportInfo := range list {
  1929. // videoReportIds = append(videoReportIds, reportInfo.Id)
  1930. // }
  1931. // // 判断周报权限\查询周报的音频列表
  1932. // videoMap, weekAuthMap, errMsg, err = GetReportChapterVideoList(validPermissionIdList, classifyParent.ClassifyName, list)
  1933. // if err != nil {
  1934. // return
  1935. // }
  1936. // }
  1937. // // 以下分类图标特殊处理 =_=!
  1938. // //reportImgMap := map[string]string{
  1939. // // "晨报": "report_list_chen.png",
  1940. // // "周报": "report_list_zhou.png",
  1941. // // "月报": "report_list_yue.png",
  1942. // // "大事点评": "report_list_dashidianping.png",
  1943. // // "会议纪要": "report_list_huiyijiyao.png",
  1944. // // "年报合集": "report_list_nianbaoheji.png",
  1945. // //}
  1946. // for _, reportInfo := range list {
  1947. // reportItem := new(response.ReportListItem)
  1948. // reportItem.ReportId = reportInfo.Id
  1949. // // 样式限制行数
  1950. // reportItem.Title = "<div style=\"-webkit-line-clamp: 2;-webkit-box-orient: vertical;display: -webkit-box;overflow: hidden;text-overflow: ellipsis;\">" + reportInfo.Title + "</div>"
  1951. // reportItem.PublishTime = reportInfo.PublishTime
  1952. // reportItem.ClassifyNameFirst = reportInfo.ClassifyNameFirst
  1953. // reportItem.ClassifyNameSecond = reportInfo.ClassifyNameSecond
  1954. // reportItem.ClassifyIdFirst = reportInfo.ClassifyIdFirst
  1955. // reportItem.ClassifyIdSecond = reportInfo.ClassifyIdSecond
  1956. // reportItem.Stage = reportInfo.Stage
  1957. // reportItem.Abstract = reportInfo.Abstract
  1958. // if reportInfo.Abstract != "" {
  1959. // reportItem.Abstract = "<div style=\"overflow: hidden;white-space: nowrap;text-overflow: ellipsis;\">" + reportInfo.Abstract + "</div>"
  1960. // }
  1961. // reportItem.Author = reportInfo.Author
  1962. // stageStr := reportInfo.StageStr
  1963. // if stageStr == "" {
  1964. // stageStr = strconv.Itoa(reportInfo.Stage)
  1965. // }
  1966. // reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】", stageStr, reportItem.ClassifyNameSecond)
  1967. // //trimClassifyNameSecond := utils.TrimHtml(reportInfo.ClassifyNameSecond)
  1968. // if reportInfo.ClassifyNameFirst == "晨报" || reportInfo.ClassifyNameFirst == "周报" || classifyIdSecond > 0 {
  1969. // //reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + reportImgUrl
  1970. // reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】", stageStr, reportItem.ClassifyNameFirst)
  1971. // }
  1972. // //else if url, ok := permissionImageMap[trimClassifyNameSecond]; ok {
  1973. // // reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + url
  1974. // //}
  1975. // //if img, ok := reportImgMap[reportInfo.ClassifyNameFirst]; ok {
  1976. // // reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + img
  1977. // //}
  1978. // // 封面图-默认取二级分类的图片,二级分类图片没有(如晨周报)则取一级
  1979. // coverImg := listImgMap[reportInfo.ClassifyIdSecond]
  1980. // if coverImg == "" {
  1981. // coverImg = listImgMap[reportInfo.ClassifyIdFirst]
  1982. // }
  1983. // reportItem.ReportImgUrl = coverImg
  1984. //
  1985. // if classifyParent.ClassifyName == "晨报" && productAuthOk {
  1986. // // 查询当前晨报的所有音频
  1987. // if vList, ok := videoMap[reportInfo.Id]; ok {
  1988. // for _, vd := range vList {
  1989. // vd.VideoImg = reportItem.ReportImgUrl
  1990. // }
  1991. // reportItem.VideoList = vList
  1992. // }
  1993. // reportItem.AuthOk = productAuthOk
  1994. // } else if classifyParent.ClassifyName == "周报" {
  1995. // if wAuth, ok := weekAuthMap[reportInfo.Id]; ok {
  1996. // reportItem.AuthOk = wAuth
  1997. // if wAuth {
  1998. // // 查询当前晨报的所有音频
  1999. // if vList, ok2 := videoMap[reportInfo.Id]; ok2 {
  2000. // for _, vd := range vList {
  2001. // vd.VideoImg = reportItem.ReportImgUrl
  2002. // }
  2003. // reportItem.VideoList = vList
  2004. // }
  2005. // }
  2006. // }
  2007. // } else if authOk, ok := checkPermissionMap[reportInfo.ClassifyNameSecond]; ok && authOk {
  2008. // if reportInfo.VideoUrl != "" {
  2009. // videoTemp := new(response.VideoListItem)
  2010. // videoTemp.VideoUrl = reportInfo.VideoUrl
  2011. // videoTemp.VideoName = reportInfo.VideoName
  2012. // if reportInfo.VideoName == "" {
  2013. // videoTemp.VideoName = reportInfo.Title
  2014. // }
  2015. // videoTemp.VideoPlaySeconds = reportInfo.VideoPlaySeconds
  2016. // videoTemp.VideoImg = reportItem.ReportImgUrl
  2017. // reportItem.VideoList = append(reportItem.VideoList, videoTemp)
  2018. // }
  2019. // reportItem.AuthOk = authOk
  2020. // }
  2021. //
  2022. // reportList = append(reportList, reportItem)
  2023. // }
  2024. //
  2025. // }
  2026. // ret = new(response.ReportList)
  2027. // ret.List = reportList
  2028. // ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  2029. // return
  2030. //}