report.go 70 KB

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