# Generated by Django 6.0.1 on 2026-02-10 15:48

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


class Migration(migrations.Migration):

    dependencies = [
        ('shop', '0014_esp32config_stock_order_courier_name_and_more'),
    ]

    operations = [
        migrations.AddField(
            model_name='esp32config',
            name='commission_rate',
            field=models.DecimalField(decimal_places=4, default=0.0, help_text='例如 0.10 表示 10%，优先级高于销售员默认比例', max_digits=5, verbose_name='产品分润比例'),
        ),
        migrations.AddField(
            model_name='salesperson',
            name='commission_rate',
            field=models.DecimalField(decimal_places=4, default=0.1, help_text='例如 0.10 表示 10%', max_digits=5, verbose_name='默认分润比例'),
        ),
        migrations.AddField(
            model_name='salesperson',
            name='parent',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='children', to='shop.salesperson', verbose_name='上级分销员'),
        ),
        migrations.AddField(
            model_name='salesperson',
            name='second_level_rate',
            field=models.DecimalField(decimal_places=4, default=0.02, help_text='作为上级时可获得的分润比例，例如 0.02 表示 2%', max_digits=5, verbose_name='二级分销比例'),
        ),
        migrations.CreateModel(
            name='CommissionLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('amount', models.DecimalField(decimal_places=2, max_digits=10, verbose_name='佣金金额')),
                ('level', models.IntegerField(default=1, help_text='1: 直接销售, 2: 二级分销', verbose_name='分销层级')),
                ('status', models.CharField(choices=[('pending', '待结算'), ('settled', '已结算'), ('cancelled', '已取消')], default='pending', max_length=20, verbose_name='状态')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='commissions', to='shop.order', verbose_name='关联订单')),
                ('salesperson', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='commissions', to='shop.salesperson', verbose_name='获佣销售员')),
            ],
            options={
                'verbose_name': '佣金记录',
                'verbose_name_plural': '佣金结算',
            },
        ),
    ]
