micro_roadshow.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/services"
  7. "hongze/hongze_cygx/utils"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. // 微路演
  13. type MicroRoadShowController struct {
  14. BaseAuthController
  15. }
  16. // @Title 微路演列表
  17. // @Description 微路演列表接口
  18. // @Param PageSize query int true "每页数据条数"
  19. // @Param CurrentIndex query int true "当前页页码,从1开始"
  20. // @Param KeyWord query string false "搜索关键词"
  21. // @Param AudioId query int false "音频ID"
  22. // @Param VideoId query int false "视频ID"
  23. // @Param AudioIds query string false "活动音频IDs"
  24. // @Param ActivityVideoIds query string false "活动视频IDs"
  25. // @Param VideoIds query string false "视频IDs"
  26. // @Param ActivityVideoId query int false "活动视频ID"
  27. // @Param Filter query int false "筛选条件 0:全部 1:视频 2:音频"
  28. // @Success 200 {object} models.HomeListResp
  29. // @router /list [get]
  30. func (this *MicroRoadShowController) List() {
  31. br := new(models.BaseResponse).Init()
  32. defer func() {
  33. this.Data["json"] = br
  34. this.ServeJSON()
  35. }()
  36. user := this.User
  37. if user == nil {
  38. br.Msg = "请登录"
  39. br.ErrMsg = "请登录,用户信息为空"
  40. br.Ret = 408
  41. return
  42. }
  43. pageSize, _ := this.GetInt("PageSize")
  44. currentIndex, _ := this.GetInt("CurrentIndex")
  45. keywords := this.GetString("KeyWord")
  46. audioId, _ := this.GetInt("AudioId")
  47. videoId, _ := this.GetInt("VideoId")
  48. audioIds := this.GetString("AudioIds")
  49. videoIds := this.GetString("VideoIds")
  50. activityVideoIds := this.GetString("ActivityVideoIds")
  51. activityVideoId, _ := this.GetInt("ActivityVideoId")
  52. filter, _ := this.GetInt("Filter", 0)
  53. if pageSize <= 0 {
  54. pageSize = utils.PageSize20
  55. }
  56. if currentIndex <= 0 {
  57. currentIndex = 1
  58. }
  59. // 微路演列表
  60. list, total, e := services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter, keywords, audioIds, videoIds, activityVideoIds)
  61. if e != nil {
  62. br.Msg = "获取失败"
  63. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  64. return
  65. }
  66. for _, item := range list {
  67. if item.Type == 1 {
  68. //音频
  69. count, err := models.GetVoiceCollectCount(user.UserId, item.Id)
  70. if err != nil {
  71. br.Msg = "获取数据失败!"
  72. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  73. return
  74. }
  75. if count > 0 {
  76. item.IsCollect = true
  77. }
  78. } else if item.Type == 2 {
  79. //活动视频
  80. count, err := models.GetActivityVideoCollectCount(user.UserId, item.Id)
  81. if err != nil {
  82. br.Msg = "获取数据失败!"
  83. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  84. return
  85. }
  86. if count > 0 {
  87. item.IsCollect = true
  88. }
  89. } else if item.Type == 3 {
  90. //微路演视频
  91. count, err := models.GetVideoCollectCount(user.UserId, item.Id)
  92. if err != nil {
  93. br.Msg = "获取数据失败!"
  94. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  95. return
  96. }
  97. if count > 0 {
  98. item.IsCollect = true
  99. }
  100. }
  101. }
  102. // 用户权限
  103. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  104. if e != nil {
  105. br.Msg = "获取失败"
  106. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  107. return
  108. }
  109. // 获取默认图配置
  110. audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
  111. if e != nil {
  112. br.Msg = "获取失败"
  113. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  114. return
  115. }
  116. for i := range list {
  117. // 权限
  118. au := new(models.UserPermissionAuthInfo)
  119. au.SellerName = authInfo.SellerName
  120. au.SellerMobile = authInfo.SellerMobile
  121. au.HasPermission = authInfo.HasPermission
  122. au.OperationMode = authInfo.OperationMode
  123. if au.HasPermission == 1 {
  124. // 非宏观权限进一步判断是否有权限
  125. if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
  126. au.HasPermission = 2
  127. }
  128. }
  129. // 无权限的弹框提示
  130. if au.HasPermission != 1 {
  131. if au.OperationMode == services.UserPermissionOperationModeCall {
  132. if list[i].Type == 1 {
  133. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  134. } else {
  135. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  136. }
  137. } else {
  138. if list[i].Type == 1 {
  139. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  140. } else {
  141. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  142. }
  143. }
  144. }
  145. list[i].AuthInfo = au
  146. list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
  147. // 默认图
  148. if list[i].BackgroundImg == "" {
  149. if list[i].Type == 1 {
  150. list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
  151. } else {
  152. list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
  153. }
  154. }
  155. // 分享图
  156. if list[i].ShareImg == "" {
  157. if list[i].Type == 1 {
  158. list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
  159. } else {
  160. list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
  161. }
  162. }
  163. //修改产业视频的标题
  164. //if list[i].Type == 3 && list[i].IndustryName != "" {
  165. // list[i].Title = "5min" + "【" + list[i].IndustryName + "】" + "逻辑解析"
  166. //}
  167. }
  168. resp := new(models.MicroRoadShowListResp)
  169. page := paging.GetPaging(currentIndex, pageSize, total)
  170. resp.List = list
  171. resp.Paging = page
  172. br.Ret = 200
  173. br.Success = true
  174. br.Msg = "获取成功"
  175. br.Data = resp
  176. }
  177. // @Title 记录用户浏览音频回放接口
  178. // @Description 记录用户浏览音频回放接口
  179. // @Param request body models.ActivityIdRep true "type json string"
  180. // @Success Ret=200 {object} models.AppointmentResp
  181. // @router /videoHistory/add [post]
  182. func (this *MicroRoadShowController) VideoHistoryAdd() {
  183. br := new(models.BaseResponse).Init()
  184. defer func() {
  185. this.Data["json"] = br
  186. this.ServeJSON()
  187. }()
  188. user := this.User
  189. if user == nil {
  190. br.Msg = "请登录"
  191. br.ErrMsg = "请登录,用户信息为空"
  192. br.Ret = 408
  193. return
  194. }
  195. uid := user.UserId
  196. var req models.AddVideoHistoryReq
  197. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  198. if err != nil {
  199. br.Msg = "参数解析异常!"
  200. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  201. return
  202. }
  203. videoId := req.VideoId
  204. playSeconds := req.PlaySeconds
  205. sourceType := req.SourceType
  206. if sourceType == 0 {
  207. sourceType = 1
  208. }
  209. var sellerName string
  210. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  211. if err != nil {
  212. br.Msg = "报名失败!"
  213. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  214. return
  215. }
  216. if sourceType == 1 {
  217. item := models.CygxMicroRoadshowVideoHistory{
  218. VideoId: videoId,
  219. UserId: uid,
  220. Mobile: user.Mobile,
  221. Email: user.Email,
  222. CompanyId: user.CompanyId,
  223. CompanyName: user.CompanyName,
  224. RealName: user.RealName,
  225. SellerName: sellerName,
  226. PlaySeconds: strconv.Itoa(playSeconds),
  227. CreateTime: time.Now(),
  228. ModifyTime: time.Now(),
  229. }
  230. if playSeconds != 0 {
  231. lastItem, err := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
  232. if err != nil {
  233. br.Msg = "操作失败"
  234. br.ErrMsg = "操作失败,GetLastCygxMicroRoadshowVideoHistory Err:" + err.Error()
  235. return
  236. }
  237. err = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
  238. if err != nil {
  239. br.Msg = "更新失败"
  240. br.ErrMsg = "更新失败,UpdateLastCygxActivityVideoHistory Err:" + err.Error()
  241. return
  242. }
  243. } else {
  244. err = models.AddCygxMicroRoadshowVideoHistory(&item)
  245. if err != nil {
  246. br.Msg = "操作失败"
  247. br.ErrMsg = "操作失败,Err:" + err.Error()
  248. return
  249. }
  250. err = models.UpdateCygxActivityVideoCounts(videoId)
  251. if err != nil {
  252. br.Msg = "更新失败"
  253. br.ErrMsg = "更新失败,Err:" + err.Error()
  254. return
  255. }
  256. }
  257. } else if sourceType == 2 {
  258. err = services.AddActivityVideoHistory(user, videoId)
  259. if err != nil {
  260. br.Msg = "更新失败"
  261. br.ErrMsg = "更新失败,AddActivityVideoHistory Err:" + err.Error()
  262. return
  263. }
  264. }
  265. br.Ret = 200
  266. br.Success = true
  267. br.Msg = "操作成功"
  268. return
  269. }
  270. // @Title 微路演新增留言
  271. // @Description 微路演新增留言接口
  272. // @Param request body models.AddVideoCommnetReq true "type json string"
  273. // @Success Ret=200 {object} models.AppointmentResp
  274. // @router /comment/add [post]
  275. func (this *MicroRoadShowController) CommentAdd() {
  276. br := new(models.BaseResponse).Init()
  277. defer func() {
  278. this.Data["json"] = br
  279. this.ServeJSON()
  280. }()
  281. user := this.User
  282. if user == nil {
  283. br.Msg = "请登录"
  284. br.ErrMsg = "请登录,用户信息为空"
  285. br.Ret = 408
  286. return
  287. }
  288. uid := user.UserId
  289. var req models.AddVideoCommnetReq
  290. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  291. if err != nil {
  292. br.Msg = "参数解析异常!"
  293. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  294. return
  295. }
  296. sourceType := req.SourceType
  297. if sourceType == 0 {
  298. sourceType = 1
  299. }
  300. item := models.CygxArticleComment{
  301. UserId: uid,
  302. CreateTime: time.Now(),
  303. RealName: user.RealName,
  304. Mobile: user.Mobile,
  305. Email: user.Email,
  306. CompanyId: user.CompanyId,
  307. CompanyName: user.CompanyName,
  308. Content: req.Content,
  309. Title: req.Title,
  310. }
  311. var resourceId int
  312. if sourceType == 1 {
  313. activityVoiceInfo, _ := models.GetCygxActivityVoiceByActivityId(req.Id)
  314. if activityVoiceInfo == nil {
  315. br.Msg = "操作失败"
  316. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
  317. return
  318. }
  319. item.ActivityId = req.Id
  320. item.ActivityVoiceId = activityVoiceInfo.ActivityVoiceId
  321. resourceId = activityVoiceInfo.ActivityId
  322. } else if sourceType == 2 {
  323. activityInfo, _ := models.GetCygxActivityVideoByActivityId(req.Id)
  324. if activityInfo == nil {
  325. br.Msg = "操作失败"
  326. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
  327. return
  328. }
  329. item.VideoId = activityInfo.VideoId
  330. item.ActivityId = req.Id
  331. resourceId = activityInfo.ActivityId
  332. } else if sourceType == 3 {
  333. item.VideoId = req.Id
  334. microVideo, e := models.GetMicroRoadshowVideoById(req.Id)
  335. if e != nil {
  336. br.Msg = "操作失败"
  337. br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(req.Id)
  338. return
  339. }
  340. item.IndustryId = microVideo.IndustryId
  341. resourceId = microVideo.IndustryId
  342. }
  343. _, err = models.AddArticleComment(&item)
  344. if err != nil {
  345. br.Msg = "提交失败"
  346. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  347. return
  348. }
  349. services.SendWxMsgWithMicroRoadshowAsk(req, user, resourceId)
  350. br.Ret = 200
  351. br.Success = true
  352. br.Msg = "操作成功"
  353. return
  354. }
  355. // @Title 微路演收藏
  356. // @Description 微路演收藏
  357. // @Param request body models.MicroRoadshowCollectReq true "type json string"
  358. // @Success 200 {object} models.FontsCollectResp
  359. // @router /collect [post]
  360. func (this *MicroRoadShowController) Collect() {
  361. br := new(models.BaseResponse).Init()
  362. defer func() {
  363. this.Data["json"] = br
  364. this.ServeJSON()
  365. }()
  366. user := this.User
  367. if user == nil {
  368. br.Msg = "请重新登录"
  369. br.Ret = 408
  370. return
  371. }
  372. uid := user.UserId
  373. var req models.MicroRoadshowCollectReq
  374. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  375. if err != nil {
  376. br.Msg = "参数解析异常!"
  377. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  378. return
  379. }
  380. if req.SourceType == 1 {
  381. _, err := models.GetCygxActivityVoiceById(req.Id)
  382. if err != nil {
  383. br.Msg = "获取信息失败"
  384. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  385. return
  386. }
  387. count, err := models.GetVoiceCollectCount(uid, req.Id)
  388. if err != nil {
  389. br.Msg = "获取数据失败!"
  390. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  391. return
  392. }
  393. resp := new(models.ArticleCollectResp)
  394. if count <= 0 {
  395. item := new(models.CygxArticleCollect)
  396. item.ActivityVoiceId = req.Id
  397. item.UserId = uid
  398. item.CreateTime = time.Now()
  399. item.Mobile = user.Mobile
  400. item.Email = user.Email
  401. item.CompanyId = user.CompanyId
  402. item.CompanyName = user.CompanyName
  403. item.RealName = user.RealName
  404. _, err = models.AddCygxArticleCollect(item)
  405. if err != nil {
  406. br.Msg = "收藏失败"
  407. br.ErrMsg = "收藏失败,Err:" + err.Error()
  408. return
  409. }
  410. br.Msg = "收藏成功"
  411. resp.Status = 1
  412. // 文章收藏消息发送
  413. //go services.ArticleUserRemind(user, detail, 2)
  414. } else {
  415. err = models.RemoveVoiceCollect(uid, req.Id)
  416. if err != nil {
  417. br.Msg = "取消收藏失败"
  418. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  419. return
  420. }
  421. br.Msg = "已取消收藏"
  422. resp.Status = 2
  423. }
  424. collectTotal, err := models.GetVoiceCollectUsersCount(req.Id)
  425. if err != nil {
  426. br.Msg = "获取数据失败"
  427. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  428. return
  429. }
  430. resp.CollectCount = collectTotal
  431. br.Ret = 200
  432. br.Success = true
  433. br.Data = resp
  434. } else if req.SourceType == 2 {
  435. _, err := models.GetCygxActivityVideoById(req.Id)
  436. if err != nil {
  437. br.Msg = "获取信息失败"
  438. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  439. return
  440. }
  441. count, err := models.GetActivityVideoCollectCount(uid, req.Id)
  442. if err != nil {
  443. br.Msg = "获取数据失败!"
  444. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  445. return
  446. }
  447. resp := new(models.ArticleCollectResp)
  448. if count <= 0 {
  449. item := new(models.CygxArticleCollect)
  450. item.ActivityVideoId = req.Id
  451. item.UserId = uid
  452. item.CreateTime = time.Now()
  453. item.Mobile = user.Mobile
  454. item.Email = user.Email
  455. item.CompanyId = user.CompanyId
  456. item.CompanyName = user.CompanyName
  457. item.RealName = user.RealName
  458. _, err = models.AddCygxArticleCollect(item)
  459. if err != nil {
  460. br.Msg = "收藏失败"
  461. br.ErrMsg = "收藏失败,Err:" + err.Error()
  462. return
  463. }
  464. br.Msg = "收藏成功"
  465. resp.Status = 1
  466. // 文章收藏消息发送
  467. //go services.ArticleUserRemind(user, detail, 2)
  468. } else {
  469. err = models.RemoveActivityVideoCollect(uid, req.Id)
  470. if err != nil {
  471. br.Msg = "取消收藏失败"
  472. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  473. return
  474. }
  475. br.Msg = "已取消收藏"
  476. resp.Status = 2
  477. }
  478. collectTotal, err := models.GetActivityVideoCollectUsersCount(req.Id)
  479. if err != nil {
  480. br.Msg = "获取数据失败"
  481. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  482. return
  483. }
  484. resp.CollectCount = collectTotal
  485. br.Ret = 200
  486. br.Success = true
  487. br.Data = resp
  488. } else if req.SourceType == 3 {
  489. _, err := models.GetMicroRoadshowVideoById(req.Id)
  490. if err != nil {
  491. br.Msg = "获取信息失败"
  492. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  493. return
  494. }
  495. count, err := models.GetVideoCollectCount(uid, req.Id)
  496. if err != nil {
  497. br.Msg = "获取数据失败!"
  498. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  499. return
  500. }
  501. resp := new(models.ArticleCollectResp)
  502. if count <= 0 {
  503. item := new(models.CygxArticleCollect)
  504. item.VideoId = req.Id
  505. item.UserId = uid
  506. item.CreateTime = time.Now()
  507. item.Mobile = user.Mobile
  508. item.Email = user.Email
  509. item.CompanyId = user.CompanyId
  510. item.CompanyName = user.CompanyName
  511. item.RealName = user.RealName
  512. _, err = models.AddCygxArticleCollect(item)
  513. if err != nil {
  514. br.Msg = "收藏失败"
  515. br.ErrMsg = "收藏失败,Err:" + err.Error()
  516. return
  517. }
  518. br.Msg = "收藏成功"
  519. resp.Status = 1
  520. // 文章收藏消息发送
  521. //go services.ArticleUserRemind(user, detail, 2)
  522. } else {
  523. err = models.RemoveVideoCollect(uid, req.Id)
  524. if err != nil {
  525. br.Msg = "取消收藏失败"
  526. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  527. return
  528. }
  529. br.Msg = "已取消收藏"
  530. resp.Status = 2
  531. }
  532. collectTotal, err := models.GetVideoCollectUsersCount(req.Id)
  533. if err != nil {
  534. br.Msg = "获取数据失败"
  535. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  536. return
  537. }
  538. resp.CollectCount = collectTotal
  539. br.Ret = 200
  540. br.Success = true
  541. br.Data = resp
  542. }
  543. }
  544. // @Title 我的收藏微路演列表
  545. // @Description 我的收藏微路演列表接口
  546. // @Param PageSize query int true "每页数据条数"
  547. // @Param CurrentIndex query int true "当前页页码,从1开始"
  548. // @Success 200 {object} models.HomeListResp
  549. // @router /mycollect [get]
  550. func (this *MicroRoadShowController) Mycollect() {
  551. br := new(models.BaseResponse).Init()
  552. defer func() {
  553. this.Data["json"] = br
  554. this.ServeJSON()
  555. }()
  556. user := this.User
  557. if user == nil {
  558. br.Msg = "请登录"
  559. br.ErrMsg = "请登录,用户信息为空"
  560. br.Ret = 408
  561. return
  562. }
  563. pageSize, _ := this.GetInt("PageSize")
  564. currentIndex, _ := this.GetInt("CurrentIndex")
  565. if pageSize <= 0 {
  566. pageSize = utils.PageSize20
  567. }
  568. if currentIndex <= 0 {
  569. currentIndex = 1
  570. }
  571. userId := user.UserId
  572. listMycollect, err := models.GetUserMicroRoadshowCollectList(userId)
  573. if err != nil {
  574. br.Msg = "获取数据失败"
  575. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  576. return
  577. }
  578. var audioIds []string
  579. var videoIds []string
  580. var activityVideoIds []string
  581. for _, item := range listMycollect {
  582. if item.ActivityVoiceId > 0 {
  583. audioIds = append(audioIds, strconv.Itoa(item.ActivityVoiceId))
  584. } else if item.VideoId > 0 {
  585. videoIds = append(videoIds, strconv.Itoa(item.VideoId))
  586. } else if item.ActivityVideoId > 0 {
  587. activityVideoIds = append(activityVideoIds, strconv.Itoa(item.ActivityVideoId))
  588. }
  589. }
  590. if len(audioIds) == 0 && len(videoIds) == 0 && len(activityVideoIds) == 0 {
  591. resp := new(models.MicroRoadShowListResp)
  592. page := paging.GetPaging(currentIndex, pageSize, 0)
  593. resp.List = make([]*models.MicroRoadShowPageList, 0)
  594. resp.Paging = page
  595. br.Ret = 200
  596. br.Success = true
  597. br.Msg = "获取成功"
  598. br.Data = resp
  599. return
  600. }
  601. audioIdstr := strings.Join(audioIds, ",")
  602. ideoIdsStr := strings.Join(videoIds, ",")
  603. activityVideoIdsStr := strings.Join(activityVideoIds, ",")
  604. // 微路演列表
  605. list, total, e := services.GetMicroRoadShowMycollect(pageSize, currentIndex, audioIdstr, ideoIdsStr, activityVideoIdsStr)
  606. if e != nil {
  607. br.Msg = "获取失败"
  608. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  609. return
  610. }
  611. for _, item := range list {
  612. if item.Type == 1 {
  613. //音频
  614. count, err := models.GetVoiceCollectCount(user.UserId, item.Id)
  615. if err != nil {
  616. br.Msg = "获取数据失败!"
  617. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  618. return
  619. }
  620. if count > 0 {
  621. item.IsCollect = true
  622. }
  623. } else if item.Type == 2 {
  624. //活动视频
  625. count, err := models.GetActivityVideoCollectCount(user.UserId, item.Id)
  626. if err != nil {
  627. br.Msg = "获取数据失败!"
  628. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  629. return
  630. }
  631. if count > 0 {
  632. item.IsCollect = true
  633. }
  634. } else if item.Type == 3 {
  635. //微路演视频
  636. count, err := models.GetVideoCollectCount(user.UserId, item.Id)
  637. if err != nil {
  638. br.Msg = "获取数据失败!"
  639. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  640. return
  641. }
  642. if count > 0 {
  643. item.IsCollect = true
  644. }
  645. }
  646. }
  647. // 用户权限
  648. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  649. if e != nil {
  650. br.Msg = "获取失败"
  651. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  652. return
  653. }
  654. // 获取默认图配置
  655. audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
  656. if e != nil {
  657. br.Msg = "获取失败"
  658. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  659. return
  660. }
  661. for i := range list {
  662. // 权限
  663. au := new(models.UserPermissionAuthInfo)
  664. au.SellerName = authInfo.SellerName
  665. au.SellerMobile = authInfo.SellerMobile
  666. au.HasPermission = authInfo.HasPermission
  667. au.OperationMode = authInfo.OperationMode
  668. if au.HasPermission == 1 {
  669. // 非宏观权限进一步判断是否有权限
  670. if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
  671. au.HasPermission = 2
  672. }
  673. }
  674. // 无权限的弹框提示
  675. if au.HasPermission != 1 {
  676. if au.OperationMode == services.UserPermissionOperationModeCall {
  677. if list[i].Type == 1 {
  678. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  679. } else {
  680. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  681. }
  682. } else {
  683. if list[i].Type == 1 {
  684. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  685. } else {
  686. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  687. }
  688. }
  689. }
  690. list[i].AuthInfo = au
  691. list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
  692. // 默认图
  693. if list[i].BackgroundImg == "" {
  694. if list[i].Type == 1 {
  695. list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
  696. } else {
  697. list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
  698. }
  699. }
  700. // 分享图
  701. if list[i].ShareImg == "" {
  702. if list[i].Type == 1 {
  703. list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
  704. } else {
  705. list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
  706. }
  707. }
  708. }
  709. resp := new(models.MicroRoadShowListResp)
  710. page := paging.GetPaging(currentIndex, pageSize, total)
  711. resp.List = list
  712. resp.Paging = page
  713. br.Ret = 200
  714. br.Success = true
  715. br.Msg = "获取成功"
  716. br.Data = resp
  717. }