212 lines
6.3 KiB
PHP
Raw Normal View History

2025-03-24 09:40:45 +08:00
<?php
2025-04-03 17:58:16 +08:00
namespace app\admin\model\school\activity\order;
2025-03-24 09:40:45 +08:00
use app\admin\model\school\activity\Activity;
2025-03-24 09:40:45 +08:00
use think\Model;
use traits\model\SoftDelete;
class Order extends Model
{
use SoftDelete;
// 表名
2025-04-03 17:58:16 +08:00
protected $name = 'school_activity_order';
2025-03-24 09:40:45 +08:00
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
// 追加属性
protected $append = [
'pay_type_text',
'status_text',
'before_status_text',
'server_status_text',
'canceltime_text',
'paytime_text',
2025-04-03 17:58:16 +08:00
'auth_time_text',
'reservation_time_text',
2025-03-24 09:40:45 +08:00
'finishtime_text',
2025-04-03 17:58:16 +08:00
'refundtime_text',
'auth_status_text',
'refundsendtime_text'
2025-03-24 09:40:45 +08:00
];
public function getPayTypeList()
{
return ['yue' => __('Pay_type yue'), 'wechat' => __('Pay_type wechat')];
}
public function getStatusList()
{
2025-04-03 17:58:16 +08:00
return ['-3' => __('Status -3'), '0' => __('Status 0'), '2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4'), '5' => __('Status 5'), '6' => __('Status 6'), '9' => __('Status 9')];
2025-03-24 09:40:45 +08:00
}
public function getBeforeStatusList()
{
2025-04-03 17:58:16 +08:00
return ['-3' => __('Before_status -3'), '0' => __('Before_status 0'), '2' => __('Before_status 2'), '3' => __('Before_status 3'), '4' => __('Before_status 4'), '6' => __('Before_status 6'), '9' => __('Before_status 9')];
2025-03-24 09:40:45 +08:00
}
public function getServerStatusList()
{
return ['0' => __('Server_status 0'), '3' => __('Server_status 3'), '6' => __('Server_status 6')];
}
2025-04-03 17:58:16 +08:00
public function getAuthStatusList()
2025-03-24 09:40:45 +08:00
{
2025-04-03 17:58:16 +08:00
return ['0' => __('Auth_status 0'), '1' => __('Auth_status 1'), '2' => __('Auth_status 2')];
2025-03-24 09:40:45 +08:00
}
public function getPayTypeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['pay_type']) ? $data['pay_type'] : '');
$list = $this->getPayTypeList();
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] : '';
}
public function getBeforeStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['before_status']) ? $data['before_status'] : '');
$list = $this->getBeforeStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getServerStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['server_status']) ? $data['server_status'] : '');
$list = $this->getServerStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getCanceltimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['canceltime']) ? $data['canceltime'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getPaytimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['paytime']) ? $data['paytime'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
2025-04-03 17:58:16 +08:00
public function getAuthTimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['auth_time']) ? $data['auth_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;
}
2025-03-24 09:40:45 +08:00
public function getFinishtimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['finishtime']) ? $data['finishtime'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getRefundtimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['refundtime']) ? $data['refundtime'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
2025-04-03 17:58:16 +08:00
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 getRefundsendtimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['refundsendtime']) ? $data['refundsendtime'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
2025-03-24 09:40:45 +08:00
protected function setCanceltimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
protected function setPaytimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
2025-04-03 17:58:16 +08:00
protected function setAuthTimeAttr($value)
2025-03-24 09:40:45 +08:00
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
2025-04-03 17:58:16 +08:00
protected function setReservationTimeAttr($value)
2025-03-24 09:40:45 +08:00
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
2025-04-03 17:58:16 +08:00
protected function setFinishtimeAttr($value)
2025-03-24 09:40:45 +08:00
{
2025-04-03 17:58:16 +08:00
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
2025-03-24 09:40:45 +08:00
}
2025-04-03 17:58:16 +08:00
protected function setRefundtimeAttr($value)
2025-03-24 09:40:45 +08:00
{
2025-04-03 17:58:16 +08:00
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
2025-03-24 09:40:45 +08:00
}
2025-04-03 17:58:16 +08:00
protected function setRefundsendtimeAttr($value)
2025-03-24 09:40:45 +08:00
{
2025-04-03 17:58:16 +08:00
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
2025-03-24 09:40:45 +08:00
}
2025-04-03 17:58:16 +08:00
public function user()
2025-03-24 09:40:45 +08:00
{
return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
2025-03-24 09:40:45 +08:00
}
2025-04-03 17:58:16 +08:00
public function activity()
2025-03-24 09:40:45 +08:00
{
return $this->belongsTo(Activity::class, 'activity_id', 'id', [], 'LEFT')->setEagerlyType(0);
2025-03-24 09:40:45 +08:00
}
2025-04-03 17:58:16 +08:00
public function detail()
2025-03-24 09:40:45 +08:00
{
return $this->belongsTo(OrderDetail::class, 'activity_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0);
2025-03-24 09:40:45 +08:00
}
}