from django.db import models


# Create your models here.

class AgentCustomerInfo(models.Model):
    id = models.AutoField(primary_key=True)
    user_id = models.CharField(db_index=True, max_length=32, verbose_name='用户id')
    company_name = models.CharField(max_length=32, verbose_name='公司名称')
    status = models.SmallIntegerField(default=1, verbose_name='0:无效,1:有效')
    created_time = models.IntegerField(default=0, verbose_name='创建时间')
    created_by = models.CharField(blank=True, max_length=32, verbose_name='创建人')
    updated_time = models.IntegerField(default=0, verbose_name='修改时间')
    updated_by = models.CharField(blank=True, max_length=32, verbose_name='修改人')

    class Meta:
        db_table = 'a_customer_info'
        verbose_name = '代理客户信息'
        verbose_name_plural = verbose_name
        app_label = 'AgentModel'


class AgentCustomerCard(models.Model):
    id = models.AutoField(primary_key=True)
    ac_id = models.IntegerField(null=True, default=None, verbose_name='代理客户ID')
    name = models.CharField(max_length=32, verbose_name='姓名')
    card_no = models.CharField(max_length=32, verbose_name='卡号')
    status = models.SmallIntegerField(default=1, verbose_name='0:无效,1:有效')
    card_address = models.CharField(max_length=128, verbose_name='开户行')
    created_time = models.IntegerField(default=0, verbose_name='创建时间')
    created_by = models.CharField(blank=True, max_length=32, verbose_name='创建人')
    updated_time = models.IntegerField(default=0, verbose_name='修改时间')
    updated_by = models.CharField(blank=True, max_length=32, verbose_name='修改人')

    class Meta:
        db_table = 'a_customer_card'
        verbose_name = '代理客户卡信息'
        verbose_name_plural = verbose_name
        app_label = 'AgentModel'


class AgentDevice(models.Model):
    id = models.AutoField(primary_key=True)
    ac_id = models.IntegerField(null=True, default=None, verbose_name='代理客户ID')
    serial_number = models.CharField(db_index=True, max_length=32, verbose_name='设备9位序列号')
    type = models.IntegerField(default=0, verbose_name='设备类型')
    status = models.SmallIntegerField(default=1, verbose_name='0:未激活,1:激活')
    at_time = models.IntegerField(default=0, verbose_name='激活时间')
    created_time = models.IntegerField(default=0, verbose_name='创建时间')
    created_by = models.CharField(blank=True, max_length=32, verbose_name='创建人')
    updated_time = models.IntegerField(default=0, verbose_name='修改时间')
    updated_by = models.CharField(blank=True, max_length=32, verbose_name='修改人')

    class Meta:
        db_table = 'a_device'
        verbose_name = '代理设备'
        verbose_name_plural = verbose_name
        app_label = 'AgentModel'


class AgentCloudServicePackage(models.Model):
    id = models.AutoField(primary_key=True)
    service_name = models.CharField(max_length=64, verbose_name='代理服务名称')
    package_id = models.IntegerField(null=True, default=None, verbose_name='套餐id')
    type = models.IntegerField(default=1, verbose_name='1:云存,2:4G')
    profit_type = models.SmallIntegerField(default=1, verbose_name='1:固定值,2:百分比')
    cost = models.DecimalField(default=0, max_digits=10, decimal_places=2, verbose_name=u'成本')
    profit = models.DecimalField(default=0, max_digits=10, decimal_places=2, verbose_name=u'利润值')
    status = models.SmallIntegerField(default=1, verbose_name='0:无效,1:有效')
    created_time = models.IntegerField(default=0, verbose_name='创建时间')
    created_by = models.CharField(blank=True, max_length=32, verbose_name='创建人')
    updated_time = models.IntegerField(default=0, verbose_name='修改时间')
    updated_by = models.CharField(blank=True, max_length=32, verbose_name='修改人')

    class Meta:
        db_table = 'a_cloud_service_package'
        verbose_name = '代理云服务套餐'
        verbose_name_plural = verbose_name
        app_label = 'AgentModel'


