# 组队招募表 TeamRecruit / TeamMember / TeamSettleLedger / TeamActionLog
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('orders', '0016_order_auto_settle_eligible'),
    ]

    operations = [
        migrations.CreateModel(
            name='TeamRecruit',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False)),
                ('club_id', models.CharField(db_index=True, max_length=16, verbose_name='俱乐部')),
                ('order_id', models.CharField(db_index=True, max_length=32, unique=True, verbose_name='订单ID')),
                ('leader_uid', models.CharField(db_index=True, max_length=32, verbose_name='队长UID')),
                ('status', models.PositiveSmallIntegerField(db_index=True, default=1, verbose_name='状态')),
                ('need_count', models.PositiveSmallIntegerField(default=1, verbose_name='目标队友数1-3')),
                ('joined_count', models.PositiveSmallIntegerField(default=0, verbose_name='已入队队友数')),
                ('share_mode', models.CharField(default='fixed', max_length=16, verbose_name='fixed|average')),
                ('per_person_amount', models.DecimalField(decimal_places=2, default=0, max_digits=10, verbose_name='固定值人均')),
                ('display_share_amount', models.DecimalField(decimal_places=2, default=0, max_digits=10, verbose_name='大厅展示分红')),
                ('commission_snap', models.DecimalField(decimal_places=2, default=0, max_digits=10, verbose_name='开启时分成快照')),
                ('order_amount_snap', models.DecimalField(decimal_places=2, default=0, max_digits=10, verbose_name='订单金额快照')),
                ('remark', models.CharField(blank=True, default='', max_length=200, verbose_name='组队备注')),
                ('leader_game_id', models.CharField(blank=True, default='', max_length=64, verbose_name='队长游戏ID')),
                ('min_deal_rate', models.DecimalField(blank=True, decimal_places=6, max_digits=8, null=True, verbose_name='最低成交率0-1')),
                ('max_fine_rate', models.DecimalField(blank=True, decimal_places=6, max_digits=8, null=True, verbose_name='最高罚款率0-1')),
                ('opened_at', models.DateTimeField(blank=True, null=True)),
                ('locked_at', models.DateTimeField(blank=True, null=True)),
                ('closed_at', models.DateTimeField(blank=True, null=True)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'team_recruit',
            },
        ),
        migrations.CreateModel(
            name='TeamMember',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False)),
                ('club_id', models.CharField(db_index=True, max_length=16)),
                ('recruit_id', models.BigIntegerField(db_index=True)),
                ('order_id', models.CharField(db_index=True, max_length=32)),
                ('user_uid', models.CharField(db_index=True, max_length=32)),
                ('role', models.CharField(default='member', max_length=16)),
                ('game_id', models.CharField(blank=True, default='', max_length=64)),
                ('share_amount', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('join_status', models.PositiveSmallIntegerField(db_index=True, default=1)),
                ('joined_at', models.DateTimeField(blank=True, null=True)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'team_member',
            },
        ),
        migrations.CreateModel(
            name='TeamSettleLedger',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False)),
                ('club_id', models.CharField(db_index=True, max_length=16)),
                ('order_id', models.CharField(db_index=True, max_length=32)),
                ('user_uid', models.CharField(db_index=True, max_length=32)),
                ('amount', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('biz_id', models.CharField(max_length=64, unique=True)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'team_settle_ledger',
            },
        ),
        migrations.CreateModel(
            name='TeamActionLog',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False)),
                ('club_id', models.CharField(blank=True, db_index=True, default='', max_length=16)),
                ('order_id', models.CharField(blank=True, db_index=True, default='', max_length=32)),
                ('recruit_id', models.BigIntegerField(blank=True, db_index=True, null=True)),
                ('actor_uid', models.CharField(blank=True, default='', max_length=32)),
                ('action', models.CharField(db_index=True, max_length=32)),
                ('detail', models.TextField(blank=True, default='')),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'team_action_log',
            },
        ),
        migrations.AddIndex(
            model_name='teamrecruit',
            index=models.Index(fields=['club_id', 'status', '-opened_at'], name='team_recrui_club_id_0b8c0a_idx'),
        ),
        migrations.AddIndex(
            model_name='teamrecruit',
            index=models.Index(fields=['leader_uid', 'status'], name='team_recrui_leader__a1b2c3_idx'),
        ),
        migrations.AddIndex(
            model_name='teammember',
            index=models.Index(fields=['order_id', 'join_status'], name='team_member_order_i_d4e5f6_idx'),
        ),
        migrations.AddIndex(
            model_name='teammember',
            index=models.Index(fields=['user_uid', 'join_status'], name='team_member_user_ui_g7h8i9_idx'),
        ),
        migrations.AddConstraint(
            model_name='teammember',
            constraint=models.UniqueConstraint(fields=('recruit_id', 'user_uid'), name='uniq_team_member_recruit_uid'),
        ),
    ]
