73 lines
1.9 KiB
PHP
73 lines
1.9 KiB
PHP
<?php
|
||
|
||
namespace app\models\integral\mall;
|
||
|
||
use Yii;
|
||
|
||
/**
|
||
* This is the model class for table "{{%integral_mall_goods_attr}}".
|
||
*
|
||
* @property int $id ID
|
||
* @property int $cx_mch_id 平台商户ID
|
||
* @property int $goods_id 商品ID
|
||
* @property int $goods_attr_id 商品规格ID
|
||
* @property int $integral_num 所需积分
|
||
* @property int $created_at 添加时间
|
||
* @property int $updated_at 更新时间
|
||
* @property int $is_delete 是否删除:0=否,1=是
|
||
* @property int $deleted_at 删除时间
|
||
*/
|
||
class IntegralMallGoodsAttr extends \yii\db\ActiveRecord
|
||
{
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public static function tableName()
|
||
{
|
||
return '{{%integral_mall_goods_attr}}';
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function rules()
|
||
{
|
||
return [
|
||
[['cx_mch_id', 'goods_id', 'goods_attr_id', 'integral_num', 'created_at', 'updated_at', 'is_delete', 'deleted_at'], 'integer'],
|
||
[['goods_id', 'goods_attr_id', 'integral_num'], 'required'],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function attributeLabels()
|
||
{
|
||
return [
|
||
'id' => 'ID',
|
||
'cx_mch_id' => '平台商户ID',
|
||
'goods_id' => '商品ID',
|
||
'goods_attr_id' => '商品规格ID',
|
||
'integral_num' => '所需积分',
|
||
'created_at' => '添加时间',
|
||
'updated_at' => '更新时间',
|
||
'is_delete' => '是否删除:0=否,1=是',
|
||
'deleted_at' => '删除时间',
|
||
];
|
||
}
|
||
|
||
public function beforeSave($insert) {
|
||
if(parent::beforeSave($insert)){
|
||
if($this->isNewRecord){
|
||
$this->created_at = time();
|
||
}
|
||
$this->updated_at = time();
|
||
if($this->is_delete == 1)
|
||
$this->deleted_at = time();
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
}
|