2024-11-06 19:09:37 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\admin\model\school\classes\hourorder;
|
|
|
|
|
|
|
|
use think\Model;
|
|
|
|
use traits\model\SoftDelete;
|
|
|
|
|
|
|
|
class Order extends Model
|
|
|
|
{
|
|
|
|
|
|
|
|
use SoftDelete;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 表名
|
|
|
|
protected $name = 'school_classes_hour_order';
|
|
|
|
|
|
|
|
// 自动写入时间戳字段
|
|
|
|
protected $autoWriteTimestamp = 'integer';
|
|
|
|
|
|
|
|
// 定义时间戳字段名
|
|
|
|
protected $createTime = 'createtime';
|
|
|
|
protected $updateTime = 'updatetime';
|
|
|
|
protected $deleteTime = 'deletetime';
|
|
|
|
|
|
|
|
// 追加属性
|
|
|
|
protected $append = [
|
|
|
|
'start_time_text',
|
|
|
|
'end_time_text',
|
|
|
|
'status_text',
|
|
|
|
'reservation_time_text',
|
|
|
|
'finish_time_text',
|
2024-11-20 18:05:45 +08:00
|
|
|
'cancel_time_text',
|
|
|
|
'auth_status_text',
|
2024-11-06 19:09:37 +08:00
|
|
|
];
|
|
|
|
|
2024-11-20 18:05:45 +08:00
|
|
|
|
|
|
|
public function getAuthStatusList()
|
|
|
|
{
|
|
|
|
return ['0' => __('Auth_status 0'), '1' => __('Auth_status 1'), '2' => __('Auth_status 2')];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAuthStatusTextAttr($value, $data)
|
|
|
|
{
|
|
|
|
$value = $value ? $value : (isset($data['auth_status']) ? $data['auth_status'] : '');
|
|
|
|
$list = $this->getAuthStatusList();
|
|
|
|
return isset($list[$value]) ? $list[$value] : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getStatusTextAttr($value, $data)
|
|
|
|
{
|
|
|
|
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
|
|
|
|
$list = $this->getStatusList();
|
|
|
|
return isset($list[$value]) ? $list[$value] : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-06 19:09:37 +08:00
|
|
|
public function getStatusList()
|
|
|
|
{
|
2024-11-07 18:11:08 +08:00
|
|
|
return ['-3' => __('Status -3'),'-1' => __('Status -1'), '0' => __('Status 0'), '3' => __('Status 3')];
|
2024-11-06 19:09:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getStartTimeTextAttr($value, $data)
|
|
|
|
{
|
|
|
|
$value = $value ? $value : (isset($data['start_time']) ? $data['start_time'] : '');
|
|
|
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getEndTimeTextAttr($value, $data)
|
|
|
|
{
|
|
|
|
$value = $value ? $value : (isset($data['end_time']) ? $data['end_time'] : '');
|
|
|
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getReservationTimeTextAttr($value, $data)
|
|
|
|
{
|
|
|
|
$value = $value ? $value : (isset($data['reservation_time']) ? $data['reservation_time'] : '');
|
|
|
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getFinishTimeTextAttr($value, $data)
|
|
|
|
{
|
|
|
|
$value = $value ? $value : (isset($data['finish_time']) ? $data['finish_time'] : '');
|
|
|
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getCancelTimeTextAttr($value, $data)
|
|
|
|
{
|
|
|
|
$value = $value ? $value : (isset($data['cancel_time']) ? $data['cancel_time'] : '');
|
|
|
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function setStartTimeAttr($value)
|
|
|
|
{
|
|
|
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function setEndTimeAttr($value)
|
|
|
|
{
|
|
|
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function setReservationTimeAttr($value)
|
|
|
|
{
|
|
|
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function setFinishTimeAttr($value)
|
|
|
|
{
|
|
|
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function setCancelTimeAttr($value)
|
|
|
|
{
|
|
|
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-11-07 18:11:08 +08:00
|
|
|
public function classesorder()
|
2024-11-06 19:09:37 +08:00
|
|
|
{
|
|
|
|
return $this->belongsTo('app\admin\model\school\classes\Order', 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function spec()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('app\admin\model\school\classes\lib\Spec', 'classes_lib_spec_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function detail()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('app\admin\model\school\classes\order\Detail', 'classes_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function lib()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('app\admin\model\school\classes\Lib', 'classes_lib_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
|
|
}
|
|
|
|
}
|