82 lines
1.9 KiB
PHP
82 lines
1.9 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace plugin\produce\app\model;
|
||
|
|
|
||
|
|
class ExceptionRecord extends BaseModel
|
||
|
|
{
|
||
|
|
protected $table = 'produce_exception_record';
|
||
|
|
|
||
|
|
protected $appends = ['reported_date', 'handled_date', 'status_name'];
|
||
|
|
|
||
|
|
protected static function booted(): void
|
||
|
|
{
|
||
|
|
static::creating(function (self $model) {
|
||
|
|
if (empty($model->reported_at)) {
|
||
|
|
$model->reported_at = time();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'id',
|
||
|
|
'order_no',
|
||
|
|
'user_code',
|
||
|
|
'reporter',
|
||
|
|
'reporter_id',
|
||
|
|
'type_id',
|
||
|
|
'type_code',
|
||
|
|
'type_name',
|
||
|
|
'reason_id',
|
||
|
|
'reason_code',
|
||
|
|
'reason_name',
|
||
|
|
'issue_id',
|
||
|
|
'issue_code',
|
||
|
|
'issue_name',
|
||
|
|
'images',
|
||
|
|
'remark',
|
||
|
|
'status',
|
||
|
|
'handler',
|
||
|
|
'handler_id',
|
||
|
|
'handled_at',
|
||
|
|
'reported_at',
|
||
|
|
'created_by',
|
||
|
|
'updated_by',
|
||
|
|
'created_at',
|
||
|
|
'updated_at',
|
||
|
|
'deleted_at',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'images' => 'array',
|
||
|
|
'status' => 'integer',
|
||
|
|
'handled_at' => 'integer',
|
||
|
|
'reported_at' => 'integer',
|
||
|
|
'created_by' => 'integer',
|
||
|
|
'updated_by' => 'integer',
|
||
|
|
'created_at' => 'integer',
|
||
|
|
'updated_at' => 'integer',
|
||
|
|
'deleted_at' => 'integer',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function getReportedDateAttribute(): ?string
|
||
|
|
{
|
||
|
|
return $this->reported_at ? date('Y-m-d H:i:s', (int) $this->reported_at) : null;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getHandledDateAttribute(): ?string
|
||
|
|
{
|
||
|
|
return $this->handled_at ? date('Y-m-d H:i:s', (int) $this->handled_at) : null;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getStatusNameAttribute(): string
|
||
|
|
{
|
||
|
|
return match ((int) $this->status) {
|
||
|
|
1 => '处理中',
|
||
|
|
2 => '已处理',
|
||
|
|
default => '待处理',
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|