micro_roadshow.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  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. if sourceType == 1 {
  312. activityVoiceInfo, _ := models.GetCygxActivityVoiceByActivityId(req.Id)
  313. if activityVoiceInfo == nil {
  314. br.Msg = "操作失败"
  315. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
  316. return
  317. }
  318. item.ActivityId = req.Id
  319. item.ActivityVoiceId = activityVoiceInfo.ActivityVoiceId
  320. } else if sourceType == 2 {
  321. activityInfo, _ := models.GetCygxActivityVideoByActivityId(req.Id)
  322. if activityInfo == nil {
  323. br.Msg = "操作失败"
  324. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
  325. return
  326. }
  327. item.VideoId = activityInfo.VideoId
  328. item.ActivityId = req.Id
  329. } else if sourceType == 3 {
  330. item.VideoId = req.Id
  331. microVideo, e := models.GetMicroRoadshowVideoById(req.Id)
  332. if e != nil {
  333. br.Msg = "操作失败"
  334. br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(req.Id)
  335. return
  336. }
  337. item.IndustryId = microVideo.IndustryId
  338. }
  339. _, err = models.AddArticleComment(&item)
  340. if err != nil {
  341. br.Msg = "提交失败"
  342. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  343. return
  344. }
  345. services.SendWxMsgWithMicroRoadshowAsk(req, user)
  346. br.Ret = 200
  347. br.Success = true
  348. br.Msg = "操作成功"
  349. return
  350. }
  351. // @Title 微路演收藏
  352. // @Description 微路演收藏
  353. // @Param request body models.MicroRoadshowCollectReq true "type json string"
  354. // @Success 200 {object} models.FontsCollectResp
  355. // @router /collect [post]
  356. func (this *MicroRoadShowController) Collect() {
  357. br := new(models.BaseResponse).Init()
  358. defer func() {
  359. this.Data["json"] = br
  360. this.ServeJSON()
  361. }()
  362. user := this.User
  363. if user == nil {
  364. br.Msg = "请重新登录"
  365. br.Ret = 408
  366. return
  367. }
  368. uid := user.UserId
  369. var req models.MicroRoadshowCollectReq
  370. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  371. if err != nil {
  372. br.Msg = "参数解析异常!"
  373. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  374. return
  375. }
  376. if req.SourceType == 1 {
  377. _, err := models.GetCygxActivityVoiceById(req.Id)
  378. if err != nil {
  379. br.Msg = "获取信息失败"
  380. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  381. return
  382. }
  383. count, err := models.GetVoiceCollectCount(uid, req.Id)
  384. if err != nil {
  385. br.Msg = "获取数据失败!"
  386. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  387. return
  388. }
  389. resp := new(models.ArticleCollectResp)
  390. if count <= 0 {
  391. item := new(models.CygxArticleCollect)
  392. item.ActivityVoiceId = req.Id
  393. item.UserId = uid
  394. item.CreateTime = time.Now()
  395. item.Mobile = user.Mobile
  396. item.Email = user.Email
  397. item.CompanyId = user.CompanyId
  398. item.CompanyName = user.CompanyName
  399. item.RealName = user.RealName
  400. _, err = models.AddCygxArticleCollect(item)
  401. if err != nil {
  402. br.Msg = "收藏失败"
  403. br.ErrMsg = "收藏失败,Err:" + err.Error()
  404. return
  405. }
  406. br.Msg = "收藏成功"
  407. resp.Status = 1
  408. // 文章收藏消息发送
  409. //go services.ArticleUserRemind(user, detail, 2)
  410. } else {
  411. err = models.RemoveVoiceCollect(uid, req.Id)
  412. if err != nil {
  413. br.Msg = "取消收藏失败"
  414. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  415. return
  416. }
  417. br.Msg = "已取消收藏"
  418. resp.Status = 2
  419. }
  420. collectTotal, err := models.GetVoiceCollectUsersCount(req.Id)
  421. if err != nil {
  422. br.Msg = "获取数据失败"
  423. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  424. return
  425. }
  426. resp.CollectCount = collectTotal
  427. br.Ret = 200
  428. br.Success = true
  429. br.Data = resp
  430. } else if req.SourceType == 2 {
  431. _, err := models.GetCygxActivityVideoById(req.Id)
  432. if err != nil {
  433. br.Msg = "获取信息失败"
  434. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  435. return
  436. }
  437. count, err := models.GetActivityVideoCollectCount(uid, req.Id)
  438. if err != nil {
  439. br.Msg = "获取数据失败!"
  440. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  441. return
  442. }
  443. resp := new(models.ArticleCollectResp)
  444. if count <= 0 {
  445. item := new(models.CygxArticleCollect)
  446. item.ActivityVideoId = req.Id
  447. item.UserId = uid
  448. item.CreateTime = time.Now()
  449. item.Mobile = user.Mobile
  450. item.Email = user.Email
  451. item.CompanyId = user.CompanyId
  452. item.CompanyName = user.CompanyName
  453. item.RealName = user.RealName
  454. _, err = models.AddCygxArticleCollect(item)
  455. if err != nil {
  456. br.Msg = "收藏失败"
  457. br.ErrMsg = "收藏失败,Err:" + err.Error()
  458. return
  459. }
  460. br.Msg = "收藏成功"
  461. resp.Status = 1
  462. // 文章收藏消息发送
  463. //go services.ArticleUserRemind(user, detail, 2)
  464. } else {
  465. err = models.RemoveActivityVideoCollect(uid, req.Id)
  466. if err != nil {
  467. br.Msg = "取消收藏失败"
  468. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  469. return
  470. }
  471. br.Msg = "已取消收藏"
  472. resp.Status = 2
  473. }
  474. collectTotal, err := models.GetActivityVideoCollectUsersCount(req.Id)
  475. if err != nil {
  476. br.Msg = "获取数据失败"
  477. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  478. return
  479. }
  480. resp.CollectCount = collectTotal
  481. br.Ret = 200
  482. br.Success = true
  483. br.Data = resp
  484. } else if req.SourceType == 3 {
  485. _, err := models.GetMicroRoadshowVideoById(req.Id)
  486. if err != nil {
  487. br.Msg = "获取信息失败"
  488. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  489. return
  490. }
  491. count, err := models.GetVideoCollectCount(uid, req.Id)
  492. if err != nil {
  493. br.Msg = "获取数据失败!"
  494. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  495. return
  496. }
  497. resp := new(models.ArticleCollectResp)
  498. if count <= 0 {
  499. item := new(models.CygxArticleCollect)
  500. item.VideoId = req.Id
  501. item.UserId = uid
  502. item.CreateTime = time.Now()
  503. item.Mobile = user.Mobile
  504. item.Email = user.Email
  505. item.CompanyId = user.CompanyId
  506. item.CompanyName = user.CompanyName
  507. item.RealName = user.RealName
  508. _, err = models.AddCygxArticleCollect(item)
  509. if err != nil {
  510. br.Msg = "收藏失败"
  511. br.ErrMsg = "收藏失败,Err:" + err.Error()
  512. return
  513. }
  514. br.Msg = "收藏成功"
  515. resp.Status = 1
  516. // 文章收藏消息发送
  517. //go services.ArticleUserRemind(user, detail, 2)
  518. } else {
  519. err = models.RemoveVideoCollect(uid, req.Id)
  520. if err != nil {
  521. br.Msg = "取消收藏失败"
  522. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  523. return
  524. }
  525. br.Msg = "已取消收藏"
  526. resp.Status = 2
  527. }
  528. collectTotal, err := models.GetVideoCollectUsersCount(req.Id)
  529. if err != nil {
  530. br.Msg = "获取数据失败"
  531. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  532. return
  533. }
  534. resp.CollectCount = collectTotal
  535. br.Ret = 200
  536. br.Success = true
  537. br.Data = resp
  538. }
  539. }
  540. // @Title 我的收藏微路演列表
  541. // @Description 我的收藏微路演列表接口
  542. // @Param PageSize query int true "每页数据条数"
  543. // @Param CurrentIndex query int true "当前页页码,从1开始"
  544. // @Success 200 {object} models.HomeListResp
  545. // @router /mycollect [get]
  546. func (this *MicroRoadShowController) Mycollect() {
  547. br := new(models.BaseResponse).Init()
  548. defer func() {
  549. this.Data["json"] = br
  550. this.ServeJSON()
  551. }()
  552. user := this.User
  553. if user == nil {
  554. br.Msg = "请登录"
  555. br.ErrMsg = "请登录,用户信息为空"
  556. br.Ret = 408
  557. return
  558. }
  559. pageSize, _ := this.GetInt("PageSize")
  560. currentIndex, _ := this.GetInt("CurrentIndex")
  561. if pageSize <= 0 {
  562. pageSize = utils.PageSize20
  563. }
  564. if currentIndex <= 0 {
  565. currentIndex = 1
  566. }
  567. userId := user.UserId
  568. listMycollect, err := models.GetUserMicroRoadshowCollectList(userId)
  569. if err != nil {
  570. br.Msg = "获取数据失败"
  571. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  572. return
  573. }
  574. var audioIds []string
  575. var videoIds []string
  576. var activityVideoIds []string
  577. for _, item := range listMycollect {
  578. if item.ActivityVoiceId > 0 {
  579. audioIds = append(audioIds, strconv.Itoa(item.ActivityVoiceId))
  580. } else if item.VideoId > 0 {
  581. videoIds = append(videoIds, strconv.Itoa(item.VideoId))
  582. } else if item.ActivityVideoId > 0 {
  583. activityVideoIds = append(activityVideoIds, strconv.Itoa(item.ActivityVideoId))
  584. }
  585. }
  586. if len(audioIds) == 0 && len(videoIds) == 0 && len(activityVideoIds) == 0 {
  587. resp := new(models.MicroRoadShowListResp)
  588. page := paging.GetPaging(currentIndex, pageSize, 0)
  589. resp.List = make([]*models.MicroRoadShowPageList, 0)
  590. resp.Paging = page
  591. br.Ret = 200
  592. br.Success = true
  593. br.Msg = "获取成功"
  594. br.Data = resp
  595. return
  596. }
  597. audioIdstr := strings.Join(audioIds, ",")
  598. ideoIdsStr := strings.Join(videoIds, ",")
  599. activityVideoIdsStr := strings.Join(activityVideoIds, ",")
  600. // 微路演列表
  601. list, total, e := services.GetMicroRoadShowMycollect(pageSize, currentIndex, audioIdstr, ideoIdsStr, activityVideoIdsStr)
  602. if e != nil {
  603. br.Msg = "获取失败"
  604. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  605. return
  606. }
  607. for _, item := range list {
  608. if item.Type == 1 {
  609. //音频
  610. count, err := models.GetVoiceCollectCount(user.UserId, item.Id)
  611. if err != nil {
  612. br.Msg = "获取数据失败!"
  613. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  614. return
  615. }
  616. if count > 0 {
  617. item.IsCollect = true
  618. }
  619. } else if item.Type == 2 {
  620. //活动视频
  621. count, err := models.GetActivityVideoCollectCount(user.UserId, item.Id)
  622. if err != nil {
  623. br.Msg = "获取数据失败!"
  624. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  625. return
  626. }
  627. if count > 0 {
  628. item.IsCollect = true
  629. }
  630. } else if item.Type == 3 {
  631. //微路演视频
  632. count, err := models.GetVideoCollectCount(user.UserId, item.Id)
  633. if err != nil {
  634. br.Msg = "获取数据失败!"
  635. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  636. return
  637. }
  638. if count > 0 {
  639. item.IsCollect = true
  640. }
  641. }
  642. }
  643. // 用户权限
  644. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  645. if e != nil {
  646. br.Msg = "获取失败"
  647. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  648. return
  649. }
  650. // 获取默认图配置
  651. audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
  652. if e != nil {
  653. br.Msg = "获取失败"
  654. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  655. return
  656. }
  657. for i := range list {
  658. // 权限
  659. au := new(models.UserPermissionAuthInfo)
  660. au.SellerName = authInfo.SellerName
  661. au.SellerMobile = authInfo.SellerMobile
  662. au.HasPermission = authInfo.HasPermission
  663. au.OperationMode = authInfo.OperationMode
  664. if au.HasPermission == 1 {
  665. // 非宏观权限进一步判断是否有权限
  666. if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
  667. au.HasPermission = 2
  668. }
  669. }
  670. // 无权限的弹框提示
  671. if au.HasPermission != 1 {
  672. if au.OperationMode == services.UserPermissionOperationModeCall {
  673. if list[i].Type == 1 {
  674. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  675. } else {
  676. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  677. }
  678. } else {
  679. if list[i].Type == 1 {
  680. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  681. } else {
  682. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  683. }
  684. }
  685. }
  686. list[i].AuthInfo = au
  687. list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
  688. // 默认图
  689. if list[i].BackgroundImg == "" {
  690. if list[i].Type == 1 {
  691. list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
  692. } else {
  693. list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
  694. }
  695. }
  696. // 分享图
  697. if list[i].ShareImg == "" {
  698. if list[i].Type == 1 {
  699. list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
  700. } else {
  701. list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
  702. }
  703. }
  704. }
  705. resp := new(models.MicroRoadShowListResp)
  706. page := paging.GetPaging(currentIndex, pageSize, total)
  707. resp.List = list
  708. resp.Paging = page
  709. br.Ret = 200
  710. br.Success = true
  711. br.Msg = "获取成功"
  712. br.Data = resp
  713. }