BroadcastRoom.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace app\controller\admin\store;
  3. use app\common\repositories\store\broadcast\BroadcastRoomGoodsRepository;
  4. use app\common\repositories\store\broadcast\BroadcastRoomRepository;
  5. use ln\basic\BaseController;
  6. use think\App;
  7. use think\response\Json;
  8. class BroadcastRoom extends BaseController
  9. {
  10. protected $repository;
  11. public function __construct(App $app, BroadcastRoomRepository $repository)
  12. {
  13. parent::__construct($app);
  14. $this->repository = $repository;
  15. }
  16. public function lst()
  17. {
  18. [$page, $limit] = $this->getPage();
  19. $where = $this->request->params(['keyword', 'status_tag', 'is_trader', 'show_type','mer_id','live_status', 'star','broadcast_room_id']);
  20. return app('json')->success($this->repository->adminList($where, $page, $limit));
  21. }
  22. /**
  23. * @param BroadcastRoomGoodsRepository $repository
  24. * @param $id
  25. * @return Json
  26. * @author zfy
  27. * @day 2020/8/31
  28. */
  29. public function goodsList(BroadcastRoomGoodsRepository $repository, $id)
  30. {
  31. [$page, $limit] = $this->getPage();
  32. if (!$this->repository->exists((int)$id))
  33. return app('json')->fail('直播间不存在');
  34. return app('json')->success($repository->getGoodsList($id, $page, $limit));
  35. }
  36. public function detail($id)
  37. {
  38. if (!$this->repository->exists($id))
  39. return app('json')->fail('数据不存在');
  40. return app('json')->success($this->repository->get($id)->toArray());
  41. }
  42. public function applyForm($id)
  43. {
  44. if (!$this->repository->exists($id))
  45. return app('json')->fail('数据不存在');
  46. return app('json')->success(formToData($this->repository->applyForm($id)));
  47. }
  48. public function apply($id)
  49. {
  50. if (!$this->repository->exists($id))
  51. return app('json')->fail('数据不存在');
  52. [$status, $msg] = $this->request->params(['status', 'msg'], true);
  53. $status = $status == 1 ? 1 : -1;
  54. if ($status == -1 && !$msg)
  55. return app('json')->fail('请输入理由');
  56. $this->repository->apply($id, $status, $msg);
  57. return app('json')->success('操作成功');
  58. }
  59. public function changeStatus($id)
  60. {
  61. $isShow = $this->request->param('is_show') == 1 ? 1 : 0;
  62. if (!$this->repository->exists($id))
  63. return app('json')->fail('数据不存在');
  64. $this->repository->isShow($id, $isShow, true);
  65. return app('json')->success('修改成功');
  66. }
  67. public function changeLiveStatus($id)
  68. {
  69. $isShow = $this->request->param('replay_status') == 1 ? 1 : 0;
  70. if (!$this->repository->exists($id))
  71. return app('json')->fail('数据不存在');
  72. $this->repository->update($id, ['replay_status' => $isShow]);
  73. return app('json')->success('修改成功');
  74. }
  75. public function sort($id)
  76. {
  77. $sort = (int)$this->request->param('sort');
  78. $star = (int)$this->request->param('star');
  79. if ($star < 0 || $star > 5)
  80. return app('json')->fail('请选择正确的星级');
  81. if (!$this->repository->exists($id))
  82. return app('json')->fail('数据不存在');
  83. $this->repository->update($id, compact('sort', 'star'));
  84. return app('json')->success('修改成功');
  85. }
  86. public function delete($id)
  87. {
  88. if (!$this->repository->exists($id))
  89. return app('json')->fail('数据不存在');
  90. $this->repository->delete($id);
  91. return app('json')->success('删除成功');
  92. }
  93. }