<?php

namespace common\models\ars;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "ats_order_goods".
 *
 * @property int $id
 * @property int $order_id 订单id
 * @property int $goods_id 商品id
 * @property int $goods_img 商品图片
 * @property string $goods_name 商品名称
 * @property int $goods_count 商品数量
 * @property string $sku_value 商品sku
 * @property int $price 销售价
 * @property int $market_price 市场价
 * @property int $updated_at 更新时间
 * @property int $created_at 创建时间
 * @property int $weight 重量
 * @property int $sku_id sku_id
 */
class OrderGoods extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'ats_order_goods';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['order_id', 'goods_id'], 'required'],
            [['order_id', 'goods_id', 'goods_img', 'goods_count', 'price', 'market_price', 'weight', 'sku_id'], 'integer'],
            [['goods_name', 'sku_value'], 'string', 'max' => 120],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'id',
            'order_id' => '订单id',
            'goods_id' => '商品id',
            'goods_img' => '商品图片',
            'goods_name' => '商品名称',
            'goods_count' => '商品数量',
            'sku_value' => '商品sku',
            'price' => '销售价',
            'market_price' => '市场价',
            'updated_at' => '更新时间',
            'created_at' => '创建时间',
            'weight' => '重量',
            'sku_id' => 'sku_id',
        ];
    }
   

    /**
    * @author linyao
    * @email 602604991@qq.com
    * @created Nov 8, 2019
    *
    * 行为存储创建时间和更新时间
    */
    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'createdAtAttribute' => 'created_at',
                'updatedAtAttribute' => 'updated_at',
                'value' => function() {
                    return time();
                },
            ],
        ];
    }
}