From e58b0fbac58c232ac1b9b19c80c02ee1dc83804b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 28 Sep 2024 15:32:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0`onBeforeWrite`?= =?UTF-8?q?=E5=92=8C`onAfterWrite`=E6=96=B9=E6=B3=95=E5=9C=A8`StoreFinance?= =?UTF-8?q?Flow`=E5=92=8C`SystemStore`=E6=A8=A1=E5=9E=8B=E4=B8=AD=E4=BB=A5?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=9B=B4=E6=96=B0=E5=89=8D=E5=90=8E=E7=9A=84?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store_finance_flow/StoreFinanceFlow.php | 16 ++++++++++++++-- app/common/model/system_store/SystemStore.php | 16 +++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/app/common/model/store_finance_flow/StoreFinanceFlow.php b/app/common/model/store_finance_flow/StoreFinanceFlow.php index 38f79b90c..c1e701280 100644 --- a/app/common/model/store_finance_flow/StoreFinanceFlow.php +++ b/app/common/model/store_finance_flow/StoreFinanceFlow.php @@ -36,10 +36,22 @@ class StoreFinanceFlow extends BaseModel { return $this->hasOne(SystemStoreStaff::class, 'id', 'staff_id')->bind(['staff_name']); } - + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + if($data){ + $find = self::where($where)->field(array_keys($data->toArray()))->find(); + if($find){ + channelLog(array_merge($find->toArray(),$where),'store_finance_flow','更新前'); + } + } + } catch (Throwable $e) { + Log::error('store_finance_flow:' . $e->getMessage()); + } + } public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'store_finance_flow','更新前'); channelLog($data->toArray(),'store_finance_flow','更新后'); }catch(Throwable $e){ Log::error('store_finance_flow:'.$e->getMessage()); diff --git a/app/common/model/system_store/SystemStore.php b/app/common/model/system_store/SystemStore.php index ff209e545..320d93f30 100644 --- a/app/common/model/system_store/SystemStore.php +++ b/app/common/model/system_store/SystemStore.php @@ -19,9 +19,23 @@ class SystemStore extends BaseModel protected $name = 'system_store'; protected $deleteTime = 'delete_time'; + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + if($data){ + $find = self::where($where)->field(array_keys($data->toArray()))->find(); + if($find){ + channelLog(array_merge($find->toArray(),$where),'system_store','更新前'); + } + } + } catch (Throwable $e) { + Log::error('system_store:' . $e->getMessage()); + } + } + public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'system_store','更新前'); channelLog($data->toArray(),'system_store','更新后'); }catch(Throwable $e){ Log::error('system_store:'.$e->getMessage());