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() { $userInfo = $this->getUserInfo(); if(!$userInfo){ return jsonError('获取用户信息失败'); } $floor = $this->floor ->where('is_open', 1) ->whereIn('floor_type', [0,1,2,3]) ->whereBetween('floor_location', [1,20]) ->get(); $data = []; foreach($floor as $item){ if($item->floor_type == 0){ //banner $banner = $this->getBanner($item->group_ids); 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_info.member_group_id', '=', 'member_group.id') ->where('member_group.id', $item->group_ids) ->limit(20) ->pluck('member_group_info.uid') ->toArray(); if(!$memberIds) continue; $memberIds = implode($memberIds, ','); $member = $this->getMemberGroup($memberIds); 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) ->limit(20) ->pluck('video_group_info.post_id') ->toArray(); if(!$videoIds) continue; $videoIds = implode($videoIds, ','); $video = $this->getPostVideo($videoIds); 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, ','); $topic = $this->getTopic($topicIds); if(!$topic) continue; $data[$item->floor_location] = [ 'show_type' => 'topic', 'data' => $topic ]; } } return $data; } }