micro_roadshow.go 21 KB

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