LiveRoom.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\v1\marketing\live;
  12. use app\adminapi\controller\AuthController;
  13. use app\services\activity\live\LiveRoomServices;
  14. use think\facade\App;
  15. /**
  16. * 直播间
  17. * Class LiveRoom
  18. * @package app\adminapi\controller\v1\marketing\live
  19. */
  20. class LiveRoom extends AuthController
  21. {
  22. /**
  23. * LiveRoom constructor.
  24. * @param App $app
  25. * @param LiveRoomServices $services
  26. */
  27. public function __construct(App $app, LiveRoomServices $services)
  28. {
  29. parent::__construct($app);
  30. $this->services = $services;
  31. }
  32. /**
  33. * 直播间列表
  34. * @return mixed
  35. */
  36. public function list()
  37. {
  38. $where = $this->request->postMore([
  39. ['kerword', ''],
  40. ['status', '']
  41. ]);
  42. return app('json')->success($this->services->getList($where));
  43. }
  44. /**
  45. * 直播间详情
  46. * @param $id
  47. * @return mixed
  48. */
  49. public function detail($id)
  50. {
  51. if (!$id) return app('json')->fail(100100);
  52. return app('json')->success($this->services->get((int)$id)->toArray());
  53. }
  54. /**
  55. * 添加直播间
  56. * @return mixed
  57. */
  58. public function add()
  59. {
  60. $data = $this->request->postMore([
  61. ['name', ''],
  62. ['cover_img', ''],
  63. ['share_img', ''],
  64. ['anchor_name', ''],
  65. ['anchor_wechat', ''],
  66. ['phone', ''],
  67. ['start_time', ['', '']],
  68. ['type', 1],
  69. ['screen_type', 1],
  70. ['close_like', 0],
  71. ['close_goods', 0],
  72. ['close_comment', 0],
  73. ['replay_status', 1],
  74. ['sort', 0]
  75. ]);
  76. if (mb_strlen($data['name']) < 6 || mb_strlen($data['name']) > 17) {
  77. return app('json')->fail(500030);
  78. }
  79. $this->validate($data, \app\adminapi\validate\marketing\LiveRoomValidate::class, 'save');
  80. $this->services->add($data);
  81. return app('json')->success(100000);
  82. }
  83. /**
  84. * 添加直播间商品
  85. * @return mixed
  86. * @throws \think\db\exception\DataNotFoundException
  87. * @throws \think\db\exception\DbException
  88. * @throws \think\db\exception\ModelNotFoundException
  89. */
  90. public function addGoods()
  91. {
  92. [$room_id, $goods_ids] = $this->request->postMore([
  93. ['room_id', 0],
  94. ['goods_ids', []]
  95. ], true);
  96. $this->services->exportGoods((int)$room_id, $goods_ids);
  97. return app('json')->success(100000);
  98. }
  99. /**
  100. * 提交审核
  101. * @param $id
  102. * @return mixed
  103. */
  104. public function apply($id)
  105. {
  106. [$status, $msg] = $this->request->postMore([
  107. ['status', ''],
  108. ['msg', '']
  109. ], true);
  110. $this->services->apply((int)$id, $status, $msg);
  111. return app('json')->success(100014);
  112. }
  113. /**
  114. * 设置状态
  115. * @param $id
  116. * @param $is_show
  117. * @return mixed
  118. */
  119. public function setShow($id, $is_show)
  120. {
  121. $this->services->isShow((int)$id, $is_show);
  122. return app('json')->success(100014);
  123. }
  124. /**
  125. * 删除直播间
  126. * @param $id
  127. * @return mixed
  128. */
  129. public function delete($id)
  130. {
  131. $this->services->delete($id);
  132. return app('json')->success(100002);
  133. }
  134. /**
  135. * 同步直播间
  136. * @return mixed
  137. */
  138. public function syncRoom()
  139. {
  140. $this->services->syncRoomStatus();
  141. return app('json')->success(100038);
  142. }
  143. }