Live.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\live\api\controller;
  11. use addon\live\model\Room;
  12. use app\api\controller\BaseApi;
  13. /**
  14. * 直播
  15. */
  16. class Live extends BaseApi
  17. {
  18. /**
  19. * 获取直播间信息
  20. */
  21. public function info()
  22. {
  23. $room = new Room();
  24. $condition = [
  25. 'site_id' => $this->site_id,
  26. 'live_status' => '101'
  27. ];
  28. // 优先查询进行中的
  29. $room_info = $room->getRoomInfo($condition);
  30. if (empty($room_info[ 'data' ])) {
  31. $condition[ 'live_status' ] = '102';
  32. // 没有进行中的查询未开始的
  33. $room_info = $room->getRoomInfo($condition);
  34. }
  35. return $this->response($room_info);
  36. }
  37. /**
  38. * 获取直播间列表
  39. * @return false|string
  40. */
  41. public function page()
  42. {
  43. $page = isset($this->params[ 'page' ]) ? $this->params[ 'page' ] : 1;
  44. $page_size = isset($this->params[ 'page_size' ]) ? $this->params[ 'page_size' ] : PAGE_LIST_ROWS;
  45. $room = new Room();
  46. $data = $room->getRoomPageList([ 'site_id' => $this->site_id ], '*', 'live_status asc', $page, $page_size);
  47. return $this->response($data);
  48. }
  49. /**
  50. * 修改直播间状态
  51. */
  52. public function modifyLiveStatus()
  53. {
  54. $room_id = $this->params[ 'room_id' ] ?? 0;
  55. $status = $this->params[ 'status' ] ?? '';
  56. if (empty($status)) return $this->response($this->error());
  57. $room = new Room();
  58. $res = $room->updateRoomInfo([ 'live_status' => $status ], [ [ 'roomid', '=', $room_id ], [ 'site_id', '=', $this->site_id ] ]);
  59. return $this->response($res);
  60. }
  61. }