cxfoot/models/integral/IntegralLog.php
2023-10-24 14:54:18 +08:00

81 lines
2.2 KiB
PHP
Raw 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\integral;
use Yii;
/**
* This is the model class for table "{{%integral_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 int $integral 积分
* @property int $before_account_integral 变化前账户积分
* @property int $after_account_integral 变化后账户积分
* @property string|null $desc 描述
* @property int $order_type 订单类型
* @property string|null $order_no 订单号
* @property string|null $ext 扩展信息
* @property int $created_at 添加时间
*/
class IntegralLog extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return '{{%integral_log}}';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['ext', 'desc', 'order_no'], 'trim'],
[['cx_mch_id', 'scene', 'type', 'user_id', 'integral', 'before_account_integral', 'after_account_integral', 'order_type', 'created_at'], 'integer'],
[['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',
'integral' => '积分',
'before_account_integral' => '变化前账户积分',
'after_account_integral' => '变化后账户积分',
'desc' => '描述',
'order_type' => '订单类型',
'order_no' => '订单号',
'ext' => '扩展信息',
'created_at' => '添加时间',
];
}
public function beforeSave($insert) {
if(parent::beforeSave($insert)){
if($this->isNewRecord){
$this->created_at = time();
}
return true;
} else {
return false;
}
}
}