BroadcastRoom.php 3.4 KB

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