155 lines
3.9 KiB
PHP
155 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace app\admin\model;
|
|
|
|
use think\Model;
|
|
|
|
|
|
class OrderDispatch extends Model
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// 表名
|
|
protected $name = 'order_dispatch';
|
|
|
|
// 自动写入时间戳字段
|
|
protected $autoWriteTimestamp = 'datetime';
|
|
|
|
protected $dateFormat = 'Y-m-d H:i:s';
|
|
// 定义时间戳字段名
|
|
protected $createTime = 'create_time';
|
|
protected $updateTime = 'update_time';
|
|
protected $deleteTime = false;
|
|
|
|
// 追加属性
|
|
protected $append = [
|
|
'type_text',
|
|
'status_text',
|
|
'is_notice_text'
|
|
];
|
|
|
|
const STATUS_TOGET = 0; //待接
|
|
const STATUS_GOTIT = 10; //已接
|
|
const STATUS_PLANIT = 20; //已预约
|
|
const STATUS_OVERTIME = 25; //超时(过了预约时间)
|
|
const STATUS_CLOCK = 30; //已打卡
|
|
const STATUS_FINISH = 60; //完成
|
|
const STATUS_REFUSED = -10; //拒绝
|
|
const STATUS_MOVE = -20; //中转(状态废弃)
|
|
const STATUS_CANCEL = -30; //取消
|
|
|
|
|
|
public function getTypeList()
|
|
{
|
|
return ['1' => __('Type 1')];
|
|
}
|
|
|
|
public function getStatusList()
|
|
{
|
|
return ['0' => __('Status 0'), '10' => __('Status 10'), '20' => __('Status 20'),'25' => __('Status 25'), '30' => __('Status 30'), '60' => __('Status 60'), '-10' => __('Status -10'),
|
|
// '-20' => __('Status -20'),
|
|
'-30' => __('Status -30')];
|
|
}
|
|
|
|
public function getIsNoticeList()
|
|
{
|
|
return ['0' => __('Is_notice 0'), '1' => __('Is_notice 1')];
|
|
}
|
|
|
|
|
|
public function getTypeTextAttr($value, $data)
|
|
{
|
|
$value = $value ?: ($data['type'] ?? '');
|
|
$list = $this->getTypeList();
|
|
return $list[$value] ?? '';
|
|
}
|
|
|
|
|
|
public function getStatusTextAttr($value, $data)
|
|
{
|
|
$value = $value ?: ($data['status'] ?? '');
|
|
$list = $this->getStatusList();
|
|
return $list[$value] ?? '';
|
|
}
|
|
|
|
|
|
public function getIsNoticeTextAttr($value, $data)
|
|
{
|
|
$value = $value ?: ($data['is_notice'] ?? '');
|
|
$list = $this->getIsNoticeList();
|
|
return $list[$value] ?? '';
|
|
}
|
|
|
|
|
|
public function deleteStatusList(){
|
|
return [
|
|
self::STATUS_TOGET,
|
|
self::STATUS_GOTIT,
|
|
self::STATUS_PLANIT,
|
|
self::STATUS_OVERTIME,
|
|
self::STATUS_CLOCK,
|
|
];
|
|
}
|
|
|
|
public function checkDelete($status){
|
|
|
|
if(in_array($status,$this->deleteStatusList())){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
public function order()
|
|
{
|
|
return $this->belongsTo('Order', 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
|
|
public function btnActiveStatusList($btn){
|
|
|
|
$btns = [
|
|
'btn_edit' => [
|
|
self::STATUS_TOGET,
|
|
self::STATUS_GOTIT,
|
|
self::STATUS_PLANIT,
|
|
self::STATUS_OVERTIME,
|
|
self::STATUS_CLOCK,
|
|
],
|
|
'btn_cancel' => [ //取消按钮
|
|
self::STATUS_TOGET,
|
|
self::STATUS_GOTIT,
|
|
self::STATUS_PLANIT,
|
|
self::STATUS_OVERTIME,
|
|
self::STATUS_CLOCK,
|
|
],
|
|
'btn_abnormal' => [ //添加异常按钮
|
|
self::STATUS_TOGET,
|
|
self::STATUS_GOTIT,
|
|
self::STATUS_PLANIT,
|
|
self::STATUS_OVERTIME,
|
|
self::STATUS_CLOCK,
|
|
],
|
|
'btn_finished' => [
|
|
self::STATUS_TOGET,
|
|
self::STATUS_GOTIT,
|
|
self::STATUS_PLANIT,
|
|
self::STATUS_OVERTIME,
|
|
self::STATUS_CLOCK,
|
|
//self::STATUS_FINISH
|
|
],
|
|
'disabled_status' => [
|
|
self::STATUS_FINISH,
|
|
self::STATUS_CANCEL,
|
|
self::STATUS_REFUSED,
|
|
self::STATUS_MOVE
|
|
]
|
|
];
|
|
|
|
return $btns[$btn]??[];
|
|
}
|
|
}
|