<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%DECLARATION}}".
 *
 * @property string $ID
 * @property string $USER_ID 会员ID
 * @property int $TYPE 报单类型
 * @property string $INSERT_USER_ID 首购会员ID
 * @property string $DEC_AMOUNT 报单金额
 * @property string $DEC_PV 报单PV
 * @property int $PERIOD_NUM 报单期数
 * @property int $STATUS 状态
 * @property int $CREATED_AT 创建时间
 */
class Declaration extends \common\components\ActiveRecord
{
    const TYPE_FIRST_BUY = 1;   // 首购
    const TYPE_UP_LEVEL = 2;    // 升级增购
    const TYPE_AGAIN_BUY = 3;   // 复销
    const TYPE_RETAIL = 4;      // 零售

    const STATUS_WAITING_PAYMENT = 0;   // 等待付款状态
    const STATUS_CAN_SETTLEMENT = 1;    // 可结算状态
    const STATUS_DELETE = 2;            // 已删除状态

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%DECLARATION}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['USER_ID', 'TYPE', 'PERIOD_NUM', 'CREATED_AT'], 'required'],
            [['TYPE', 'PERIOD_NUM', 'STATUS', 'CREATED_AT'], 'integer'],
            [['DEC_AMOUNT', 'DEC_PV'], 'number'],
            [['ID', 'USER_ID', 'INSERT_USER_ID'], 'string', 'max' => 32],
            [['ID'], 'unique'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'ID' => 'ID',
            'USER_ID' => '会员ID',
            'TYPE' => '报单类型',
            'INSERT_USER_ID' => '首购会员ID',
            'DEC_AMOUNT' => '报单金额',
            'DEC_PV' => '报单PV',
            'PERIOD_NUM' => '报单期数',
            'STATUS' => '状态',
            'CREATED_AT' => '创建时间',
        ];
    }
}
