BroadcastRoom.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\store;
  12. use app\common\repositories\store\broadcast\BroadcastRoomGoodsRepository;
  13. use app\common\repositories\store\broadcast\BroadcastRoomRepository;
  14. use crmeb\basic\BaseController;
  15. use think\App;
  16. use think\response\Json;
  17. /**
  18. * 直播间
  19. */
  20. class BroadcastRoom extends BaseController
  21. {
  22. protected $repository;
  23. public function __construct(App $app, BroadcastRoomRepository $repository)
  24. {
  25. parent::__construct($app);
  26. $this->repository = $repository;
  27. }
  28. /**
  29. * 列表
  30. * @return Json
  31. * @author Qinii
  32. */
  33. public function lst()
  34. {
  35. [$page, $limit] = $this->getPage();
  36. $where = $this->request->params(['keyword', 'status_tag', 'is_trader', 'show_type', 'mer_id', 'live_status', 'star', 'broadcast_room_id']);
  37. return app('json')->success($this->repository->adminList($where, $page, $limit));
  38. }
  39. /**
  40. * 商品列表
  41. * @param BroadcastRoomGoodsRepository $repository
  42. * @param $id
  43. * @return Json
  44. * @author xaboy
  45. * @day 2020/8/31
  46. */
  47. public function goodsList(BroadcastRoomGoodsRepository $repository, $id)
  48. {
  49. [$page, $limit] = $this->getPage();
  50. if (!$this->repository->exists((int)$id))
  51. return app('json')->fail('直播间不存在');
  52. return app('json')->success($repository->getGoodsList($id, $page, $limit));
  53. }
  54. /**
  55. * 详情
  56. * @param $id
  57. * @return Json
  58. * @author Qinii
  59. */
  60. public function detail($id)
  61. {
  62. if (!$this->repository->exists($id))
  63. return app('json')->fail('数据不存在');
  64. return app('json')->success($this->repository->get($id)->toArray());
  65. }
  66. /**
  67. * 审核表单
  68. * @param $id
  69. * @return Json
  70. * @author Qinii
  71. */
  72. public function applyForm($id)
  73. {
  74. if (!$this->repository->exists($id))
  75. return app('json')->fail('数据不存在');
  76. return app('json')->success(formToData($this->repository->applyForm($id)));
  77. }
  78. /**
  79. * 审核
  80. * @param $id
  81. * @return Json
  82. * @author Qinii
  83. */
  84. public function apply($id)
  85. {
  86. if (!$this->repository->exists($id))
  87. return app('json')->fail('数据不存在');
  88. [$status, $msg] = $this->request->params(['status', 'msg'], true);
  89. $status = $status == 1 ? 1 : -1;
  90. if ($status == -1 && !$msg)
  91. return app('json')->fail('请输入理由');
  92. $this->repository->apply($id, $status, $msg);
  93. return app('json')->success('操作成功');
  94. }
  95. /**
  96. * 显示状态
  97. * @param $id
  98. * @return Json
  99. * @author Qinii
  100. */
  101. public function changeStatus($id)
  102. {
  103. $isShow = $this->request->param('is_show') == 1 ? 1 : 0;
  104. if (!$this->repository->exists($id))
  105. return app('json')->fail('数据不存在');
  106. $this->repository->isShow($id, $isShow, true);
  107. return app('json')->success('修改成功');
  108. }
  109. /**
  110. * 直播回放修改
  111. * @param $id
  112. * @return Json
  113. * @author Qinii
  114. */
  115. public function changeLiveStatus($id)
  116. {
  117. $isShow = $this->request->param('replay_status') == 1 ? 1 : 0;
  118. if (!$this->repository->exists($id))
  119. return app('json')->fail('数据不存在');
  120. $this->repository->update($id, ['replay_status' => $isShow]);
  121. return app('json')->success('修改成功');
  122. }
  123. /**
  124. * 直播间排序
  125. * @param $id
  126. * @return Json
  127. * @author Qinii
  128. */
  129. public function sort($id)
  130. {
  131. $sort = (int)$this->request->param('sort');
  132. $star = (int)$this->request->param('star');
  133. if ($star < 0 || $star > 5)
  134. return app('json')->fail('请选择正确的星级');
  135. if (!$this->repository->exists($id))
  136. return app('json')->fail('数据不存在');
  137. $this->repository->update($id, compact('sort', 'star'));
  138. return app('json')->success('修改成功');
  139. }
  140. /**
  141. * 删除
  142. * @param $id
  143. * @return Json
  144. * @author Qinii
  145. */
  146. public function delete($id)
  147. {
  148. if (!$this->repository->exists($id))
  149. return app('json')->fail('数据不存在');
  150. $this->repository->delete($id);
  151. return app('json')->success('删除成功');
  152. }
  153. /**
  154. * 关闭客服
  155. * @param $id
  156. * @return Json
  157. * @author Qinii
  158. */
  159. public function closeKf($id)
  160. {
  161. $status = $this->request->param('status') == 1 ? 1 : -1;
  162. $this->repository->closeInfo($id, 'close_kf', $status, false);
  163. return app('json')->success('修改成功');
  164. }
  165. /**
  166. * 禁言
  167. * @param $id
  168. * @return Json
  169. * @author Qinii
  170. */
  171. public function banComment($id)
  172. {
  173. $status = $this->request->param('status') == 1 ? 1 : -1;
  174. $this->repository->closeInfo($id, 'close_comment', $status, false);
  175. return app('json')->success('修改成功');
  176. }
  177. /**
  178. * 直播间是否公开
  179. * @param $id
  180. * @return Json
  181. * @author Qinii
  182. */
  183. public function isFeedsPublic($id)
  184. {
  185. $status = $this->request->param('status') == 1 ? 1 : -1;
  186. $this->repository->closeInfo($id, 'is_feeds_public', $status, false);
  187. return app('json')->success('修改成功');
  188. }
  189. }