96 lines
2.8 KiB
PHP
96 lines
2.8 KiB
PHP
<?php
|
||
|
||
namespace app\models;
|
||
|
||
use Yii;
|
||
use app\models\Model;
|
||
|
||
/**
|
||
* This is the model class for table "{{%balance_log}}".
|
||
*
|
||
* @property int $id ID
|
||
* @property int $cx_mch_id 平台商户ID
|
||
* @property int $scene 场景类型
|
||
* @property int $type 类型:1=收入,2=支出
|
||
* @property int $user_id 用户ID
|
||
* @property float $money 金额
|
||
* @property float $before_account_balance 变化前账户余额
|
||
* @property float $after_account_balance 变化后账户余额
|
||
* @property string|null $desc 描述
|
||
* @property int $order_type 订单类型
|
||
* @property string|null $order_no 订单号
|
||
* @property string|null $ext 扩展信息
|
||
* @property int $created_at 添加时间
|
||
* @property int $is_delete 是否删除:0=否,1=是
|
||
* @property int $deleted_at 删除时间
|
||
*/
|
||
class BalanceLog extends \yii\db\ActiveRecord
|
||
{
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public static function tableName()
|
||
{
|
||
return '{{%balance_log}}';
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function rules()
|
||
{
|
||
return [
|
||
[['ext', 'desc', 'order_no'], 'trim'],
|
||
[['cx_mch_id', 'scene', 'type', 'user_id', 'order_type', 'created_at', 'is_delete', 'deleted_at'], 'integer'],
|
||
[['money', 'before_account_balance', 'after_account_balance'], 'number'],
|
||
[['ext'], 'string'],
|
||
[['desc'], 'string', 'max' => 2048],
|
||
[['order_no'], 'string', 'max' => 128],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function attributeLabels()
|
||
{
|
||
return [
|
||
'id' => 'ID',
|
||
'cx_mch_id' => '平台商户ID',
|
||
'scene' => '场景类型',
|
||
'type' => '类型:1=收入,2=支出',
|
||
'user_id' => '用户ID',
|
||
'money' => '金额',
|
||
'before_account_balance' => '变化前账户余额',
|
||
'after_account_balance' => '变化后账户余额',
|
||
'desc' => '描述',
|
||
'order_type' => '订单类型',
|
||
'order_no' => '订单号',
|
||
'ext' => '扩展信息',
|
||
'created_at' => '添加时间',
|
||
'is_delete' => '是否删除:0=否,1=是',
|
||
'deleted_at' => '删除时间',
|
||
];
|
||
}
|
||
|
||
|
||
public function beforeSave($insert) {
|
||
if(parent::beforeSave($insert)){
|
||
if($this->isNewRecord){
|
||
$this->created_at = time();
|
||
}
|
||
if($this->is_delete == 1)
|
||
$this->deleted_at = time();
|
||
$this->htmlTagFilter();
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
public function htmlTagFilter()
|
||
{
|
||
$this->desc = Model::htmlTagFilter($this->desc);
|
||
}
|
||
}
|