dispatch 日志

This commit is contained in:
xman 2025-03-31 11:15:08 +08:00
parent a36fd9805f
commit 7a4bafcc12
2 changed files with 49 additions and 1 deletions

View File

@ -4,6 +4,7 @@ namespace app\admin\controller\orders;
use app\admin\model\Order;
use app\admin\model\OrderDispatch;
use app\admin\model\OrderDispatchLog;
use app\common\controller\Backend;
use app\common\Logic\OrderLogic;
use think\Db;
@ -229,8 +230,19 @@ class Dispatch2 extends Backend
$row->validateFailException()->validate($validate);
}
if($row->worker_id != $params['worker_id']){ //更换了师傅
$worker = model('worker')->where('id',$params['worker_id'])->find();
$params ['worker_name'] = $worker->name;
$params ['worker_tel'] = $worker->tel;
//记录日志
OrderDispatchLog::create([
'dispatch_id' => $row->id,
'order_id' => $row->order_id,
'worker_id' => $params['worker_id'],
'status' => $row->status,
'status_text' => $this->model->getStatusList()[$row->status],
'remark' => '师傅由 ('.$row->worker_id.')'.$row->worker_name.' 更换为('.$params['worker_id'].')'.$worker->name
]);
}
$result = $row->allowField(true)->save($params);

View File

@ -0,0 +1,36 @@
<?php
namespace app\admin\model;
use think\Model;
class OrderDispatchLog extends Model
{
// 表名
protected $name = 'order_dispatch_log';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
protected $dateFormat = 'Y-m-d H:i:s';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'order_status_text'
];
}