feat: 增加onBeforeWrite
和onAfterWrite
方法在StoreFinanceFlow
和SystemStore
模型中以记录更新前后的日志
This commit is contained in:
parent
2a17dde78d
commit
e58b0fbac5
@ -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());
|
||||
|
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user