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

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


class Migration(migrations.Migration):

    dependencies = [
        ('basic_info', '0024_frontend_page_and_visible_pages'),
        ('printing', '0032_delete_plateordertiiauploadfailure_and_more'),
    ]

    operations = [
        migrations.AlterModelOptions(
            name='plateorder',
            options={'ordering': ['-created_at'], 'permissions': [('can_invalidate_plateorder', '可以作废开版订单'), ('can_activate_plateorder', '可以恢复开版订单'), ('view_all_plateorders', '查看所有开版订单（突破客户可见性限制）')], 'verbose_name': '开版订单', 'verbose_name_plural': '开版订单'},
        ),
        migrations.AlterModelOptions(
            name='printingorder',
            options={'permissions': [('can_invalidate_printingorder', '可以作废印染订单'), ('can_activate_printingorder', '可以恢复印染订单'), ('view_all_printingorders', '查看所有印染订单（突破客户可见性限制）')], 'verbose_name': '印染订单', 'verbose_name_plural': '印染订单'},
        ),
        migrations.AddField(
            model_name='plateorder',
            name='merchant',
            field=models.ForeignKey(blank=True, help_text='所属商户，可空以兼容历史数据', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='plate_orders', to='basic_info.merchant', verbose_name='商户'),
        ),
        migrations.AddField(
            model_name='printingjob',
            name='merchant',
            field=models.ForeignKey(blank=True, help_text='所属商户，可空以兼容历史数据', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='printing_jobs', to='basic_info.merchant', verbose_name='商户'),
        ),
        migrations.AddField(
            model_name='printingorder',
            name='merchant',
            field=models.ForeignKey(blank=True, help_text='所属商户，可空以兼容历史数据', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='printing_orders', to='basic_info.merchant', verbose_name='商户'),
        ),
        migrations.CreateModel(
            name='PlateOrderTiiaUploadFailure',
            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='更新时间')),
                ('run_date', models.DateField(help_text='以任务处理的日期为准（通常为“昨天”）', verbose_name='任务日期')),
                ('plate_order_id', models.PositiveBigIntegerField(db_index=True, help_text='PlateOrder.id（不使用外键，避免历史数据/删除带来的约束问题）', verbose_name='开版订单ID')),
                ('error', models.TextField(blank=True, default='', verbose_name='错误摘要')),
                ('details', models.JSONField(blank=True, default=list, help_text='通常存储 upload_plate_order_images_to_tencent_tiia 返回的失败条目列表', verbose_name='错误详情')),
                ('attempts', models.PositiveIntegerField(default=0, verbose_name='尝试次数')),
                ('last_attempt_at', models.DateTimeField(blank=True, null=True, verbose_name='最后尝试时间')),
            ],
            options={
                'verbose_name': '开版订单图片上传失败记录',
                'verbose_name_plural': '开版订单图片上传失败记录',
                'ordering': ['-created_at'],
                'constraints': [models.UniqueConstraint(fields=('run_date', 'plate_order_id'), name='uniq_plateorder_tiia_fail_run_date_po')],
            },
        ),
    ]
