init commit

This commit is contained in:
2025-06-13 21:10:20 +09:00
commit d52c611afb
269 changed files with 37162 additions and 0 deletions

83
lottery/webapp/models.py Normal file
View File

@@ -0,0 +1,83 @@
from django.db import models
from django.core.validators import MinValueValidator
from decimal import Decimal
class Client(models.Model):
name = models.CharField("Имя", max_length=255)
club_card_number = models.CharField("Номер клубной карты", max_length=100, unique=True)
telegram_id = models.CharField("Telegram ID", max_length=50, blank=True, null=True)
bot_admin = models.BooleanField(default=False, help_text="Является ли пользователь администратором бота")
chat_disabled = models.BooleanField(
default=False,
verbose_name="Блокировка отправки сообщений",
help_text="Если установлено, пользователь не может отправлять сообщения в чат."
)
def __str__(self):
return f"{self.name} ({self.club_card_number})"
class Meta:
verbose_name = "Клиент"
verbose_name_plural = "Клиенты"
class Invoice(models.Model):
# Поля, полученные из API
api_id = models.CharField("API Invoice ID", max_length=255, unique=True)
invoice_type = models.CharField("Type", max_length=50, default="Invoice")
created_at = models.DateTimeField("Created at")
closed_at = models.DateTimeField("Closed at", null=True, blank=True)
ext_id = models.CharField("External ID", max_length=255, blank=True, null=True)
ext_type = models.CharField("External Type", max_length=255, blank=True, null=True)
# Данные клиента, полученные из объекта "client"
client_api_id = models.CharField("Client API ID", max_length=255, blank=True, null=True)
client_type = models.CharField("Client Type", max_length=50, blank=True, null=True)
client_name = models.CharField("Client Name", max_length=255, blank=True, null=True)
client_club_card_number = models.CharField("Club Card Number", max_length=100, blank=True, null=True)
# Финансовые поля
sum = models.DecimalField("Sum", max_digits=10, decimal_places=2, default=Decimal("0.00"),
validators=[MinValueValidator(Decimal("0.00"))])
company_number = models.PositiveIntegerField("Company Number", default=0)
bonus = models.DecimalField("Bonus", max_digits=10, decimal_places=2, null=True, blank=True,
validators=[MinValueValidator(Decimal("0.00"))])
start_bonus = models.DecimalField("Start Bonus", max_digits=10, decimal_places=2, null=True, blank=True,
validators=[MinValueValidator(Decimal("0.00"))])
deposit_sum = models.DecimalField("Deposit Sum", max_digits=10, decimal_places=2, default=Decimal("0.00"),
validators=[MinValueValidator(Decimal("0.00"))])
notes = models.TextField("Notes", blank=True, null=True)
used = models.BooleanField(default=False, verbose_name="Использован в розыгрыше")
def __str__(self):
return f"{self.ext_id} / {self.client_name or 'Unknown Client'} ({self.client_club_card_number})"
class Meta:
verbose_name = "Счет"
verbose_name_plural = "Счета"
ordering = ['-created_at']
class APISettings(models.Model):
api_url = models.URLField("API URL")
api_key = models.CharField("API KEY", max_length=255)
def __str__(self):
return f"Настройки API: {self.api_url}"
class BindingRequest(models.Model):
STATUS_CHOICES = (
('pending', 'Ожидает проверки'),
('approved', 'Подтверждён'),
('rejected', 'Отклонён'),
)
telegram_chat_id = models.CharField(max_length=50, help_text="Идентификатор чата Telegram пользователя")
client_card = models.CharField(max_length=100, help_text="Номер клиентской карты")
client = models.ForeignKey(Client, on_delete=models.SET_NULL, null=True, blank=True)
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
created_at = models.DateTimeField(auto_now_add=True)
processed_at = models.DateTimeField(null=True, blank=True)
def __str__(self):
return f"КК: {self.client_card} | Статус: {self.get_status_display()}"
class Meta:
verbose_name = "Запрос на сопоставление"
verbose_name_plural = "Запросы на сопоставления"