添加日志

This commit is contained in:
xman 2025-04-14 10:32:08 +08:00
parent 25f1c91271
commit 4da8536a47

View File

@ -12,6 +12,7 @@ use fast\Tree;
use think\Db; use think\Db;
use think\exception\PDOException; use think\exception\PDOException;
use think\exception\ValidateException; use think\exception\ValidateException;
use think\Hook;
use think\Model; use think\Model;
use function Symfony\Component\Clock\now; use function Symfony\Component\Clock\now;
@ -208,6 +209,14 @@ class Order extends Backend
$params['update_time'] = date('Y-m-d H:i:s'); $params['update_time'] = date('Y-m-d H:i:s');
$result = $this->model->allowField(true)->save($params); $result = $this->model->allowField(true)->save($params);
//日志
$hookparams['order'] = $this->model;
$hookparams['role'] = 1;
$hookparams['auth'] = $this->auth;
$hookparams['remark'] = $params['remark']??'';
Hook::listen('order_change', $hookparams);
if ($params['dispatch_type'] == 2) { if ($params['dispatch_type'] == 2) {
$this->autoDispatch($this->model); $this->autoDispatch($this->model);
} }
@ -367,6 +376,15 @@ class Order extends Backend
(new OrderDispatch())->allowField(true)->save($insert); (new OrderDispatch())->allowField(true)->save($insert);
$order->status = \app\admin\model\Order::STATUS_DISPATCHED; $order->status = \app\admin\model\Order::STATUS_DISPATCHED;
$order->save(); $order->save();
//日志
$hookparams['order'] = $order;
$hookparams['role'] = 1;
$hookparams['auth'] = $this->auth;
$hookparams['remark'] = $params['remark']??'';
Hook::listen('order_change', $hookparams);
return true; return true;
} }
@ -460,6 +478,14 @@ class Order extends Backend
} }
$params['status'] = \app\admin\model\Order::STATUS_CANCEL; $params['status'] = \app\admin\model\Order::STATUS_CANCEL;
$result = $order->allowField(true)->save($params); $result = $order->allowField(true)->save($params);
//日志
$hookparams['order'] = $order;
$hookparams['role'] = 1;
$hookparams['auth'] = $this->auth;
$hookparams['remark'] = $params['remark']??'';
Hook::listen('order_change', $hookparams);
Db::commit(); Db::commit();
} catch (ValidateException | PDOException | Exception $e) { } catch (ValidateException | PDOException | Exception $e) {
Db::rollback(); Db::rollback();