83 lines
2.1 KiB
PHP
83 lines
2.1 KiB
PHP
<?php
|
||
|
||
namespace app\models;
|
||
|
||
use Yii;
|
||
use app\models\Model;
|
||
|
||
/**
|
||
* This is the model class for table "{{%recharge_rule}}".
|
||
*
|
||
* @property int $id ID
|
||
* @property int $cx_mch_id 平台商户ID
|
||
* @property string $name 方案名称
|
||
* @property float $pay_price 支付金额
|
||
* @property float $send_price 赠送金额
|
||
* @property int $created_at 添加时间
|
||
* @property int $updated_at 更新时间
|
||
* @property int $deleted_at 删除时间
|
||
* @property int $is_delete 是否删除:0=否,1=是
|
||
*/
|
||
class RechargeRule extends \yii\db\ActiveRecord
|
||
{
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public static function tableName()
|
||
{
|
||
return '{{%recharge_rule}}';
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function rules()
|
||
{
|
||
return [
|
||
[['name'], 'trim'],
|
||
[['cx_mch_id', 'created_at', 'updated_at', 'deleted_at', 'is_delete'], 'integer'],
|
||
[['name'], 'required'],
|
||
[['pay_price', 'send_price'], 'number'],
|
||
[['name'], 'string', 'max' => 50],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function attributeLabels()
|
||
{
|
||
return [
|
||
'id' => 'ID',
|
||
'cx_mch_id' => '平台商户ID',
|
||
'name' => '方案名称',
|
||
'pay_price' => '支付金额',
|
||
'send_price' => '赠送金额',
|
||
'created_at' => '添加时间',
|
||
'updated_at' => '更新时间',
|
||
'deleted_at' => '删除时间',
|
||
'is_delete' => '是否删除:0=否,1=是',
|
||
];
|
||
}
|
||
|
||
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();
|
||
$this->htmlTagFilter();
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
public function htmlTagFilter()
|
||
{
|
||
$this->name = Model::htmlTagFilter($this->name);
|
||
}
|
||
}
|