class AgentCustomerPackage(models.Model):
    id = models.AutoField(primary_key=True)
    ac_id = models.IntegerField(null=True, default=None, verbose_name='代理客户ID')
    cs_id = models.IntegerField(null=True, default=None, verbose_name='代理服务套餐id')
    created_time = models.IntegerField(default=0, verbose_name='创建时间')
    created_by = models.CharField(blank=True, max_length=32, verbose_name='创建人')
    updated_time = models.IntegerField(default=0, verbose_name='修改时间')
    updated_by = models.CharField(blank=True, max_length=32, verbose_name='修改人')

    class Meta:
        db_table = 'a_customer_package'
        verbose_name = '代理客户关联云服务套餐'
        verbose_name_plural = verbose_name
        app_label = 'AgentModel'


class AgentAccount(models.Model):
    id = models.AutoField(primary_key=True)
    ac_id = models.IntegerField(null=True, default=None, verbose_name='代理客户ID')
    amount = models.DecimalField(default=0, max_digits=10, decimal_places=2, verbose_name='金额')
    status = models.SmallIntegerField(default=1, verbose_name='1:已结算,2:已退款,3:提现')
    remark = models.CharField(null=True, default=None, max_length=255, verbose_name='备注')
    created_time = models.IntegerField(default=0, verbose_name='创建时间')
    updated_time = models.IntegerField(default=0, verbose_name='修改时间')

    class Meta:
        db_table = 'a_account'
        verbose_name = '代理账户余额'
        verbose_name_plural = verbose_name
        app_label = 'AgentModel'


class AgentAccountWithdraw(models.Model):
    id = models.AutoField(primary_key=True)
    ac_id = models.IntegerField(null=True, default=None, verbose_name='代理客户ID')
    amount = models.DecimalField(default=0, max_digits=10, decimal_places=2, verbose_name='金额')
    status = models.SmallIntegerField(default=1, verbose_name='1:审核中,2:审核通过,3:审核失败,4:已打款')
    card_id = models.IntegerField(null=True, default=None, verbose_name='客户提现卡id')
    arrival_time = models.IntegerField(default=0, verbose_name='到账时间')
    remark = models.CharField(null=True, default=None, max_length=255, verbose_name='备注')
    created_time = models.IntegerField(default=0, verbose_name='创建时间')
    updated_time = models.IntegerField(default=0, verbose_name='修改时间')

    class Meta:
        db_table = 'a_account_withdraw'
        verbose_name = '代理账户提现明细'
        verbose_name_plural = verbose_name
        app_label = 'AgentModel'


class AgentDeviceOrder(models.Model):
    id = models.AutoField(primary_key=True)
    ac_id = models.IntegerField(null=True, default=None, verbose_name='代理客户ID')
    serial_number = models.CharField(db_index=True, blank=True, default=None, max_length=32, verbose_name='设备9位序列号')
    csp_id = models.IntegerField(null=True, default=None, verbose_name='代理云服务套餐ID')
    order_id = models.CharField(blank=True, default=None, max_length=32, verbose_name='关联订单表')
    status = models.SmallIntegerField(default=1, verbose_name='0:结算失败,1:待结算,2:已结算,3:订单已退款')
    profit_amount = models.DecimalField(default=0, max_digits=10, decimal_places=2, verbose_name='营业额')
    profit = models.DecimalField(default=0, max_digits=10, decimal_places=2, verbose_name='利润')
    is_del = models.BooleanField(blank=True, default=False, verbose_name=u'是否删除')
    settlement_time = models.IntegerField(default=0, verbose_name='结算时间')
    remark = models.CharField(null=True, default=None, max_length=128, verbose_name='备注')
    expire_time = models.IntegerField(default=0, verbose_name='套餐失效时间')
    pay_time = models.IntegerField(default=0, verbose_name='套餐支付时间')
    created_time = models.IntegerField(default=0, verbose_name='创建时间')
    updated_time = models.IntegerField(default=0, verbose_name='修改时间')

    class Meta:
        db_table = 'a_device_order'
        verbose_name = '代理设备订单结算明细'
        verbose_name_plural = verbose_name
        app_label = 'AgentModel'


