allocatr/application/admin/model/Aftersale.php
2025-06-05 22:30:56 +08:00

125 lines
2.9 KiB
PHP

<?php
namespace app\admin\model;
use think\Model;
class Aftersale extends Model
{
// 表名
protected $name = 'aftersale';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
protected $dateFormat = 'Y-m-d H:i:s';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $deleteTime = false;
// 追加属性
protected $append = [
'status_text',
'handle_type_text',
'from_text',
'refund_type_text',
'worker_refund_entry_text',
'type_text'
];
public function getStatusList()
{
return ['1' => __('Status 1'),
'2' => __('Status 2'),
'3' => __('Status 3'),
'4' => __('Status 4'),
'-1' => __('Status -1')];
}
public function getHandleTypeList()
{
return ['1' => __('Handle_type 1'), '2' => __('Handle_type 2'), '3' => __('Handle_type 3'), '4' => __('Handle_type 4')];
}
public function getFromList()
{
return ['1' => __('From 1'), '2' => __('From 2'), '3' => __('From 3')];
}
public function getRefundTypeList()
{
return ['0' => __('Refund_type 0'),'1' => __('Refund_type 1'), '2' => __('Refund_type 2')];
}
public function getTypeList()
{
return ['1' => __('退款'),'2' => __('返修'), '3' => __('其它')];
}
public function getWorkerRefundEntryList()
{
return ['0' => __('Worker_refund_entry 0'), '1' => __('Worker_refund_entry 1')];
}
public function getStatusTextAttr($value, $data)
{
$value = $value ?: ($data['status'] ?? '');
$list = $this->getStatusList();
return $list[$value] ?? '';
}
public function getHandleTypeTextAttr($value, $data)
{
$value = $value ?: ($data['handle_type'] ?? '');
$list = $this->getHandleTypeList();
return $list[$value] ?? '';
}
public function getTypeTextAttr($value, $data)
{
$value = $value ?: ($data['type'] ?? '');
$list = $this->getTypeList();
return $list[$value] ?? '';
}
public function getFromTextAttr($value, $data)
{
$value = $value ?: ($data['from'] ?? '');
$list = $this->getFromList();
return $list[$value] ?? '';
}
public function getRefundTypeTextAttr($value, $data)
{
$value = $value ?: ($data['refund_type'] ?? '');
$list = $this->getRefundTypeList();
return $list[$value] ?? '';
}
public function getWorkerRefundEntryTextAttr($value, $data)
{
$value = $value ?: ($data['worker_refund_entry'] ?? '');
$list = $this->getWorkerRefundEntryList();
return $list[$value] ?? '';
}
public function order()
{
return $this->belongsTo('Order', 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}