Add Django backend, 1C integration, deploy config and API docs
Backend (Django 4.2 + DRF): - accounts: phone OTP login, JWT, profile, addresses - catalog: categories, products, images, filters, search, hits/new/related - orders: creation with Idempotency-Key, stock reservation, status history, cancel - loyalty: bonus accounts, promo codes, gift certificates - payments: payment records and YooKassa webhook handling - content: static pages, banners, site settings - integration: 1C exchange (catalog sync, order push via outbox, statuses, bonuses) - common: error envelope, pagination, request-id, integration auth, admin dashboard Infrastructure: Dockerfile, docker-compose (Postgres, Redis, Celery worker/beat, Nginx), requirements split by environment, OpenAPI contracts for site and 1C, architecture doc. Tests: 22 pytest cases covering catalog, orders, idempotency, OTP, integration.
This commit is contained in:
1 parent
5f8d37357d
commit
756f40353b
130 files changed
+10066
No files matched your search
@@ -0,0 +1,51 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from django.db import models
|
||||
|
||||
from apps.common.models import TimeStampedModel
|
||||
|
||||
|
||||
class Payment(TimeStampedModel):
|
||||
class Method(models.TextChoices):
|
||||
CARD = "card", "Банковская карта"
|
||||
SBP = "sbp", "СБП"
|
||||
MIR_PAY = "mir_pay", "МИР Pay"
|
||||
CASH = "cash", "Наличные при получении"
|
||||
INSTALLMENT = "installment", "Рассрочка"
|
||||
SPLIT = "split", "Оплата частями"
|
||||
|
||||
class Status(models.TextChoices):
|
||||
PENDING = "pending", "Ожидает"
|
||||
SUCCEEDED = "succeeded", "Успешно"
|
||||
FAILED = "failed", "Ошибка"
|
||||
REFUNDED = "refunded", "Возвращён"
|
||||
CANCELLED = "cancelled", "Отменён"
|
||||
|
||||
order = models.ForeignKey(
|
||||
"orders.Order", on_delete=models.CASCADE, related_name="payments"
|
||||
)
|
||||
method = models.CharField(max_length=20, choices=Method.choices)
|
||||
status = models.CharField(
|
||||
max_length=20, choices=Status.choices, default=Status.PENDING
|
||||
)
|
||||
amount = models.DecimalField(
|
||||
max_digits=12, decimal_places=2, default=Decimal("0")
|
||||
)
|
||||
provider = models.CharField(max_length=32, default="yookassa")
|
||||
provider_payment_id = models.CharField(
|
||||
max_length=128, blank=True, db_index=True
|
||||
)
|
||||
idempotency_key = models.CharField(
|
||||
max_length=128, unique=True, null=True, blank=True
|
||||
)
|
||||
payload = models.JSONField(default=dict, blank=True)
|
||||
paid_at = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "payments_payment"
|
||||
verbose_name = "платёж"
|
||||
verbose_name_plural = "платежи"
|
||||
ordering = ["-created_at"]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.order.number}: {self.method} {self.amount}"
|
||||
Reference in new issue
Block a user