cxfoot/models/RechargeRule.php
2023-10-27 14:25:12 +08:00

83 lines
2.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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);
}
}