micro_roadshow.go 25 KB

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