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

104 lines
3.5 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 "{{%order_detail}}".
*
* @property int $id ID
* @property int $cx_mch_id 平台商户ID
* @property int $order_id 订单ID
* @property string $goods_id 商品ID
* @property int $num 购买商品数量
* @property float $unit_price 商品单价
* @property float $total_original_price 商品原总价(优惠前)
* @property float $total_price 商品总价(优惠后)
* @property string $goods_attr_info 购买商品信息
* @property int $is_delete 是否删除0=否1=是
* @property int $created_at 添加时间
* @property int $updated_at 更新时间
* @property int $deleted_at 删除时间
* @property int $is_refund 是否退款
* @property int $refund_status 售后状态0=未售后1=售后中2=售后结束
* @property string $plugin_sign 插件标识
* @property string $serial_no 商品货号
* @property int $goods_type 商品类型
* @property string $start_time 开始时间
* @property int $end_time 结束时间
* @property int $end_at 预约结束时间
* @property int $start_at 预约开始时间
* @property int $duration 时长
*/
class OrderDetail extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return '{{%order_detail}}';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['goods_attr_info', 'plugin_sign', 'serial_no'], 'trim'],
[['cx_mch_id', 'order_id', 'num', 'is_delete', 'created_at', 'updated_at', 'deleted_at', 'is_refund', 'refund_status', 'goods_type'], 'integer'],
[['order_id', 'goods_id', 'num', 'unit_price', 'total_original_price', 'total_price', 'goods_attr_info',], 'required'],
[['unit_price', 'total_original_price', 'total_price'], 'number'],
[['goods_attr_info'], 'string'],
[['plugin_sign'], 'string', 'max' => 255],
[['serial_no'], 'string', 'max' => 60],
[['goods_id'], 'string', 'max' => 20],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'cx_mch_id' => '平台商户ID',
'order_id' => '订单ID',
'goods_id' => '商品ID',
'num' => '购买商品数量',
'unit_price' => '商品单价',
'total_original_price' => '商品原总价(优惠前)',
'total_price' => '商品总价(优惠后)',
'goods_attr_info' => '购买商品信息',
'is_delete' => '是否删除0=否1=是',
'created_at' => '添加时间',
'updated_at' => '更新时间',
'deleted_at' => '删除时间',
'is_refund' => '是否退款',
'refund_status' => '售后状态0=未售后1=售后中2=售后结束',
'plugin_sign' => '插件标识',
'serial_no' => '商品货号',
'goods_type' => '商品类型',
];
}
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;
}
}
}