# Generated by Django 4.2.27 on 2026-04-19 12:06

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


class Migration(migrations.Migration):

    dependencies = [
        ("peizhi", "0013_alter_tixianquotadefault_leixing"),
    ]

    operations = [
        migrations.CreateModel(
            name="PopupConfig",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "popup_id",
                    models.CharField(max_length=50, verbose_name="弹窗唯一ID"),
                ),
                (
                    "title",
                    models.CharField(
                        blank=True, max_length=200, verbose_name="标题（后台用）"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, verbose_name="描述（后台用）"),
                ),
                (
                    "strategy_type",
                    models.CharField(
                        choices=[
                            ("once", "仅一次"),
                            ("daily", "每日"),
                            ("weekly", "每周"),
                            ("monthly", "每月"),
                            ("yearly", "每年"),
                            ("always", "始终"),
                            ("count", "周期内次数限制"),
                        ],
                        default="once",
                        max_length=20,
                    ),
                ),
                (
                    "max_count",
                    models.PositiveIntegerField(
                        default=1, verbose_name="周期内最大展示次数"
                    ),
                ),
                (
                    "reset_interval",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("day", "天"),
                            ("week", "周"),
                            ("month", "月"),
                            ("year", "年"),
                        ],
                        max_length=20,
                        verbose_name="重置周期（count类型时使用）",
                    ),
                ),
                (
                    "duration",
                    models.PositiveIntegerField(
                        default=0, verbose_name="强制阅读秒数（0=无强制）"
                    ),
                ),
                (
                    "force_even_muted",
                    models.BooleanField(
                        default=False, verbose_name="强制弹出（忽略用户今日屏蔽）"
                    ),
                ),
                (
                    "sort_order",
                    models.PositiveIntegerField(default=0, verbose_name="展示顺序"),
                ),
                (
                    "is_active",
                    models.BooleanField(default=True, verbose_name="是否启用"),
                ),
                (
                    "start_time",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="生效开始时间"
                    ),
                ),
                (
                    "end_time",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="生效结束时间"
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "弹窗配置",
                "verbose_name_plural": "弹窗配置",
                "db_table": "popup_config",
                "ordering": ["sort_order", "id"],
            },
        ),
        migrations.CreateModel(
            name="PopupPage",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "page_key",
                    models.CharField(
                        db_index=True,
                        max_length=50,
                        unique=True,
                        verbose_name="页面标识",
                    ),
                ),
                ("name", models.CharField(max_length=100, verbose_name="页面名称")),
                ("description", models.TextField(blank=True, verbose_name="描述")),
                (
                    "is_active",
                    models.BooleanField(default=True, verbose_name="是否启用"),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "弹窗页面",
                "verbose_name_plural": "弹窗页面",
                "db_table": "popup_page",
            },
        ),
        migrations.CreateModel(
            name="PopupImage",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "image_url",
                    models.CharField(max_length=500, verbose_name="图片相对路径"),
                ),
                ("text", models.TextField(blank=True, verbose_name="图片上方文字")),
                (
                    "sort_order",
                    models.PositiveIntegerField(default=0, verbose_name="展示顺序"),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "popup_config",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="images",
                        to="peizhi.popupconfig",
                    ),
                ),
            ],
            options={
                "verbose_name": "弹窗图片",
                "verbose_name_plural": "弹窗图片",
                "db_table": "popup_image",
                "ordering": ["sort_order", "id"],
            },
        ),
        migrations.AddField(
            model_name="popupconfig",
            name="page",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="popups",
                to="peizhi.popuppage",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="popupconfig",
            unique_together={("page", "popup_id")},
        ),
    ]
