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


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("shipment", "0012_replace_cancelled_at_with_status_modified_at_and_add_approved_by"),
    ]

    operations = [
        migrations.CreateModel(
            name="ShipmentDelivery",
            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="更新时间")),
                ("status", models.IntegerField(choices=[(1, "待送货"), (2, "送货中"), (3, "已送达")], db_index=True, default=1, verbose_name="状态")),
                ("driver_name", models.CharField(db_index=True, max_length=100, verbose_name="司机名")),
                ("vehicle_trip", models.CharField(db_index=True, max_length=100, verbose_name="车次")),
                ("started_at", models.DateTimeField(blank=True, null=True, verbose_name="开始送货时间")),
                ("delivered_at", models.DateTimeField(blank=True, null=True, verbose_name="送达时间")),
                ("created_by", models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="created_shipment_deliveries", to=settings.AUTH_USER_MODEL, verbose_name="创建人")),
                ("merchant", models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name="shipment_deliveries", to="basic_info.merchant", verbose_name="所属商户")),
            ],
            options={
                "verbose_name": "送货单",
                "verbose_name_plural": "送货单",
                "db_table": "shipment_delivery",
                "ordering": ["-created_at", "-id"],
            },
        ),
        migrations.AddField(
            model_name="shipment",
            name="address",
            field=models.CharField(blank=True, default="", max_length=255, verbose_name="地址"),
        ),
        migrations.AddField(
            model_name="shipment",
            name="contact_name",
            field=models.CharField(blank=True, default="", max_length=100, verbose_name="联系人"),
        ),
        migrations.AddField(
            model_name="shipment",
            name="contact_phone",
            field=models.CharField(blank=True, default="", max_length=50, verbose_name="联系电话"),
        ),
        migrations.AddField(
            model_name="shipment",
            name="delivery",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="shipments",
                to="shipment.shipmentdelivery",
                verbose_name="送货单",
            ),
        ),
        migrations.AddField(
            model_name="shipmentdelivery",
            name="internal_remark",
            field=models.CharField(blank=True, default="", max_length=200, verbose_name="内部备注"),
        ),
        migrations.AddField(
            model_name="shipmentdelivery",
            name="remark",
            field=models.CharField(blank=True, default="", max_length=200, verbose_name="备注"),
        ),
    ]
