post(); $pageSize = request()->post('pageSize', 0); $params['is_recommend'] = 1; $datas = LiveService::make()->getDataList($params, $pageSize,'', $this->userId); return showJson(1010, true, $datas); } catch (\Exception $exception){ RedisService::set("caches:request:error_live_index", ['error'=>$exception->getMessage(),'trace'=>$exception->getTrace()], 7200); return showJson(1018, false, ['error'=>env('APP_DEBUG')? $exception->getMessage() : '']); } } /** * 在线用户数据 * @return array */ public function users() { $params =request()->post(); $pageSize = request()->post('pageSize', 15); $datas = LiveService::make()->getUserList($params, $pageSize, $this->userId); return showJson(1010, true, $datas); } /** * 礼物列表 * @return array */ public function giftList() { $params =request()->post(); $pageSize = request()->post('pageSize', 15); $datas = LiveService::make()->getGiftList($params, $pageSize, $this->userId); return showJson(1010, true, $datas); } /** * 播放与浏览 * @return array */ public function updatePlay() { $id = request()->post('id',0); if(!$result = LiveService::make()->updatePlay($this->userId, $id)){ return showJson(LiveService::make()->getError(), false); }else{ return showJson(LiveService::make()->getError(), true, $result); } } /** * 获取流地址 * @return array */ public function getUrl() { $urls = LiveService::make()->getLiveUrl($this->userId); return showJson(1010, true, $urls); } /** * 直播详情 * @param LiveValidator $validator * @return array */ public function getInfo(LiveValidator $validator) { $params = request()->all(); $params = $validator->check($params, 'info'); if (!is_array($params)) { return showJson($params, false); } if(!$info = LiveService::make()->getInfo($params['id'], $this->userId)){ return showJson(LiveService::make()->getError(),false); }else{ return showJson(1010,true, $info); } } /** * 更新观看时长任务 * @return array */ public function updatePlayTask() { // 观看直播任务 $id = request()->post('id',0); $time = request()->post('time',0); TaskService::make()->updateTask($this->userId,1, $id, $time); return showJson(1010,true, []); } /** * 状态 * @return array|mixed */ public function status() { if(!$result = LiveService::make()->status()){ return showJson(LiveService::make()->getError(), false); }else{ return showJson(LiveService::make()->getError(), true, $result); } } /** * 点赞 * @return array|mixed */ public function like() { $params = request()->post(); if(!$result = LiveService::make()->like($this->userId, $params)){ return showJson(LiveService::make()->getError(), false); }else{ return showJson(LiveService::make()->getError(), true, $result); } } /** * 创建直播间(开启直播) * @return array */ public function create(LiveValidator $validator) { $params = request()->all(); $params = $validator->check($params, 'create'); if (!is_array($params)) { return showJson($params, false); } if(!$result = LiveService::make()->create($this->userId, $params)){ return showJson(LiveService::make()->getError(),false); }else{ return showJson(LiveService::make()->getError(),true, $result); } } /** * 礼物打赏 * @return array */ public function reward() { $params = request()->all(); if(!$result = LiveService::make()->reward($this->userId, $params)){ return showJson(LiveService::make()->getError(),false); }else{ return showJson(LiveService::make()->getError(),true, $result); } } }