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,103 @@
|
||||
# Generated by Django 4.2.16 on 2026-11-06 13:26
|
||||
|
||||
import apps.orders.models
|
||||
from decimal import Decimal
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('catalog', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Order',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('number', models.CharField(default=apps.orders.models.generate_order_number, editable=False, max_length=32, unique=True)),
|
||||
('external_id', models.CharField(blank=True, db_index=True, max_length=64)),
|
||||
('status', models.CharField(choices=[('new', 'Новый'), ('processing', 'В обработке'), ('delivering', 'Доставляется'), ('completed', 'Выполнен'), ('cancelled', 'Отменён')], db_index=True, default='new', max_length=20)),
|
||||
('payment_status', models.CharField(choices=[('pending', 'Ожидает оплаты'), ('partially_paid', 'Частично оплачен'), ('paid', 'Оплачен'), ('refunded', 'Возвращён')], default='pending', max_length=20)),
|
||||
('customer_name', models.CharField(max_length=255)),
|
||||
('phone', models.CharField(max_length=20)),
|
||||
('email', models.EmailField(blank=True, max_length=254)),
|
||||
('delivery_method', models.CharField(blank=True, max_length=64)),
|
||||
('delivery_address', models.TextField(blank=True)),
|
||||
('delivery_cost', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=12)),
|
||||
('comment', models.TextField(blank=True)),
|
||||
('subtotal', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=12)),
|
||||
('discount_total', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=12)),
|
||||
('bonus_applied', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=12)),
|
||||
('certificate_applied', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=12)),
|
||||
('total', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=12)),
|
||||
('promo_code', models.CharField(blank=True, max_length=64)),
|
||||
('certificate_code', models.CharField(blank=True, max_length=64)),
|
||||
('idempotency_key', models.CharField(blank=True, max_length=128, null=True, unique=True)),
|
||||
('synced_at', models.DateTimeField(blank=True, null=True)),
|
||||
('sync_error', models.TextField(blank=True)),
|
||||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='orders', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'заказ',
|
||||
'verbose_name_plural': 'заказы',
|
||||
'db_table': 'orders_order',
|
||||
'ordering': ['-created_at'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='OrderStatusHistory',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('status', models.CharField(choices=[('new', 'Новый'), ('processing', 'В обработке'), ('delivering', 'Доставляется'), ('completed', 'Выполнен'), ('cancelled', 'Отменён')], max_length=20)),
|
||||
('comment', models.TextField(blank=True)),
|
||||
('source', models.CharField(choices=[('site', 'Сайт'), ('1c', '1С')], default='site', max_length=10)),
|
||||
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='status_history', to='orders.order')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'история статуса',
|
||||
'verbose_name_plural': 'история статусов',
|
||||
'db_table': 'orders_status_history',
|
||||
'ordering': ['created_at'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='OrderItem',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('product_external_id', models.CharField(blank=True, max_length=64)),
|
||||
('name', models.CharField(max_length=500)),
|
||||
('sku', models.CharField(max_length=64)),
|
||||
('price', models.DecimalField(decimal_places=2, max_digits=12)),
|
||||
('quantity', models.PositiveIntegerField()),
|
||||
('total', models.DecimalField(decimal_places=2, max_digits=12)),
|
||||
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='orders.order')),
|
||||
('product', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='order_items', to='catalog.product')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'позиция заказа',
|
||||
'verbose_name_plural': 'позиции заказа',
|
||||
'db_table': 'orders_order_item',
|
||||
},
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='order',
|
||||
index=models.Index(fields=['status', 'created_at'], name='orders_orde_status_25e057_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='order',
|
||||
index=models.Index(fields=['user', 'created_at'], name='orders_orde_user_id_37fed6_idx'),
|
||||
),
|
||||
]
|
||||
Reference in new issue
Block a user