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

75 lines
1.8 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\integral\mall;
use Yii;
use app\models\Order;
/**
* This is the model class for table "{{%integral_mall_order}}".
*
* @property int $id ID
* @property int $cx_mch_id 平台商户ID
* @property int $order_id 订单ID
* @property int $integral_num 所需积分
* @property int $created_at 添加时间
* @property int $is_delete 是否删除0=否1=是
* @property int $deleted_at 删除时间
*/
class IntegralMallOrder extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return '{{%integral_mall_order}}';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['cx_mch_id', 'order_id', 'integral_num', 'created_at', 'is_delete', 'deleted_at'], 'integer'],
[['order_id', 'integral_num'], 'required'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'cx_mch_id' => '平台商户ID',
'order_id' => '订单ID',
'integral_num' => '所需积分',
'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();
return true;
} else {
return false;
}
}
public function getOrder()
{
return $this->hasOne(Order::className(), ['id' => 'order_id']);
}
}