# Generated by Django 5.2.8 on 2026-01-22 01:36

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('basic_info', '0024_frontend_page_and_visible_pages'),
        ('shipment', '0009_remove_salesitem_merchant_remove_shipment_area_and_more'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AddField(
            model_name='salesitem',
            name='merchant',
            field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.PROTECT, related_name='sales_items', to='basic_info.merchant', verbose_name='所属商户'),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='shipment',
            name='area',
            field=models.CharField(blank=True, default='', help_text='出货地区（可空字符串）', max_length=30, verbose_name='地区'),
        ),
        migrations.AddField(
            model_name='shipment',
            name='cancelled_at',
            field=models.DateTimeField(blank=True, null=True, verbose_name='取消时间'),
        ),
        migrations.AddField(
            model_name='shipment',
            name='cancelled_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='cancelled_shipments', to=settings.AUTH_USER_MODEL, verbose_name='取消人'),
        ),
        migrations.AddField(
            model_name='shipment',
            name='external_id',
            field=models.CharField(blank=True, help_text='用于兼容外部遗留系统的订单号（可空）', max_length=120, null=True, verbose_name='外部订单号'),
        ),
        migrations.AddField(
            model_name='shipment',
            name='merchant',
            field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.PROTECT, related_name='shipments', to='basic_info.merchant', verbose_name='所属商户'),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='shipment',
            name='status',
            field=models.IntegerField(choices=[(1, '待送货'), (2, '已交付'), (3, '已取消')], default=1, verbose_name='状态'),
        ),
        migrations.CreateModel(
            name='ExternalFinishedProduct',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('style_name', models.CharField(max_length=200, verbose_name='款式名称')),
                ('num_of_rolls', models.PositiveIntegerField(verbose_name='卷数')),
                ('remark', models.CharField(blank=True, max_length=200, null=True, verbose_name='备注')),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_external_finished_products', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
                ('shipment', models.ForeignKey(blank=True, help_text='关联的出货单（可空，兼容历史数据/逐步迁移）', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='external_finished_products', to='shipment.shipment', verbose_name='出货单')),
            ],
            options={
                'verbose_name': '外部成品表',
                'verbose_name_plural': '外部成品表',
                'db_table': 'external_finished_product',
                'ordering': ['-created_at'],
            },
        ),
    ]
