# Generated manually for merchant_ops

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


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='MerchantStaffPermission',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('perm_code', models.CharField(max_length=64, unique=True, verbose_name='权限码')),
                ('perm_name', models.CharField(max_length=64, verbose_name='权限名称')),
                ('sort_order', models.IntegerField(default=0, verbose_name='排序')),
                ('status', models.IntegerField(default=1, verbose_name='1启用0停用')),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
            ],
            options={'db_table': 'merchant_staff_permission', 'verbose_name': '商家客服权限字典'},
        ),
        migrations.CreateModel(
            name='MerchantStaffRole',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('club_id', models.CharField(default='xq', max_length=16, verbose_name='Club')),
                ('merchant_id', models.CharField(blank=True, db_index=True, max_length=7, null=True, verbose_name='商家ID')),
                ('role_code', models.CharField(max_length=32, verbose_name='角色码')),
                ('role_name', models.CharField(max_length=64, verbose_name='角色名')),
                ('is_system', models.BooleanField(default=False, verbose_name='系统预置')),
                ('sort_order', models.IntegerField(default=0)),
                ('status', models.IntegerField(default=1, verbose_name='1启用0停用')),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
            ],
            options={'db_table': 'merchant_staff_role', 'verbose_name': '商家客服角色', 'unique_together': {('merchant_id', 'role_code')}},
        ),
        migrations.CreateModel(
            name='MerchantStaffInvite',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('club_id', models.CharField(default='xq', max_length=16)),
                ('merchant_id', models.CharField(db_index=True, max_length=7, verbose_name='商家ID')),
                ('invite_code', models.CharField(max_length=32, unique=True, verbose_name='邀请码')),
                ('status', models.IntegerField(default=0, verbose_name='0未用1已用2作废3过期')),
                ('created_by', models.CharField(max_length=7, verbose_name='创建人')),
                ('used_by', models.CharField(blank=True, max_length=7, null=True)),
                ('used_at', models.DateTimeField(blank=True, null=True)),
                ('expire_at', models.DateTimeField(blank=True, null=True)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
                ('role', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='merchant_ops.merchantstaffrole', verbose_name='预绑角色')),
            ],
            options={'db_table': 'merchant_staff_invite'},
        ),
        migrations.CreateModel(
            name='MerchantStaffMember',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('club_id', models.CharField(default='xq', max_length=16)),
                ('merchant_id', models.CharField(db_index=True, max_length=7)),
                ('staff_user_id', models.CharField(db_index=True, max_length=7)),
                ('status', models.IntegerField(default=1, verbose_name='1正常0停用2已移除')),
                ('display_name', models.CharField(blank=True, default='', max_length=64)),
                ('joined_at', models.DateTimeField(auto_now_add=True)),
                ('revoked_at', models.DateTimeField(blank=True, null=True)),
                ('today_dispatch_count', models.IntegerField(default=0)),
                ('today_dispatch_amount', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
                ('invited_by_code', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='merchant_ops.merchantstaffinvite')),
                ('role', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='merchant_ops.merchantstaffrole')),
            ],
            options={'db_table': 'merchant_staff_member', 'unique_together': {('merchant_id', 'staff_user_id')}},
        ),
        migrations.CreateModel(
            name='MerchantStaffRolePermission',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('perm_code', models.CharField(db_index=True, max_length=64)),
                ('role', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='role_permissions', to='merchant_ops.merchantstaffrole')),
            ],
            options={'db_table': 'merchant_staff_role_permission', 'unique_together': {('role', 'perm_code')}},
        ),
        migrations.CreateModel(
            name='MerchantStaffMemberPermission',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('perm_code', models.CharField(max_length=64)),
                ('granted', models.BooleanField(default=True, verbose_name='True授予False禁止')),
                ('member', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='member_permissions', to='merchant_ops.merchantstaffmember')),
            ],
            options={'db_table': 'merchant_staff_member_permission', 'unique_together': {('member', 'perm_code')}},
        ),
        migrations.CreateModel(
            name='MerchantStaffWallet',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('merchant_id', models.CharField(db_index=True, max_length=7)),
                ('staff_user_id', models.CharField(db_index=True, max_length=7)),
                ('quota_total', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('quota_used', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('quota_frozen', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('member', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='wallets', to='merchant_ops.merchantstaffmember')),
            ],
            options={'db_table': 'merchant_staff_wallet', 'unique_together': {('merchant_id', 'staff_user_id')}},
        ),
        migrations.CreateModel(
            name='MerchantStaffWalletLedger',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('merchant_id', models.CharField(db_index=True, max_length=7)),
                ('staff_user_id', models.CharField(db_index=True, max_length=7)),
                ('change_type', models.CharField(max_length=32)),
                ('amount', models.DecimalField(decimal_places=2, max_digits=12)),
                ('balance_after', models.DecimalField(decimal_places=2, max_digits=12)),
                ('related_order_id', models.CharField(blank=True, max_length=32, null=True)),
                ('operator_id', models.CharField(max_length=7)),
                ('remark', models.CharField(blank=True, default='', max_length=255)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('wallet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ledgers', to='merchant_ops.merchantstaffwallet')),
            ],
            options={'db_table': 'merchant_staff_wallet_ledger'},
        ),
        migrations.CreateModel(
            name='MerchantStaffDailyStats',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('club_id', models.CharField(default='xq', max_length=16)),
                ('merchant_id', models.CharField(db_index=True, max_length=7)),
                ('staff_user_id', models.CharField(db_index=True, max_length=7)),
                ('member_id', models.BigIntegerField(db_index=True)),
                ('stat_date', models.DateField(db_index=True)),
                ('year', models.PositiveSmallIntegerField()),
                ('month', models.PositiveSmallIntegerField()),
                ('day', models.PositiveSmallIntegerField()),
                ('dispatch_count', models.IntegerField(default=0)),
                ('dispatch_amount', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('settle_count', models.IntegerField(default=0)),
                ('settle_amount', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('refund_count', models.IntegerField(default=0)),
                ('refund_amount', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('cancel_count', models.IntegerField(default=0)),
                ('penalty_count', models.IntegerField(default=0)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
            ],
            options={'db_table': 'merchant_staff_ri_tongji', 'unique_together': {('merchant_id', 'staff_user_id', 'stat_date')}},
        ),
        migrations.CreateModel(
            name='MerchantOrderDispatch',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('order_id', models.CharField(db_index=True, max_length=32, unique=True)),
                ('merchant_id', models.CharField(db_index=True, max_length=7)),
                ('dispatch_actor_type', models.CharField(max_length=16, verbose_name='MERCHANT/STAFF')),
                ('dispatch_actor_id', models.CharField(max_length=7)),
                ('staff_member_id', models.BigIntegerField(blank=True, db_index=True, null=True)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
            ],
            options={'db_table': 'merchant_order_dispatch'},
        ),
        migrations.CreateModel(
            name='MerchantStaffAuditLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('merchant_id', models.CharField(db_index=True, max_length=7)),
                ('operator_user_id', models.CharField(db_index=True, max_length=7)),
                ('operator_type', models.CharField(max_length=16, verbose_name='MERCHANT_OWNER/STAFF')),
                ('staff_member_id', models.BigIntegerField(blank=True, null=True)),
                ('action', models.CharField(db_index=True, max_length=64)),
                ('resource_type', models.CharField(blank=True, default='', max_length=32)),
                ('resource_id', models.CharField(blank=True, default='', max_length=64)),
                ('value_before', models.JSONField(blank=True, null=True)),
                ('value_after', models.JSONField(blank=True, null=True)),
                ('amount', models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True)),
                ('request_ip', models.CharField(blank=True, default='', max_length=64)),
                ('remark', models.CharField(blank=True, default='', max_length=500)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
            ],
            options={'db_table': 'merchant_staff_audit_log'},
        ),
        migrations.CreateModel(
            name='MerchantDispatchTemplate',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('merchant_id', models.CharField(db_index=True, max_length=7)),
                ('template_name', models.CharField(max_length=128)),
                ('template_type', models.CharField(default='EXPRESS', max_length=16)),
                ('payload_json', models.JSONField(default=dict)),
                ('created_by', models.CharField(max_length=7)),
                ('created_by_type', models.CharField(default='MERCHANT', max_length=16)),
                ('status', models.IntegerField(default=1)),
                ('use_count', models.IntegerField(default=0)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
            ],
            options={'db_table': 'merchant_dispatch_template'},
        ),
    ]