class AgentDeviceOrderInstallment(models.Model):
    id = models.AutoField(primary_key=True)
    ado_id = models.IntegerField(null=True, default=None, verbose_name='关联的代理设备订单')
    ac_id = models.IntegerField(null=True, default=None, verbose_name='代理客户ID')
    period_number = models.IntegerField(verbose_name='期数', help_text="这个字段表示这是第几期")
    amount = models.DecimalField(default=0, max_digits=10, decimal_places=2, verbose_name='本期结算金额')
    status = models.SmallIntegerField(default=1, verbose_name='0:结算失败,1:待结算,2:已结算,3:已退款')
    settlement_time = models.IntegerField(default=0, verbose_name='实际结算时间', help_text="记录实际结算的时间戳")
    due_date = models.IntegerField(verbose_name='应结算日期', help_text="预计结算的时间戳")
    created_time = models.IntegerField(default=0, verbose_name='创建时间')
    updated_time = models.IntegerField(default=0, verbose_name='修改时间')

    class Meta:
        db_table = 'a_device_order_installment'
        verbose_name = '代理设备订单分期结算'
        verbose_name_plural = verbose_name
        app_label = 'AgentModel'


class ApplyAgent(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32, verbose_name='姓名')
    phone = models.CharField(max_length=16, db_index=True, verbose_name=u'手机号', default='', blank=True)
    regin = models.CharField(default='', max_length=32, verbose_name='地区')
    remark = models.CharField(null=True, default=None, max_length=128, verbose_name='备注')
    created_time = models.IntegerField(default=0, verbose_name='创建时间')
    updated_time = models.IntegerField(default=0, verbose_name='修改时间')

    class Meta:
        db_table = 'apply_agent'
        verbose_name = '申请代理表'
        verbose_name_plural = verbose_name
        app_label = 'AgentModel'


class CustomUIDPool(models.Model):
    id = models.AutoField(primary_key=True, verbose_name='自增标记ID')
    uid = models.CharField(default='', db_index=True, max_length=32, unique=True, verbose_name='设备ID')
    type = models.SmallIntegerField(default=1, verbose_name=u'外销客户UID')
    customer_name = models.CharField(default='', max_length=32, verbose_name='客户id')
    status = models.IntegerField(default=0, verbose_name='0:未绑,1:绑定,2:弃用不再使用')
    created_time = models.IntegerField(default=0, verbose_name='创建时间')
    updated_time = models.IntegerField(default=0, verbose_name='更新时间')

    class Meta:
        db_table = 'custom_uid_pool'
        verbose_name = '定制UID池'
        verbose_name_plural = verbose_name
        app_label = 'AgentModel'


class DeviceCustomUID(models.Model):
    id = models.AutoField(primary_key=True, verbose_name='自增标记ID')
    uid = models.CharField(default='', db_index=True, max_length=32, unique=True, verbose_name='设备ID')
    device_mac = models.CharField(default='', db_index=True, max_length=64, unique=True, verbose_name='mac地址')
    status = models.IntegerField(default=0, verbose_name='1:绑定,2:失败')
    created_time = models.IntegerField(default=0, verbose_name='创建时间')
    updated_time = models.IntegerField(default=0, verbose_name='更新时间')

    class Meta:
        db_table = 'device_custom_uid'
        verbose_name = '设备关联定制UID'
        verbose_name_plural = verbose_name
        app_label = 'AgentModel'
