isEmpty()) { return false; } return $user->is_vip == 1 && $user->vip_expire_time > time(); } /** * @notes 获取用户当前VIP等级配置(未过期才返回) */ public static function getUserVipLevel(int $userId): ?array { $user = User::findOrEmpty($userId); if ($user->isEmpty() || $user->is_vip != 1 || $user->vip_expire_time <= time()) { return null; } $level = VipLevel::where('level', $user->vip_level)->where('status', 1)->findOrEmpty(); if ($level->isEmpty()) { return null; } return $level->toArray(); } /** * @notes 检查VIP用户是否享有翻译免费权益 */ public static function hasTranslateFree(int $userId): bool { $level = self::getUserVipLevel($userId); return $level && !empty($level['translate_free']); } /** * @notes 检查VIP用户是否享有解锁帖子免费权益 */ public static function hasUnlockFree(int $userId): bool { $level = self::getUserVipLevel($userId); return $level && !empty($level['unlock_free']); } }