cxgj/models/RechargeOrder.php
2023-11-27 09:45:13 +08:00

83 lines
2.4 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;
/**
* 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;
}
}
}