207 lines
5.8 KiB
PHP
207 lines
5.8 KiB
PHP
<?php
|
|
|
|
namespace app\admin\model\school\classes\order;
|
|
|
|
use app\common\model\dyqc\ManystoreShop;
|
|
use app\common\model\manystore\Shop;
|
|
use app\common\model\school\classes\ClassesLib;
|
|
use app\manystore\model\Manystore;
|
|
use think\Model;
|
|
use traits\model\SoftDelete;
|
|
|
|
class ServiceOrder extends Model
|
|
{
|
|
|
|
use SoftDelete;
|
|
|
|
|
|
|
|
// 表名
|
|
protected $name = 'school_classes_service_order';
|
|
|
|
// 自动写入时间戳字段
|
|
protected $autoWriteTimestamp = 'integer';
|
|
|
|
// 定义时间戳字段名
|
|
protected $createTime = 'createtime';
|
|
protected $updateTime = 'updatetime';
|
|
protected $deleteTime = 'deletetime';
|
|
|
|
// 追加属性
|
|
protected $append = [
|
|
'status_text',
|
|
'service_stauts_text',
|
|
'sales_type_text',
|
|
'platform_text',
|
|
'pay_type_text',
|
|
'refundtime_text',
|
|
'rejecttime_text',
|
|
'handletime_text',
|
|
'confirmtime_text',
|
|
'checkouttime_text'
|
|
];
|
|
|
|
|
|
|
|
public function getStatusList()
|
|
{
|
|
return ['1' => __('Status 1'), '4' => __('Status 4'), '7' => __('Status 7'), '-3' => __('Status -3')];
|
|
}
|
|
|
|
public function getServiceStautsList()
|
|
{
|
|
return ['1' => __('Service_stauts 1'), '4' => __('Service_stauts 4'), '7' => __('Service_stauts 7'), '-3' => __('Service_stauts -3')];
|
|
}
|
|
|
|
public function getSalesTypeList()
|
|
{
|
|
return ['-3' => __('Sales_type -3'), '1' => __('Sales_type 1'), '4' => __('Sales_type 4'), '7' => __('Sales_type 7'), '10' => __('Sales_type 10')];
|
|
}
|
|
|
|
public function getPlatformList()
|
|
{
|
|
return ['miniapp' => __('Platform miniapp')];
|
|
}
|
|
|
|
public function getPayTypeList()
|
|
{
|
|
return ['yue' => __('Pay_type yue'), 'wechat' => __('Pay_type wechat')];
|
|
}
|
|
|
|
|
|
public function getStatusTextAttr($value, $data)
|
|
{
|
|
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
|
|
$list = $this->getStatusList();
|
|
return isset($list[$value]) ? $list[$value] : '';
|
|
}
|
|
|
|
|
|
public function getServiceStautsTextAttr($value, $data)
|
|
{
|
|
$value = $value ? $value : (isset($data['service_stauts']) ? $data['service_stauts'] : '');
|
|
$list = $this->getServiceStautsList();
|
|
return isset($list[$value]) ? $list[$value] : '';
|
|
}
|
|
|
|
|
|
public function getSalesTypeTextAttr($value, $data)
|
|
{
|
|
$value = $value ? $value : (isset($data['sales_type']) ? $data['sales_type'] : '');
|
|
$list = $this->getSalesTypeList();
|
|
return isset($list[$value]) ? $list[$value] : '';
|
|
}
|
|
|
|
|
|
public function getPlatformTextAttr($value, $data)
|
|
{
|
|
$value = $value ? $value : (isset($data['platform']) ? $data['platform'] : '');
|
|
$list = $this->getPlatformList();
|
|
return isset($list[$value]) ? $list[$value] : '';
|
|
}
|
|
|
|
|
|
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 getRefundtimeTextAttr($value, $data)
|
|
{
|
|
$value = $value ? $value : (isset($data['refundtime']) ? $data['refundtime'] : '');
|
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
|
}
|
|
|
|
|
|
public function getRejecttimeTextAttr($value, $data)
|
|
{
|
|
$value = $value ? $value : (isset($data['rejecttime']) ? $data['rejecttime'] : '');
|
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
|
}
|
|
|
|
|
|
public function getHandletimeTextAttr($value, $data)
|
|
{
|
|
$value = $value ? $value : (isset($data['handletime']) ? $data['handletime'] : '');
|
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
|
}
|
|
|
|
|
|
public function getConfirmtimeTextAttr($value, $data)
|
|
{
|
|
$value = $value ? $value : (isset($data['confirmtime']) ? $data['confirmtime'] : '');
|
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
|
}
|
|
|
|
|
|
public function getCheckouttimeTextAttr($value, $data)
|
|
{
|
|
$value = $value ? $value : (isset($data['checkouttime']) ? $data['checkouttime'] : '');
|
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
|
}
|
|
|
|
protected function setRefundtimeAttr($value)
|
|
{
|
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
|
}
|
|
|
|
protected function setRejecttimeAttr($value)
|
|
{
|
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
|
}
|
|
|
|
protected function setHandletimeAttr($value)
|
|
{
|
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
|
}
|
|
|
|
protected function setConfirmtimeAttr($value)
|
|
{
|
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
|
}
|
|
|
|
protected function setCheckouttimeAttr($value)
|
|
{
|
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
|
}
|
|
|
|
|
|
public function classesorder()
|
|
{
|
|
return $this->belongsTo(Order::class, 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
|
|
public function detail()
|
|
{
|
|
return $this->belongsTo(OrderDetail::class, 'classes_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
|
|
public function lib()
|
|
{
|
|
return $this->belongsTo(ClassesLib::class, 'classes_lib_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
|
|
public function manystore()
|
|
{
|
|
return $this->belongsTo(Manystore::class, 'manystore_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
|
|
public function shop()
|
|
{
|
|
return $this->belongsTo(ManystoreShop::class, 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
}
|