83 lines
2.4 KiB
PHP
83 lines
2.4 KiB
PHP
<?php
|
||
|
||
namespace app\models;
|
||
|
||
use Yii;
|
||
|
||
/**
|
||
* This is the model class for table "{{%recharge_order}}".
|
||
*
|
||
* @property int $id ID
|
||
* @property int $cx_mch_id 平台商户ID
|
||
* @property string $order_no 订单号
|
||
* @property int $user_id 用户ID
|
||
* @property float $pay_price 支付金额
|
||
* @property float $send_price 赠送金额
|
||
* @property int $pay_type 支付类型
|
||
* @property int $is_pay 是否支付:0=否,1=是
|
||
* @property int $pay_time 支付时间
|
||
* @property int $created_at 添加时间
|
||
* @property int $updated_at 更新时间
|
||
* @property int $is_delete 是否删除:0=否,1=是
|
||
* @property int $deleted_at 删除时间
|
||
*/
|
||
class RechargeOrder extends \yii\db\ActiveRecord
|
||
{
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public static function tableName()
|
||
{
|
||
return '{{%recharge_order}}';
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function rules()
|
||
{
|
||
return [
|
||
[['cx_mch_id', 'user_id', 'pay_type', 'is_pay', 'pay_time', 'created_at', 'updated_at', 'is_delete', 'deleted_at'], 'integer'],
|
||
[['order_no', 'user_id'], 'required'],
|
||
[['pay_price', 'send_price'], 'number'],
|
||
[['order_no'], 'string', 'max' => 64],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function attributeLabels()
|
||
{
|
||
return [
|
||
'id' => 'ID',
|
||
'cx_mch_id' => '平台商户ID',
|
||
'order_no' => '订单号',
|
||
'user_id' => '用户ID',
|
||
'pay_price' => '支付金额',
|
||
'send_price' => '赠送金额',
|
||
'pay_type' => '支付类型',
|
||
'is_pay' => '是否支付:0=否,1=是',
|
||
'pay_time' => '支付时间',
|
||
'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;
|
||
}
|
||
}
|
||
}
|