floor = $floor; $this->memberGroup = $memberGroup; $this->memberGroupInfo = $memberGroupInfo; $this->videoGroup = $videoGroup; $this->videoGroupInfo = $videoGroupInfo; $this->topicGroup = $topicGroup; $this->topicGroupInfo = $topicGroupInfo; } public function index($request) { $perPage = isset($request['per_page']) ? $request['per_page'] : 20; $where = []; $where[] = ['is_open', 1]; return $this->floor->where($where)->orderBy('floor_location', 'asc')->paginate($perPage); } public function info() { Log::debug('推荐内容楼层-开始请求'); $floor = $this->floor ->where('is_open', 1) ->whereIn('floor_type', [0,1,2,3]) ->whereBetween('floor_location', [1,20]) ->get(); Log::debug('推荐内容楼层-楼层列表'.json_encode($floor)); $data = []; foreach($floor as $item){ if($item->floor_type == 0){ //banner $banner = $this->getBanner($item->group_ids); Log::debug('推荐内容楼层-banner'.json_encode($banner)); if($banner){ $data[$item->floor_location] = [ 'show_type' => 'banner', 'data' => $banner ]; } }elseif($item->floor_type == 1){ //user $memberIds = $this->memberGroup ->join('member_group_info', '.member_group_id', '=', 'member_group.id') ->where('member_group.id', $item->group_ids) ->orderBy('member_group_info.sort', 'asc') ->limit(20) ->pluck('member_group_info.uid') ->toArray(); if(!$memberIds) continue; $memberIds = implode($memberIds, ','); $member = $this->getMemberGroup($memberIds); Log::debug('推荐内容楼层-user'.json_encode($member)); if(!$member) continue; $data[$item->floor_location] = [ 'show_type' => 'user', 'data' => $member ]; }elseif($item->floor_type == 2){ //video $videoIds = $this->videoGroup ->join('video_group_info', 'video_group_info.video_group_id', '=', 'video_group.id') ->where('video_group.id', $item->group_ids) ->orderBy('video_group_info.sort', 'asc') ->limit(20) ->pluck('video_group_info.post_id') ->toArray(); if(!$videoIds) continue; $videoIds = implode($videoIds, ','); $video = $this->getPostVideo($videoIds); Log::debug('推荐内容楼层-video'.json_encode($video)); if(!$video) continue; $data[$item->floor_location] = [ 'show_type' => 'video', 'data' => $video ]; }elseif($item->floor_type == 3){ //topic $topicIds = $this->topicGroup ->join('topic_group_info', 'topic_group_info.topic_group_id', '=', 'topic_group.id') ->where('topic_group.id', $item->group_ids) ->limit(20) ->pluck('topic_group_info.topic_id') ->toArray(); if(!$topicIds) continue; $topicIds = implode($topicIds, ','); Log::debug('推荐内容楼层-topicIds'.$topicIds); $topic = $this->getTopic($topicIds); Log::debug('推荐内容楼层-topic'.json_encode($topic)); if(!$topic) continue; $data[$item->floor_location] = [ 'show_type' => 'topic', 'data' => $topic ]; } } Log::debug('推荐内容楼层-data'.json_encode($data)); return jsonSuccess($data); } public function hotVideoIds() { $id = $this->floor ->where('is_open', 1) ->where('floor_type', 2) ->value('group_ids'); $data = ''; if($id){ //video $videoIds = $this->videoGroup ->join('video_group_info', 'video_group_info.video_group_id', '=', 'video_group.id') ->where('video_group.id', $id) ->orderBy('video_group_info.sort', 'asc') ->pluck('video_group_info.post_id') ->toArray(); if($videoIds){ $data = implode($videoIds, ','); $key = 'hotVideoIds'; Redis::SET($key, $data); Redis::EXPIRE($key, 600); } } Log::debug('热门视频ids'.$data); return jsonSuccess($data); } }