ficc_report.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. package services
  2. //FICC研报
  3. import (
  4. "errors"
  5. "fmt"
  6. "hongze/hongze_cygx/models"
  7. "hongze/hongze_cygx/models/ficc_report"
  8. "hongze/hongze_cygx/utils"
  9. "html"
  10. "strconv"
  11. "strings"
  12. "time"
  13. )
  14. // GetMinClassify
  15. // @Description: 获取最小分类ID
  16. // @author: Roc
  17. // @datetime 2024-06-20 09:23:19
  18. // @param reportInfo *models.Report
  19. // @return minClassifyId int
  20. // @return minClassifyName string
  21. // @return err error
  22. func GetMinClassify(reportInfo *ficc_report.Report) (minClassifyId int, minClassifyName string, err error) {
  23. defer func() {
  24. if err != nil {
  25. go utils.SendAlarmMsg(fmt.Sprint("获取最小分类ID失败,报告ID:%d,Err:%s", reportInfo.Id, err.Error()), 2)
  26. }
  27. }()
  28. minClassifyId = reportInfo.ClassifyIdThird
  29. minClassifyName = reportInfo.ClassifyNameThird
  30. if minClassifyId <= 0 {
  31. minClassifyId = reportInfo.ClassifyIdSecond
  32. minClassifyName = reportInfo.ClassifyNameSecond
  33. }
  34. if minClassifyId <= 0 {
  35. minClassifyId = reportInfo.ClassifyIdFirst
  36. minClassifyName = reportInfo.ClassifyNameFirst
  37. }
  38. if minClassifyId <= 0 {
  39. err = errors.New("分类异常")
  40. }
  41. return
  42. }
  43. // 获取报告详情
  44. func GetReportDetail(userinfo *models.WxUserItem, reportId int) (reportDetail ficc_report.ReportDetail, err error) {
  45. //var errMsg string
  46. defer func() {
  47. if err != nil {
  48. fmt.Println(err)
  49. go utils.SendAlarmMsg(fmt.Sprint("获取研报详情失败 GetReportDetail ,err:", err.Error(), "ReportId:", reportId), 2)
  50. }
  51. }()
  52. detailArticle, e := models.GetArticleDetailByReportId(reportId)
  53. if e != nil {
  54. err = errors.New("报告查询出错" + e.Error())
  55. return
  56. }
  57. reportInfo, e := ficc_report.GetByReportId(reportId)
  58. if e != nil {
  59. //errMsg = err.Error()
  60. err = errors.New("报告查询出错" + e.Error())
  61. return
  62. }
  63. if reportInfo.Id == 0 {
  64. err = errors.New("报告不存在")
  65. return
  66. }
  67. if reportInfo.State != 2 && reportInfo.State != 6 {
  68. err = errors.New("报告未发布")
  69. return
  70. }
  71. // 获取最小分类
  72. minClassifyId, _, err := GetMinClassify(reportInfo)
  73. // 判断报告是否属于专栏报告
  74. firstClassify, e := ficc_report.GetByClassifyId(reportInfo.ClassifyIdFirst)
  75. if e != nil {
  76. err = errors.New("报告一级分类有误")
  77. return
  78. }
  79. // 最小分类
  80. var minClassify *ficc_report.Classify
  81. if reportInfo.ClassifyIdFirst == minClassifyId {
  82. minClassify = firstClassify
  83. } else {
  84. minClassify, e = ficc_report.GetByClassifyId(minClassifyId)
  85. if e != nil {
  86. err = errors.New("报告最小层级分类有误")
  87. return
  88. }
  89. }
  90. //判断是否已经申请过
  91. applyCount, e := models.GetApplyRecordCount(userinfo.UserId)
  92. if e != nil {
  93. err = errors.New("判断是否已申请过试用失败")
  94. return
  95. }
  96. var hasPermission int
  97. if userinfo.CompanyId > 1 {
  98. companyPermission, e := models.GetCompanyPermission(userinfo.CompanyId)
  99. if e != nil {
  100. err = errors.New("获取用户权限信息失败")
  101. return
  102. }
  103. if companyPermission == "" {
  104. if applyCount > 0 {
  105. hasPermission = 5
  106. } else {
  107. hasPermission = 2
  108. }
  109. } else {
  110. var hasPersion bool
  111. slice := strings.Split(companyPermission, ",")
  112. if utils.InArrayByStr(slice, "周期") {
  113. hasPersion = true
  114. }
  115. if hasPersion {
  116. hasPermission = 1
  117. } else { //无该行业权限
  118. companyDetail, e := models.GetCompanyDetailById(userinfo.CompanyId)
  119. if e == nil && companyDetail.ProductId == 1 {
  120. hasPermission = 2
  121. } else {
  122. hasPermission = 3
  123. }
  124. }
  125. }
  126. //获取销售手机号
  127. sellerItem, e := models.GetSellerByCompanyId(userinfo.CompanyId)
  128. if e != nil && e.Error() != utils.ErrNoRow() {
  129. err = errors.New("获取销售数据失败")
  130. return
  131. }
  132. if sellerItem != nil {
  133. reportDetail.SellerMobile = sellerItem.Mobile
  134. reportDetail.SellerName = sellerItem.RealName
  135. }
  136. } else { //潜在客户
  137. if applyCount > 0 {
  138. hasPermission = 5
  139. } else {
  140. hasPermission = 4
  141. }
  142. }
  143. reportDetail.HasPermission = hasPermission
  144. //判断权限
  145. var authOk bool
  146. var reportChapterIdList []int
  147. if reportInfo.HasChapter == 1 {
  148. if reportInfo.ClassifyNameFirst == "晨报" {
  149. //authOk, permissionCheckInfo, err = CheckDayReportPermission(userinfo, productAuthOk)
  150. } else {
  151. _, _, _, reportChapterIdList, err = CheckWeekReportPermission(userinfo, reportId, true)
  152. }
  153. }
  154. if hasPermission == 1 {
  155. authOk = true
  156. }
  157. reportItem := new(ficc_report.ReportItem)
  158. reportItem.ReportId = reportInfo.Id
  159. reportItem.Title = reportInfo.Title
  160. reportItem.PublishTime = reportInfo.PublishTime
  161. reportItem.ClassifyNameFirst = reportInfo.ClassifyNameFirst
  162. reportItem.ClassifyNameSecond = reportInfo.ClassifyNameSecond
  163. reportItem.Stage = reportInfo.Stage
  164. reportItem.Abstract = reportInfo.Abstract
  165. reportItem.ContentSub = html.UnescapeString(reportInfo.ContentSub)
  166. reportItem.Frequency = reportInfo.Frequency
  167. reportItem.VideoName = reportInfo.VideoName
  168. reportItem.HasChapter = reportInfo.HasChapter
  169. reportItem.ReportLayout = reportInfo.ReportLayout
  170. reportItem.HeadImg = reportInfo.HeadImg
  171. reportItem.EndImg = reportInfo.EndImg
  172. reportItem.CanvasColor = reportInfo.CanvasColor
  173. reportItem.ArticleId = detailArticle.ArticleId
  174. reportItem.Disclaimer = GetConfigCodeDisclaimer()
  175. //版头版尾样式
  176. {
  177. if reportInfo.HeadResourceId > 0 {
  178. headResource, tmpErr := ficc_report.GetResourceItemById(reportInfo.HeadResourceId)
  179. if tmpErr != nil {
  180. err = tmpErr
  181. return
  182. }
  183. reportItem.HeadImg = headResource.ImgURL
  184. reportItem.HeadStyle = headResource.Style
  185. }
  186. if reportInfo.EndResourceId > 0 {
  187. endResource, tmpErr := ficc_report.GetResourceItemById(reportInfo.EndResourceId)
  188. if tmpErr != nil {
  189. err = tmpErr
  190. return
  191. }
  192. reportItem.EndImg = endResource.ImgURL
  193. reportItem.EndStyle = endResource.Style
  194. }
  195. }
  196. if reportInfo.VideoName == "" && reportInfo.VideoUrl != "" {
  197. reportItem.VideoName = reportInfo.Title
  198. }
  199. reportItem.VideoSize = reportInfo.VideoSize
  200. reportItem.VideoPlaySeconds = reportInfo.VideoPlaySeconds
  201. reportItem.Author = reportInfo.Author
  202. // 分享背景图取二级分类配图, 二级没有配图时使用一级配图, 一级也没有使用默认图
  203. reportItem.ShareBgImg = utils.DEFAULT_REPORT_SHARE_BG_IMG
  204. secondClassify, e := ficc_report.GetByClassifyId(reportInfo.ClassifyIdSecond)
  205. if e != nil {
  206. err = errors.New("报告二级分类有误")
  207. return
  208. }
  209. if secondClassify.YbShareBgImg != "" {
  210. reportItem.ShareBgImg = secondClassify.YbShareBgImg
  211. } else {
  212. if firstClassify.YbShareBgImg != "" {
  213. reportItem.ShareBgImg = firstClassify.YbShareBgImg
  214. }
  215. }
  216. var reportTypeList []*ficc_report.ReportChapterListItem
  217. if reportInfo.HasChapter == 1 {
  218. //(晨报和周报的banner图)
  219. if reportInfo.ClassifyNameFirst == "晨报" {
  220. reportItem.BannerUrl = utils.ALIYUN_YBIMG_HOST + "report_banner_day.jpg"
  221. } else {
  222. reportItem.BannerUrl = utils.ALIYUN_YBIMG_HOST + "report_banner_week.jpg"
  223. }
  224. // 如果还没有配置banner图,则取晨报的
  225. if reportItem.BannerUrl == `` {
  226. reportItem.BannerUrl = utils.ALIYUN_YBIMG_HOST + "report_banner_day.jpg"
  227. }
  228. if authOk {
  229. reportTypeList, err = GetChapterListByReportChapterIdList(reportInfo.ClassifyNameFirst, reportInfo.Id, reportChapterIdList)
  230. if err != nil {
  231. return
  232. }
  233. }
  234. } else {
  235. // 音频播放条图片用分类图片
  236. //reportItem.VideoImg = utils.HZ_DEFAULT_AVATAR
  237. //permissionIds, tmpErr := chart_permission_search_key_word_mapping.GetChartPermissionIdsByKeyWord(reportInfo.ClassifyIdSecond)
  238. //if tmpErr != nil {
  239. // errMsg = tmpErr.Error()
  240. // err = errors.New("查询报告权限失败")
  241. // return
  242. //}
  243. //if len(permissionIds) > 0 {
  244. // chartPermission, tmpErr := chart_permission.GetListByIds(permissionIds)
  245. // if tmpErr != nil {
  246. // errMsg = tmpErr.Error()
  247. // err = errors.New("查询品种信息失败")
  248. // return
  249. // }
  250. // lenChart := len(chartPermission)
  251. // for i := 0; i < lenChart; i++ {
  252. // if chartPermission[i].YbImgUrl != "" {
  253. // reportItem.VideoImg = utils.ALIYUN_YBIMG_HOST + chartPermission[i].YbImgUrl
  254. // break
  255. // }
  256. // }
  257. //}
  258. }
  259. //如果有权限则展示content
  260. if authOk {
  261. reportItem.Content = html.UnescapeString(reportInfo.Content)
  262. reportItem.VideoUrl = reportInfo.VideoUrl
  263. }
  264. reportDetail.ReportInfo = reportItem
  265. reportDetail.ReportChapterList = reportTypeList
  266. //reportDetail.PermissionCheck = &permissionCheckInfo
  267. reportDetail.AuthOk = authOk
  268. //reportDetail.LikeNum = likeNum
  269. //reportDetail.LikeEnabled = likeEnabled
  270. reportDetail.ReportShowType = int(firstClassify.ShowType)
  271. reportDetail.ReportDetailShowType = int(minClassify.ReportDetailShowType)
  272. // 如果分类配置是列表展示,那么就移除content内容
  273. if minClassify.ReportDetailShowType == 2 {
  274. for _, v := range reportTypeList {
  275. v.Content = ``
  276. }
  277. } else {
  278. for _, v := range reportTypeList {
  279. v.Content = html.UnescapeString(v.Content)
  280. }
  281. }
  282. return
  283. }
  284. // CheckWeekReportPermission
  285. // @Description: 验证周报的权限(并获取拥有权限的章节id列表)
  286. // @author: Roc
  287. // @datetime 2024-06-24 11:06:52
  288. // @param userInfo user.UserInfo
  289. // @param reportId int
  290. // @param productAuthOk bool
  291. // @return authOk bool
  292. // @return permissionCheckInfo response.PermissionCheckInfo
  293. // @return validTypeIds []int 分类关联的章节类型ID列表
  294. // @return reportChapterIdList []int 并获取拥有权限的章节id列表
  295. // @return err error
  296. func CheckWeekReportPermission(userInfo *models.WxUserItem, reportId int, productAuthOk bool) (authOk bool, permissionCheckInfo ficc_report.PermissionCheckInfo, validTypeIds, reportChapterIdList []int, err error) {
  297. var permissionIds []int
  298. //var validPermissionIds []int //最后允许显示的章节
  299. // 当前报告的品种与章节列表的map
  300. permissionChapterList := make(map[int][]int)
  301. permissionIdMap := make(map[int]bool)
  302. typeIdMap := make(map[int]bool)
  303. reportChapterIdMap := make(map[int]bool)
  304. if productAuthOk {
  305. reportChapterMappingList, e := ficc_report.GetReportChapterPermissionMappingItemListByReportId(reportId)
  306. if e != nil && e.Error() != utils.ErrNoRow() {
  307. err = errors.New(e.Error())
  308. return
  309. }
  310. for _, v := range reportChapterMappingList {
  311. if _, ok := permissionIdMap[v.ChartPermissionId]; !ok {
  312. permissionIdMap[v.ChartPermissionId] = true
  313. permissionIds = append(permissionIds, v.ChartPermissionId)
  314. }
  315. if _, ok := typeIdMap[v.TypeId]; !ok {
  316. typeIdMap[v.TypeId] = true
  317. validTypeIds = append(validTypeIds, v.TypeId)
  318. }
  319. tmpList, ok := permissionChapterList[v.ChartPermissionId]
  320. if !ok {
  321. tmpList = make([]int, 0)
  322. }
  323. permissionChapterList[v.ChartPermissionId] = append(tmpList, v.ReportChapterId)
  324. if _, ok := reportChapterIdMap[v.ReportChapterId]; !ok {
  325. reportChapterIdMap[v.ReportChapterId] = true
  326. reportChapterIdList = append(reportChapterIdList, v.ReportChapterId) //走权益的校验权限,到这里的权限都可以用
  327. }
  328. }
  329. }
  330. return
  331. }
  332. // GetChapterListByReportChapterIdList
  333. // @Description: 根据报告获取章节列表
  334. // @author: Roc
  335. // @datetime 2024-06-24 11:23:36
  336. // @param classifyNameFirst string
  337. // @param reportId int
  338. // @param reportChapterIdList []int
  339. // @param reportCreateTime time.Time
  340. // @return reportTypeList response.ReportChapterList
  341. // @return err error
  342. func GetChapterListByReportChapterIdList(classifyNameFirst string, reportId int, reportChapterIdList []int) (reportTypeList ficc_report.ReportChapterList, err error) {
  343. var errMsg string
  344. defer func() {
  345. if err != nil {
  346. go utils.SendAlarmMsg(fmt.Sprintf("GetChapterListByReport: err:%s, errMsg:%s", err.Error(), errMsg), 2)
  347. }
  348. }()
  349. //查询有效的章节
  350. typeList, e := ficc_report.GetEffectTypes()
  351. if e != nil {
  352. err = errors.New("章节类型查询出错" + e.Error())
  353. return
  354. }
  355. if len(typeList) == 0 {
  356. err = errors.New("无有效的章节")
  357. return
  358. }
  359. typeMap := make(map[uint64]*ficc_report.ReportChapterType)
  360. for _, v := range typeList {
  361. typeMap[v.ReportChapterTypeId] = v
  362. }
  363. var chapterList []*ficc_report.ReportChapter
  364. if len(reportChapterIdList) > 0 {
  365. //获取所有当前研报有权限的章节
  366. chapterList, e = ficc_report.GetListByChapterIds(reportChapterIdList)
  367. } else {
  368. // 获取所有报告章节
  369. chapterList, e = ficc_report.GetListByReportId(reportId, classifyNameFirst)
  370. }
  371. if e != nil && e.Error() != utils.ErrNoRow() {
  372. err = errors.New("章节查询出错" + e.Error())
  373. return
  374. }
  375. if len(chapterList) == 0 {
  376. err = errors.New("无有效章节")
  377. return
  378. }
  379. for _, item := range chapterList {
  380. typeItem, ok1 := typeMap[uint64(item.TypeId)]
  381. // 如果是配置的章节,那么就需要判断是否禁用,如果禁用,则不展示
  382. if item.TypeId > 0 && !ok1 {
  383. continue
  384. }
  385. temp := new(ficc_report.ReportChapterListItem)
  386. temp.ReportChapterId = item.ReportChapterId
  387. temp.TypeId = item.TypeId
  388. temp.TypeName = item.TypeName
  389. temp.Title = item.Title
  390. temp.Trend = item.Trend
  391. temp.ReportId = item.ReportId
  392. temp.Sort = item.Sort
  393. temp.PublishTime = item.PublishTime
  394. temp.VideoUrl = item.VideoUrl
  395. temp.VideoName = item.VideoName
  396. temp.VideoPlaySeconds = item.VideoPlaySeconds
  397. temp.VideoSize = item.VideoSize
  398. temp.Content = item.Content
  399. // 系统配置的参数,只有配置的章节类型,才能赋值
  400. if typeItem != nil {
  401. temp.ReportChapterTypeKey = typeItem.ReportChapterTypeKey
  402. temp.ReportChapterTypeName = typeItem.ReportChapterTypeName
  403. temp.ReportChapterTypeThumb = typeItem.YbIconUrl
  404. }
  405. reportTypeList = append(reportTypeList, temp)
  406. }
  407. //if len(reportTypeList) > 0 {
  408. // sort.Sort(reportTypeList)
  409. //}
  410. return
  411. }
  412. //func init() {
  413. // GetFiccRreportToCygxArticle()
  414. // //UpdateFICCReportResourceData(5542)
  415. //}
  416. // 获取FICC研报到查研观向数据库中
  417. func GetFiccRreportToCygxArticle() (err error) {
  418. defer func() {
  419. if err != nil {
  420. fmt.Println(err)
  421. go utils.SendAlarmMsg(fmt.Sprint("自动取消十分钟之内没有付款的的订单 CancelCygxOrder ,err:", err.Error()), 2)
  422. }
  423. }()
  424. var condition string
  425. var pars []interface{}
  426. //modifyTime := time.Now().Add(-10 * time.Minute)
  427. //condition = ` AND modify_time >= ? `
  428. //pars = append(pars, modifyTime)
  429. reportList, e := ficc_report.GetFiccRreportToCygxArticle(condition, pars)
  430. if e != nil {
  431. err = errors.New("GetFiccRreportToCygxArticle, Err: " + e.Error())
  432. return
  433. }
  434. fmt.Println(len(reportList))
  435. if len(reportList) == 0 {
  436. return
  437. }
  438. var reportIds []int
  439. for _, v := range reportList {
  440. reportIds = append(reportIds, v.Id)
  441. }
  442. listaFiccReport, e := models.GetCygxCygxArticleListByReportIds(reportIds)
  443. if e != nil {
  444. err = errors.New("GetCygxCygxArticleListByReportIds, Err: " + e.Error())
  445. return
  446. }
  447. mapFiccReport := make(map[int]int)
  448. for _, v := range listaFiccReport {
  449. mapFiccReport[v.IsReport] = v.ArticleId
  450. }
  451. //量不大,先这么写吧
  452. for _, v := range reportList {
  453. time.Sleep(1 * time.Millisecond) // 延时一秒
  454. item := new(models.CygxArticle)
  455. item.ReportId = v.Id
  456. item.PublishDate = v.PublishTime.Format(utils.FormatDateTime)
  457. item.Title = v.Title
  458. item.Body = v.Content
  459. item.Abstract = v.Abstract
  460. item.CreateDate = time.Now().Format(utils.FormatDate)
  461. item.PublishStatus = 1
  462. if (v.ClassifyNameFirst == "宏观报告" && v.ClassifyNameSecond == "大类资产周报") || (v.ClassifyNameFirst == "晨会纪要" && v.ClassifyNameSecond == "晨会纪要") {
  463. item.SubCategoryName = "产业跟踪"
  464. item.MatchTypeName = "产业跟踪"
  465. if utils.RunMode == "release" {
  466. item.CategoryId = 10091
  467. item.CategoryIdTwo = 10091
  468. } else {
  469. item.CategoryId = 10089
  470. item.CategoryIdTwo = 10089
  471. }
  472. } else if v.ClassifyNameFirst == "调研纪要" && v.ClassifyNameSecond == "调研纪要" {
  473. item.SubCategoryName = "调研纪要"
  474. item.MatchTypeName = "调研纪要"
  475. if utils.RunMode == "release" {
  476. item.CategoryId = 10090
  477. item.CategoryIdTwo = 10090
  478. } else {
  479. item.CategoryId = 10090
  480. item.CategoryIdTwo = 10090
  481. }
  482. } else {
  483. continue
  484. }
  485. var articleIdMax int
  486. //如果不存在就新增
  487. if mapFiccReport[v.Id] == 0 {
  488. maxArticleIdArticleInfo, e := models.GetMaxArticleIdInfo()
  489. if e != nil {
  490. err = errors.New("GetMaxArticleIdInfo, Err: " + e.Error())
  491. return
  492. }
  493. articleIdMax = maxArticleIdArticleInfo.ArticleId + 1
  494. item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdMax))
  495. item.ArticleId = articleIdMax
  496. _, e = models.AddCygxArticles(item)
  497. if e != nil {
  498. err = errors.New("AddCygxArticles, Err: " + e.Error())
  499. return
  500. }
  501. } else {
  502. articleIdMax = mapFiccReport[v.Id]
  503. item.ArticleId = mapFiccReport[v.Id]
  504. updateParams := make(map[string]interface{})
  505. updateParams["Title"] = item.Title
  506. updateParams["PublishDate"] = item.PublishDate
  507. updateParams["Body"] = item.Body
  508. updateParams["Abstract"] = item.Abstract
  509. updateParams["PublishStatus"] = item.PublishStatus
  510. updateParams["SubCategoryName"] = item.SubCategoryName
  511. updateParams["MatchTypeName"] = item.MatchTypeName
  512. updateParams["CategoryId"] = item.CategoryId
  513. updateParams["CategoryIdTwo"] = item.CategoryIdTwo
  514. whereParam := map[string]interface{}{"article_id": item.ArticleId}
  515. err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
  516. if err != nil {
  517. fmt.Println("UpdateByExpr Err:" + err.Error())
  518. return err
  519. }
  520. }
  521. UpdateFICCReportResourceData(v.Id)
  522. AddCygxReportMappingCategoryGroupByArticleId(articleIdMax)
  523. fmt.Println(v)
  524. }
  525. return
  526. }
  527. // 根据用户信息,获取跳转研报小程序详情信息
  528. func GetFiccReportXcxItem(user *models.WxUserItem) (itemSourceResp *models.CygxResourceDataResp) {
  529. var err error
  530. defer func() {
  531. if err != nil {
  532. fmt.Println(err)
  533. go utils.SendAlarmMsg(fmt.Sprint("根据用户信息,获取跳转研报小程序详情信息失败 GetFiccReportXcxItem ,err:", err.Error(), "UserId:", user.UserId), 2)
  534. }
  535. }()
  536. deUserId := utils.DesBase64Encrypt([]byte(strconv.Itoa(user.UserId)))
  537. itemSource := new(models.CygxResourceDataResp)
  538. itemSource.Source = utils.CYGX_OBJ_FICC_REPORT_XCX
  539. itemResp := new(models.FiccReportXcx)
  540. itemResp.Source = utils.CYGX_OBJ_FICC_REPORT_XCX
  541. itemResp.Title = "每日原油播报"
  542. itemResp.SecondTitle = "欧美市场隔夜复盘"
  543. itemResp.ImgUrl = utils.FICC_REPORT_ICO_HOME
  544. itemResp.Mobile = user.Mobile
  545. itemResp.SellerMobile = ""
  546. itemResp.SellerName = ""
  547. itemResp.Appid = utils.FICC_REPORT_APPID
  548. itemResp.SourceUrl = "pages/voice/voice?thirdCode="
  549. itemResp.ThirdCode = string(deUserId)
  550. //var hasPermission int
  551. var hasPersion bool
  552. if user.CompanyId > 1 {
  553. companyPermission, e := models.GetCompanyPermission(user.CompanyId)
  554. if e != nil {
  555. err = errors.New("获取用户权限信息失败" + e.Error())
  556. return
  557. }
  558. if companyPermission != "" {
  559. slice := strings.Split(companyPermission, ",")
  560. if utils.InArrayByStr(slice, "周期") {
  561. hasPersion = true
  562. }
  563. }
  564. }
  565. if hasPersion {
  566. itemResp.HasPermission = 1
  567. } else {
  568. itemResp.HasPermission, itemResp.SellerName, itemResp.SellerMobile, _, err = GetUserHasPermissionArticle(user)
  569. if err != nil {
  570. return
  571. }
  572. }
  573. itemSource.FiccReportXcx = itemResp
  574. itemSourceResp = itemSource
  575. return
  576. }