WeLiveController.java 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. package com.linkwechat.controller;
  2. import com.alibaba.excel.EasyExcel;
  3. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4. import com.linkwechat.common.core.controller.BaseController;
  5. import com.linkwechat.common.core.domain.AjaxResult;
  6. import com.linkwechat.common.core.page.TableDataInfo;
  7. import com.linkwechat.common.utils.ServletUtils;
  8. import com.linkwechat.common.utils.StringUtils;
  9. import com.linkwechat.common.utils.poi.LwExcelUtil;
  10. import com.linkwechat.domain.kf.vo.WeKfRecordListVo;
  11. import com.linkwechat.domain.live.WeLive;
  12. import com.linkwechat.domain.live.WeLiveWatchUser;
  13. import com.linkwechat.domain.live.vo.WeLinveUserVo;
  14. import com.linkwechat.fegin.QwSysUserClient;
  15. import com.linkwechat.service.IWeLiveService;
  16. import com.linkwechat.service.IWeLiveTipService;
  17. import com.linkwechat.service.IWeLiveWatchUserService;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.web.bind.annotation.*;
  20. import javax.servlet.http.HttpServletResponse;
  21. import java.io.IOException;
  22. import java.io.UnsupportedEncodingException;
  23. import java.net.URLEncoder;
  24. import java.text.ParseException;
  25. import java.util.Arrays;
  26. import java.util.List;
  27. /**
  28. * 直播相关
  29. */
  30. @RestController
  31. @RequestMapping("/live")
  32. public class WeLiveController extends BaseController {
  33. @Autowired
  34. IWeLiveService iWeLiveService;
  35. @Autowired
  36. IWeLiveTipService iWeLiveTipService;
  37. @Autowired
  38. IWeLiveWatchUserService iWeLiveWatchUserService;
  39. @Autowired
  40. QwSysUserClient qwSysUserClient;
  41. /**
  42. * 新增或更新直播
  43. * @param weLive
  44. * @return
  45. */
  46. @PostMapping("/addOrUpdate")
  47. public AjaxResult addOrUpdate(@RequestBody WeLive weLive){
  48. iWeLiveService.addOrUpdate(weLive);
  49. return AjaxResult.success();
  50. }
  51. /**
  52. * 获取直播列表
  53. * @param weLive
  54. * @return
  55. */
  56. @GetMapping("/findWelives")
  57. public TableDataInfo findWelives(WeLive weLive){
  58. startPage();
  59. return getDataTable(iWeLiveService.findLives(weLive));
  60. }
  61. /**
  62. * 获取直播详情
  63. * @return
  64. */
  65. @GetMapping("/findLiveDetail/{weLiveId}")
  66. public AjaxResult findLiveDetail(@PathVariable String weLiveId){
  67. return AjaxResult.success(
  68. iWeLiveService.findLiveDetail(weLiveId)
  69. );
  70. }
  71. /**
  72. * 通过id列表删除
  73. *
  74. * @param ids id列表
  75. * @return 结果
  76. */
  77. @DeleteMapping(path = "/{ids}")
  78. public AjaxResult batchDeleteLiwes(@PathVariable("ids") Long[] ids) {
  79. iWeLiveService.removeLives(Arrays.asList(ids));
  80. return AjaxResult.success();
  81. }
  82. /**
  83. * 取消直播
  84. * @param live
  85. * @return
  86. */
  87. @PostMapping("/cancelLive")
  88. public AjaxResult cancelLive(@RequestBody WeLive live){
  89. iWeLiveService.cancleLive(live);
  90. return AjaxResult.success();
  91. }
  92. /**
  93. * 同步直播
  94. * @return
  95. */
  96. @GetMapping("/synchLive")
  97. public AjaxResult synchLive(){
  98. iWeLiveService.synchLive();
  99. return AjaxResult.success();
  100. }
  101. /**
  102. * 导出直播
  103. * @return
  104. */
  105. @GetMapping("/exportWeLives")
  106. public void exportWeLives(){
  107. LwExcelUtil.exprotForWeb(
  108. ServletUtils.getResponse(), WeLive.class, iWeLiveService.findLives(new WeLive()),"直播"
  109. );
  110. }
  111. /**
  112. * 分享统计-tab(客户或客群维度) (客户或客群维度 1:客户 2:客群)
  113. * @param liveId
  114. * @return
  115. */
  116. @GetMapping("/findWeLiveTaskCustomerDetailTab")
  117. public AjaxResult findWeLiveTaskCustomerDetailTab(String liveId){
  118. WeLive weLive = iWeLiveService.getById(liveId);
  119. if(null != weLive){
  120. return AjaxResult.success(
  121. iWeLiveTipService.findWeLiveTaskExecuteUserDetailTab(liveId,weLive.getTargetType())
  122. );
  123. }
  124. return AjaxResult.success();
  125. }
  126. /**
  127. * 分享统计(员工维度)-tab
  128. * @param liveId
  129. * @return
  130. */
  131. @GetMapping("findWeLiveTaskUserDetailTab")
  132. public AjaxResult findWeLiveTaskUserDetailTab(String liveId){
  133. WeLive weLive = iWeLiveService.getById(liveId);
  134. if(null != weLive){
  135. return AjaxResult.success(
  136. iWeLiveTipService.findWeLiveTaskUserDetailTab(liveId,weLive.getTargetType())
  137. );
  138. }
  139. return AjaxResult.success();
  140. }
  141. /**
  142. * 分享统计-员工详情(客户或客群)
  143. * @param userName 员工名称
  144. * @param liveId 直播id
  145. * @param sendTargetType 目标类型 发送目标1:客户;2:客群
  146. * @return
  147. */
  148. @GetMapping("/findWeLiveTaskUserDetail")
  149. public TableDataInfo findWeLiveTaskUserDetail(String userName, String liveId,@RequestParam(defaultValue = "1") Integer sendTargetType){
  150. startPage();
  151. return getDataTable(
  152. iWeLiveTipService.findWeLiveTaskUserDetail(userName, liveId, sendTargetType)
  153. );
  154. }
  155. /**
  156. * 分享统计-客户详情(客户或客群)
  157. * @param sendTargetType 目标类型 发送目标1:客户;2:客群
  158. * @param userName 员工名称
  159. * @param liveId 直播id
  160. * @param sendState 直播状态(0:预约中;1:直播中;2:已结束;3:已过期;4:已取消)
  161. * @return
  162. */
  163. @GetMapping("/findWeLiveTaskCustomerDetail")
  164. public TableDataInfo findWeLiveTaskCustomerDetail(Integer sendTargetType,String userName,String liveId,Integer sendState){
  165. startPage();
  166. return getDataTable(
  167. iWeLiveTipService.findWeLiveTaskCustomerDetail(sendTargetType,userName,liveId,sendState)
  168. );
  169. }
  170. /**
  171. * 获取观众列表
  172. * @param weLiveWatchUser
  173. * @return
  174. */
  175. @GetMapping("/weLiveWatchUser")
  176. public TableDataInfo findVisitorList(WeLiveWatchUser weLiveWatchUser){
  177. startPage();
  178. return getDataTable(
  179. iWeLiveWatchUserService.list(
  180. new LambdaQueryWrapper<WeLiveWatchUser>()
  181. .eq(weLiveWatchUser.getLiveId() !=null,WeLiveWatchUser::getLiveId,weLiveWatchUser.getLiveId())
  182. .eq(weLiveWatchUser.getWatchUserType()!=null,WeLiveWatchUser::getWatchUserType,weLiveWatchUser.getWatchUserType())
  183. )
  184. );
  185. }
  186. /**
  187. * 获取直播凭证
  188. * @param livingId
  189. * @param openId
  190. * @return
  191. */
  192. @GetMapping("/getLivingCode")
  193. public AjaxResult getLivingCode(String livingId,String openId){
  194. WeLinveUserVo weLinveUserVo=new WeLinveUserVo();
  195. WeLive weLive = iWeLiveService.getById(livingId);
  196. if(null != weLive){
  197. weLinveUserVo.setLiveCode(iWeLiveService.getLivingCode(weLive.getLivingId(), openId));
  198. }
  199. return AjaxResult.success(
  200. weLinveUserVo
  201. );
  202. }
  203. /**
  204. * 导出观看成员
  205. * @param watchUserType
  206. * @return
  207. */
  208. @GetMapping("/exprotWeLiveWatchUser")
  209. public AjaxResult exprotWeLiveWatchUser(Integer watchUserType,String liveId){
  210. LwExcelUtil.exprotForWeb(
  211. ServletUtils.getResponse(), WeLiveWatchUser.class,
  212. iWeLiveWatchUserService.list(
  213. new LambdaQueryWrapper<WeLiveWatchUser>()
  214. .eq(StringUtils.isNotEmpty(liveId),WeLiveWatchUser::getLiveId,liveId)
  215. .eq(watchUserType != null, WeLiveWatchUser::getWatchUserType, watchUserType)
  216. )
  217. ,"观看成员"
  218. );
  219. return AjaxResult.success();
  220. }
  221. /**
  222. * 同步发送结果
  223. * @param id
  224. * @return
  225. */
  226. @GetMapping("/synchExecuteResult/{id}")
  227. public AjaxResult synchExecuteResult(@PathVariable String id){
  228. iWeLiveService.synchExecuteResult(id);
  229. return AjaxResult.success();
  230. }
  231. }