user(); if (empty($user)) { $user = $this->authCheck(); } if (empty($user)) { return $this->failure('你的账号还没登录'); } if ($user->type != 'single' || $user->live_match_maker) { return $next($request); } //检查自己是否是否是会员 $is_super_rank = $user->isSuperRank(); if (empty($is_super_rank)) { $type = 'rank'; //如果是查看用户详情,普通用户可以每天查看七个 if ($request->route()->getName() === 'other_user_infor') { $count = 7; $other_user_id = $request->id; $result = $this->checkPreview($user, $count, $other_user_id); if (empty($result)) { return $this->failv2('普通用户每天只可查看'.$count.'位用户,升级会员可查看更多!', compact('type')); }else{ return $next($request); } } return $this->failv2('购买超级会员获得更多用户权限', compact('type')); } return $next($request); } //如果是查看用户详情,普通用户可以每天查看七个 public function checkPreview($user, $count, $other_user_id) { $start_time = date('Y-m-d'); //普通用户可以查看7个用户 $history_count = UserPreview::where('preview_user_id', $user->id)->where('preview_time', '>', $start_time)->distinct('user_id')->pluck('user_id')->toArray(); $in_preview = in_array($other_user_id, $history_count); if (count($history_count) >= $count && empty($in_preview)) { return false; } return true; } }