<?php

namespace common\models;

use common\helpers\snowflake\SnowFake;
use common\helpers\Tool;
use Yii;
use yii\base\Exception;

/**
 * This is the model class for table "{{%PERF_ACTIVE_USER}}".
 *
 * 
 * 
 * @property string $ID
 * @property string $USER_ID 用户id
 * @property string $IS_ACTIVE 是否活跃 1活跃
 * @property string $IS_SENT 是否已挂网,已官网不能删除 1已挂网
 * @property int $PERIOD_NUM 业绩期,是第几期
 * @property string $CALC_MONTH 结算年月202110
 * @property string $P_CALC_MONTH 结算年月日2021-12-10
 * @property string $WHICH_WEEK 当月第几周
 * @property int $WHICH_MONTH 当年第几月
 * @property string $WHICH_YEAR 结算周期年份
 * @property int $CREATED_AT 创建时间
 */
class PerfActiveUser extends \common\components\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%PERF_ACTIVE_USER}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['IS_ACTIVE', 'USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT', 'SRATR_AT', 'END_AT'], 'required'],
            [['PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
            [['ID', 'USER_ID'], 'string', 'max' => 32],
            [['P_CALC_MONTH'], 'string', 'max' => 7],
            [['ID'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'ID' => 'ID',
            'USER_ID' => '用户ID',
            'IS_ACTIVE' => '是否活跃',
            'IS_SENT' => '是否已挂网',
            'PERIOD_NUM' => '业绩期',
            'CALC_MONTH' => '结算年月',
            'P_CALC_MONTH' => '结算年月日',
            'SRATR_AT' => '活跃开始时间',
            'END_AT' => '活跃结束时间',
            'CREATED_AT' => '创建时间'
        ];
    }

    /**
     * 生成sn
     * @return string
     */
    public static function generateSN() {
        return  SnowFake::instance()->generateId();
    }
}
