refactor(model): 移除门店、仓库和库存模型中的日志记录钩子
- 删除了 StoreBranchProduct、WarehouseProduct 和 WarehouseProductStorege 模型中的 onBeforeWrite 和 onAfterWrite 钩子方法 - 移除了用于记录更新前后日志的代码 - 简化了模型结构,提高了代码可读性和性能
This commit is contained in:
parent
788a8cb211
commit
03cc208b1d
@ -68,25 +68,4 @@ class StoreBranchProduct extends BaseModel
|
||||
{
|
||||
return $this->hasOne(StoreProduct::class,'id','product_id');
|
||||
}
|
||||
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),'branch_product','更新前');
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::error('branch_product:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public static function onAfterWrite($data){
|
||||
try{
|
||||
channelLog($data->toArray(),'branch_product','更新后');
|
||||
}catch(Throwable $e){
|
||||
Log::error('branch_product:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -46,26 +46,4 @@ class WarehouseProduct extends BaseModel
|
||||
'create_time',
|
||||
'update_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),'warehouse_product','更新前');
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::error('warehouse_product:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAfterWrite($data){
|
||||
try{
|
||||
channelLog($data->toArray(),'warehouse_product','更新后');
|
||||
}catch(Throwable $e){
|
||||
Log::error('warehouse_product:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -23,26 +23,4 @@ class WarehouseProductStorege extends BaseModel
|
||||
'total_price',
|
||||
'update_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), 'warehouse_product_storege', '更新前');
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::error('warehouse_product_storege:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public static function onAfterWrite($data)
|
||||
{
|
||||
try {
|
||||
channelLog($data->toArray(), 'warehouse_product_storege', '更新后');
|
||||
} catch (Throwable $e) {
|
||||
Log::error('warehouse_product_storege:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user