Room.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\store\controller\apps\live;
  10. use app\store\controller\Controller;
  11. use app\store\model\wxapp\LiveRoom as LiveRoomModel;
  12. /**
  13. * 小程序直播间管理
  14. * Class Room
  15. * @package app\store\controller\apps\live
  16. */
  17. class Room extends Controller
  18. {
  19. /**
  20. * 直播间列表页
  21. * @param string $search 检索词
  22. * @return mixed
  23. * @throws \think\exception\DbException
  24. */
  25. public function index($search = '')
  26. {
  27. $model = new LiveRoomModel;
  28. $list = $model->getList($search);
  29. return $this->fetch('index', compact('list'));
  30. }
  31. /**
  32. * 同步刷新直播间列表
  33. * @return array|bool
  34. * @throws \app\common\exception\BaseException
  35. * @throws \think\exception\DbException
  36. */
  37. public function refresh()
  38. {
  39. $model = new LiveRoomModel;
  40. if ($model->refreshLiveList()) {
  41. return $this->renderSuccess('同步成功');
  42. }
  43. return $this->renderError($model->getError() ?: '同步失败');
  44. }
  45. /**
  46. * 修改直播间置顶状态
  47. * @param $room_id
  48. * @param $is_top
  49. * @return array|bool
  50. * @throws \think\exception\DbException
  51. */
  52. public function settop($room_id, $is_top)
  53. {
  54. // 商品详情
  55. $model = LiveRoomModel::detail($room_id);
  56. if (!$model->setIsTop($is_top)) {
  57. return $this->renderError('操作失败');
  58. }
  59. return $this->renderSuccess('操作成功');
  60. }
  61. }