uchill/backend/apps/subscriptions/management/commands/create_diverse_subscription...

295 lines
14 KiB
Python
Raw Permalink 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.

"""
Команда для создания разнообразных тарифных планов с разными наборами функций.
"""
from django.core.management.base import BaseCommand
from django.utils import timezone
from apps.subscriptions.models import SubscriptionPlan, BulkDiscount
from decimal import Decimal
class Command(BaseCommand):
help = 'Создает разнообразные тарифные планы с разными наборами функций'
def handle(self, *args, **options):
self.stdout.write('Создание разнообразных тарифных планов...')
# Список всех возможных функций для отображения
all_features = {
'video_calls': 'Видеозвонки',
'screen_sharing': 'Демонстрация экрана',
'whiteboard': 'Интерактивная доска',
'homework': 'Домашние задания',
'materials': 'Материалы',
'analytics': 'Аналитика',
'telegram_bot': 'Telegram бот',
'api_access': 'API доступ',
}
# 1. СТАРТОВЫЙ - минимальные функции (только базовые)
plan_start, created = SubscriptionPlan.objects.update_or_create(
slug='start',
defaults={
'name': 'Стартовый',
'description': 'Идеально для начинающих репетиторов. Базовые функции для проведения занятий.',
'price': Decimal('500'),
'price_per_student': None,
'currency': 'RUB',
'billing_period': 'monthly',
'subscription_type': 'monthly',
'trial_days': 7,
'max_clients': 5,
'max_lessons_per_month': 20,
'max_storage_mb': 1024, # 1 GB
'max_video_minutes_per_month': 300,
'allow_video_calls': True,
'allow_screen_sharing': True,
'allow_whiteboard': False, # НЕТ
'allow_homework': False, # НЕТ
'allow_materials': True,
'allow_analytics': False, # НЕТ
'allow_telegram_bot': False, # НЕТ
'allow_api_access': False, # НЕТ
'is_active': True,
'is_featured': False,
'sort_order': 1,
}
)
if created:
self.stdout.write(self.style.SUCCESS(f'✓ Создан план: {plan_start.name}'))
else:
self.stdout.write(self.style.WARNING(f'⚠ План уже существует: {plan_start.name}'))
# 2. БАЗОВЫЙ - основные функции
plan_basic, created = SubscriptionPlan.objects.update_or_create(
slug='basic',
defaults={
'name': 'Базовый',
'description': 'Популярный тариф для большинства репетиторов. Все необходимые функции для эффективной работы.',
'price': Decimal('1500'),
'price_per_student': None,
'currency': 'RUB',
'billing_period': 'monthly',
'subscription_type': 'monthly',
'trial_days': 14,
'max_clients': 15,
'max_lessons_per_month': 50,
'max_storage_mb': 5120, # 5 GB
'max_video_minutes_per_month': 1000,
'allow_video_calls': True,
'allow_screen_sharing': True,
'allow_whiteboard': True,
'allow_homework': True,
'allow_materials': True,
'allow_analytics': True,
'allow_telegram_bot': False, # НЕТ
'allow_api_access': False, # НЕТ
'is_active': True,
'is_featured': True,
'sort_order': 2,
}
)
if created:
self.stdout.write(self.style.SUCCESS(f'✓ Создан план: {plan_basic.name}'))
else:
self.stdout.write(self.style.WARNING(f'⚠ План уже существует: {plan_basic.name}'))
# 3. ПРОФЕССИОНАЛЬНЫЙ - большинство функций
plan_pro, created = SubscriptionPlan.objects.update_or_create(
slug='professional',
defaults={
'name': 'Профессиональный',
'description': 'Для опытных репетиторов и небольших школ. Расширенные возможности и автоматизация.',
'price': Decimal('3500'),
'price_per_student': None,
'currency': 'RUB',
'billing_period': 'monthly',
'subscription_type': 'monthly',
'trial_days': 14,
'max_clients': 50,
'max_lessons_per_month': None, # Безлимит
'max_storage_mb': 20480, # 20 GB
'max_video_minutes_per_month': None, # Безлимит
'allow_video_calls': True,
'allow_screen_sharing': True,
'allow_whiteboard': True,
'allow_homework': True,
'allow_materials': True,
'allow_analytics': True,
'allow_telegram_bot': True,
'allow_api_access': False, # НЕТ
'is_active': True,
'is_featured': True,
'sort_order': 3,
}
)
if created:
self.stdout.write(self.style.SUCCESS(f'✓ Создан план: {plan_pro.name}'))
else:
self.stdout.write(self.style.WARNING(f'⚠ План уже существует: {plan_pro.name}'))
# 4. БИЗНЕС - все функции
plan_business, created = SubscriptionPlan.objects.update_or_create(
slug='business',
defaults={
'name': 'Бизнес',
'description': 'Для образовательных центров и крупных школ. Все функции без ограничений.',
'price': Decimal('7000'),
'price_per_student': None,
'currency': 'RUB',
'billing_period': 'monthly',
'subscription_type': 'monthly',
'trial_days': 30,
'max_clients': None, # Безлимит
'max_lessons_per_month': None, # Безлимит
'max_storage_mb': 51200, # 50 GB
'max_video_minutes_per_month': None, # Безлимит
'allow_video_calls': True,
'allow_screen_sharing': True,
'allow_whiteboard': True,
'allow_homework': True,
'allow_materials': True,
'allow_analytics': True,
'allow_telegram_bot': True,
'allow_api_access': True, # ЕСТЬ
'is_active': True,
'is_featured': True,
'sort_order': 4,
}
)
if created:
self.stdout.write(self.style.SUCCESS(f'✓ Создан план: {plan_business.name}'))
else:
self.stdout.write(self.style.WARNING(f'⚠ План уже существует: {plan_business.name}'))
# 5. ЗА УЧЕНИКА (БАЗОВЫЙ) - основные функции
plan_per_student_basic, created = SubscriptionPlan.objects.update_or_create(
slug='per-student-basic-new',
defaults={
'name': 'За ученика (Базовый) - Новый',
'description': 'Гибкая оплата за каждого ученика. Базовые функции для работы с учениками.',
'price': Decimal('0'),
'price_per_student': Decimal('100'),
'currency': 'RUB',
'billing_period': 'monthly',
'subscription_type': 'per_student',
'trial_days': 7,
'max_clients': None,
'max_lessons_per_month': None,
'max_storage_mb': 5120, # 5 GB
'max_video_minutes_per_month': None,
'allow_video_calls': True,
'allow_screen_sharing': True,
'allow_whiteboard': True,
'allow_homework': True,
'allow_materials': True,
'allow_analytics': True,
'allow_telegram_bot': False, # НЕТ
'allow_api_access': False, # НЕТ
'is_active': True,
'is_featured': True,
'sort_order': 5,
}
)
if created:
self.stdout.write(self.style.SUCCESS(f'✓ Создан план: {plan_per_student_basic.name}'))
# Прогрессирующие скидки
BulkDiscount.objects.get_or_create(
plan=plan_per_student_basic,
min_students=1,
max_students=4,
defaults={'price_per_student': Decimal('100')}
)
BulkDiscount.objects.get_or_create(
plan=plan_per_student_basic,
min_students=5,
max_students=9,
defaults={'price_per_student': Decimal('84')}
)
BulkDiscount.objects.get_or_create(
plan=plan_per_student_basic,
min_students=10,
max_students=None,
defaults={'price_per_student': Decimal('80')}
)
self.stdout.write(self.style.SUCCESS(' ✓ Созданы прогрессирующие скидки'))
else:
self.stdout.write(self.style.WARNING(f'⚠ План уже существует: {plan_per_student_basic.name}'))
# 6. ЗА УЧЕНИКА (ПРЕМИУМ) - все функции
plan_per_student_premium, created = SubscriptionPlan.objects.update_or_create(
slug='per-student-premium-new',
defaults={
'name': 'За ученика (Премиум) - Новый',
'description': 'Премиум тариф за ученика со всеми функциями. Идеально для профессиональных репетиторов.',
'price': Decimal('0'),
'price_per_student': Decimal('150'),
'currency': 'RUB',
'billing_period': 'monthly',
'subscription_type': 'per_student',
'trial_days': 14,
'max_clients': None,
'max_lessons_per_month': None,
'max_storage_mb': 10240, # 10 GB
'max_video_minutes_per_month': None,
'allow_video_calls': True,
'allow_screen_sharing': True,
'allow_whiteboard': True,
'allow_homework': True,
'allow_materials': True,
'allow_analytics': True,
'allow_telegram_bot': True,
'allow_api_access': True, # ЕСТЬ
'is_active': True,
'is_featured': True,
'sort_order': 6,
}
)
if created:
self.stdout.write(self.style.SUCCESS(f'✓ Создан план: {plan_per_student_premium.name}'))
# Прогрессирующие скидки
BulkDiscount.objects.get_or_create(
plan=plan_per_student_premium,
min_students=1,
max_students=4,
defaults={'price_per_student': Decimal('150')}
)
BulkDiscount.objects.get_or_create(
plan=plan_per_student_premium,
min_students=5,
max_students=9,
defaults={'price_per_student': Decimal('126')}
)
BulkDiscount.objects.get_or_create(
plan=plan_per_student_premium,
min_students=10,
max_students=None,
defaults={'price_per_student': Decimal('120')}
)
self.stdout.write(self.style.SUCCESS(' ✓ Созданы прогрессирующие скидки'))
else:
self.stdout.write(self.style.WARNING(f'⚠ План уже существует: {plan_per_student_premium.name}'))
self.stdout.write(self.style.SUCCESS('\nВсе тарифные планы созданы!'))
self.stdout.write('\nСозданные тарифы:')
self.stdout.write(' 1. Стартовый - 500 руб/мес (минимальные функции)')
self.stdout.write(' 2. Базовый - 1500 руб/мес (основные функции)')
self.stdout.write(' 3. Профессиональный - 3500 руб/мес (большинство функций)')
self.stdout.write(' 4. Бизнес - 7000 руб/мес (все функции)')
self.stdout.write(' 5. За ученика (Базовый) - 100 руб/ученик (основные функции)')
self.stdout.write(' 6. За ученика (Премиум) - 150 руб/ученик (все функции)')