bp/app/Config/BusinessModules.php

152 lines
4.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Config;
use CodeIgniter\Config\BaseConfig;
/**
* Конфигурация бизнес-модулей системы
*
* Определяет доступные модули, их параметры и цены.
*/
class BusinessModules extends BaseConfig
{
/**
* Список доступных модулей
*
* @var array<string, array{
* name: string,
* description: string,
* price_monthly: int,
* price_yearly: int,
* trial_days: int,
* features: string[]
* }>
*/
public array $modules = [
'base' => [
'name' => 'Базовый модуль',
'description' => 'Основные функции управления клиентами',
'price_monthly' => 0,
'price_yearly' => 0,
'trial_days' => 0,
'features' => [
'Управление клиентами',
'Базовая история взаимодействий',
],
],
'crm' => [
'name' => 'CRM',
'description' => 'Полноценная CRM-система с воронками продаж',
'price_monthly' => 990,
'price_yearly' => 9900,
'trial_days' => 14,
'features' => [
'Воронки продаж',
'Управление контактами',
'Этапы сделок',
'Drag-n-drop сортировка',
'Автоматизация',
],
],
'booking' => [
'name' => 'Бронирования',
'description' => 'Управление бронированиями и расписанием',
'price_monthly' => 1490,
'price_yearly' => 14900,
'trial_days' => 14,
'features' => [
'Календарь бронирований',
'Управление ресурсами',
'Уведомления клиентам',
],
],
'tasks' => [
'name' => 'Задачи',
'description' => 'Управление задачами и проектами',
'price_monthly' => 790,
'price_yearly' => 7900,
'trial_days' => 14,
'features' => [
'Доски задач',
'Назначение ответственных',
'Сроки и дедлайны',
],
],
'proof' => [
'name' => 'Proof',
'description' => 'Система согласования документов',
'price_monthly' => 590,
'price_yearly' => 5900,
'trial_days' => 14,
'features' => [
'Согласование документов',
'Комментарии и версии',
'Утверждение',
],
],
];
/**
* Проверка существования модуля
*
* @param string $moduleCode
* @return bool
*/
public function exists(string $moduleCode): bool
{
return isset($this->modules[$moduleCode]);
}
/**
* Получение информации о модуле (без переопределений)
*
* @param string $moduleCode
* @return array|null
*/
public function getModule(string $moduleCode): ?array
{
return $this->modules[$moduleCode] ?? null;
}
/**
* Получение цены модуля
*
* @param string $moduleCode
* @param string $period 'monthly' или 'yearly'
* @return int
*/
public function getPrice(string $moduleCode, string $period = 'monthly'): int
{
$module = $this->getModule($moduleCode);
if (!$module) {
return 0;
}
return $period === 'yearly' ? $module['price_yearly'] : $module['price_monthly'];
}
/**
* Получение списка всех кодов модулей
*
* @return array
*/
public function getAllModuleCodes(): array
{
return array_keys($this->modules);
}
/**
* Получение списка платных модулей (с возможностью триала)
*
* @return array<string, array>
*/
public function getPaidModules(): array
{
return array_filter($this->modules, function ($module) {
return $module['trial_days'] > 0;
});
}
}