BroadcastRoom.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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. class BroadcastRoom extends BaseController
  18. {
  19. protected $repository;
  20. public function __construct(App $app, BroadcastRoomRepository $repository)
  21. {
  22. parent::__construct($app);
  23. $this->repository = $repository;
  24. }
  25. public function lst()
  26. {
  27. [$page, $limit] = $this->getPage();
  28. $where = $this->request->params(['keyword', 'status_tag', 'is_trader', 'show_type','mer_id','live_status', 'star','broadcast_room_id']);
  29. return app('json')->success($this->repository->adminList($where, $page, $limit));
  30. }
  31. /**
  32. * @param BroadcastRoomGoodsRepository $repository
  33. * @param $id
  34. * @return Json
  35. * @author xaboy
  36. * @day 2020/8/31
  37. */
  38. public function goodsList(BroadcastRoomGoodsRepository $repository, $id)
  39. {
  40. [$page, $limit] = $this->getPage();
  41. if (!$this->repository->exists((int)$id))
  42. return app('json')->fail('直播间不存在');
  43. return app('json')->success($repository->getGoodsList($id, $page, $limit));
  44. }
  45. public function detail($id)
  46. {
  47. if (!$this->repository->exists($id))
  48. return app('json')->fail('数据不存在');
  49. return app('json')->success($this->repository->get($id)->toArray());
  50. }
  51. public function applyForm($id)
  52. {
  53. if (!$this->repository->exists($id))
  54. return app('json')->fail('数据不存在');
  55. return app('json')->success(formToData($this->repository->applyForm($id)));
  56. }
  57. public function apply($id)
  58. {
  59. if (!$this->repository->exists($id))
  60. return app('json')->fail('数据不存在');
  61. [$status, $msg] = $this->request->params(['status', 'msg'], true);
  62. $status = $status == 1 ? 1 : -1;
  63. if ($status == -1 && !$msg)
  64. return app('json')->fail('请输入理由');
  65. $this->repository->apply($id, $status, $msg);
  66. return app('json')->success('操作成功');
  67. }
  68. public function changeStatus($id)
  69. {
  70. $isShow = $this->request->param('is_show') == 1 ? 1 : 0;
  71. if (!$this->repository->exists($id))
  72. return app('json')->fail('数据不存在');
  73. $this->repository->isShow($id, $isShow, true);
  74. return app('json')->success('修改成功');
  75. }
  76. public function changeLiveStatus($id)
  77. {
  78. $isShow = $this->request->param('replay_status') == 1 ? 1 : 0;
  79. if (!$this->repository->exists($id))
  80. return app('json')->fail('数据不存在');
  81. $this->repository->update($id, ['replay_status' => $isShow]);
  82. return app('json')->success('修改成功');
  83. }
  84. public function sort($id)
  85. {
  86. $sort = (int)$this->request->param('sort');
  87. $star = (int)$this->request->param('star');
  88. if ($star < 0 || $star > 5)
  89. return app('json')->fail('请选择正确的星级');
  90. if (!$this->repository->exists($id))
  91. return app('json')->fail('数据不存在');
  92. $this->repository->update($id, compact('sort', 'star'));
  93. return app('json')->success('修改成功');
  94. }
  95. public function delete($id)
  96. {
  97. if (!$this->repository->exists($id))
  98. return app('json')->fail('数据不存在');
  99. $this->repository->delete($id);
  100. return app('json')->success('删除成功');
  101. }
  102. }