From 4e2fcf669f0e157a42a33d0227e02a0e8e2d6d27 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 26 Sep 2024 17:21:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SystemStoreStorageController.php | 3 +++ .../store_branch_product/StoreBranchProduct.php | 12 ++++++++++-- app/common/model/store_order/StoreOrder.php | 12 +++++++++++- .../store_order_cart_info/StoreOrderCartInfo.php | 12 +++++++++++- app/common/model/store_product/StoreProduct.php | 12 ++++++++++-- app/common/model/user/User.php | 10 +++++++++- .../model/warehouse_product/WarehouseProduct.php | 12 +++++++++++- .../WarehouseProductStorege.php | 12 +++++++++++- 8 files changed, 76 insertions(+), 9 deletions(-) diff --git a/app/api/controller/system_store_storage/SystemStoreStorageController.php b/app/api/controller/system_store_storage/SystemStoreStorageController.php index 2aec9d636..c1e1fd1a1 100644 --- a/app/api/controller/system_store_storage/SystemStoreStorageController.php +++ b/app/api/controller/system_store_storage/SystemStoreStorageController.php @@ -37,6 +37,9 @@ class SystemStoreStorageController extends BaseApiController return $this->dataLists(new SystemStoreStorageGroupLists()); } + /** + * @notes 门店入库 + */ public function warehousing_add() { $params = $this->request->post(); $find=SystemStoreStorage::where('id',$params['id'])->find(); diff --git a/app/common/model/store_branch_product/StoreBranchProduct.php b/app/common/model/store_branch_product/StoreBranchProduct.php index ae0ad6b83..e03539d9e 100644 --- a/app/common/model/store_branch_product/StoreBranchProduct.php +++ b/app/common/model/store_branch_product/StoreBranchProduct.php @@ -41,10 +41,18 @@ class StoreBranchProduct extends BaseModel { return $this->hasOne(StoreProduct::class,'id','product_id'); } - + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find, $where),'branch_product','更新前'); + } catch (Throwable $e) { + Log::error('branch_product:' . $e->getMessage()); + } + } public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'branch_product','更新前'); channelLog($data->toArray(),'branch_product','更新后'); }catch(Throwable $e){ Log::error('branch_product:'.$e->getMessage()); diff --git a/app/common/model/store_order/StoreOrder.php b/app/common/model/store_order/StoreOrder.php index 815958362..d87ac40fe 100644 --- a/app/common/model/store_order/StoreOrder.php +++ b/app/common/model/store_order/StoreOrder.php @@ -101,9 +101,19 @@ class StoreOrder extends BaseModel ->group('days')->select()->toArray(); } + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find, $where),'store_order','更新前'); + } catch (Throwable $e) { + Log::error('store_order:' . $e->getMessage()); + } + } + public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'store_order','更新前'); channelLog($data->toArray(),'store_order','更新后'); }catch(Throwable $e){ Log::error('store_order:'.$e->getMessage()); diff --git a/app/common/model/store_order_cart_info/StoreOrderCartInfo.php b/app/common/model/store_order_cart_info/StoreOrderCartInfo.php index 93b2b3518..677c9a710 100644 --- a/app/common/model/store_order_cart_info/StoreOrderCartInfo.php +++ b/app/common/model/store_order_cart_info/StoreOrderCartInfo.php @@ -21,9 +21,19 @@ class StoreOrderCartInfo extends BaseModel return $this->hasOne(StoreBranchProduct::class,'id','product_id')->bind(['store_name','image','unit','price']); } + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find, $where),'store_order_cart_info','更新前'); + } catch (Throwable $e) { + Log::error('store_order_cart_info:' . $e->getMessage()); + } + } + public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'store_order_cart_info','更新前'); channelLog($data->toArray(),'store_order_cart_info','更新后'); }catch(Throwable $e){ Log::error('store_order_cart_info:'.$e->getMessage()); diff --git a/app/common/model/store_product/StoreProduct.php b/app/common/model/store_product/StoreProduct.php index ddcfe97e9..8d95ef264 100644 --- a/app/common/model/store_product/StoreProduct.php +++ b/app/common/model/store_product/StoreProduct.php @@ -33,10 +33,18 @@ class StoreProduct extends BaseModel return $this->hasOne(StoreCategory::class,'id','cate_id')->bind(['class_name'=>'name']); } - + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find, $where),'product','更新前'); + } catch (Throwable $e) { + Log::error('product:' . $e->getMessage()); + } + } public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'product','更新前'); channelLog($data->toArray(),'product','更新后'); }catch(Throwable $e){ Log::error('product:'.$e->getMessage()); diff --git a/app/common/model/user/User.php b/app/common/model/user/User.php index 704b7ed2a..8d615a728 100644 --- a/app/common/model/user/User.php +++ b/app/common/model/user/User.php @@ -197,9 +197,17 @@ class User extends BaseModel })->field("FROM_UNIXTIME($create_time,'$timeType') as days,count(id) as num")->group('days')->select()->toArray(); } + public static function onBeforeWrite($data){ + try{ + $where=$data->getWhere(); + $find=self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find,$where),'user','更新前'); + }catch(Throwable $e){ + Log::error('user:'.$e->getMessage()); + } + } public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'user','更新前'); channelLog($data->toArray(),'user','更新后'); }catch(Throwable $e){ Log::error('user:'.$e->getMessage()); diff --git a/app/common/model/warehouse_product/WarehouseProduct.php b/app/common/model/warehouse_product/WarehouseProduct.php index 24e61c73e..7ca934e18 100644 --- a/app/common/model/warehouse_product/WarehouseProduct.php +++ b/app/common/model/warehouse_product/WarehouseProduct.php @@ -19,9 +19,19 @@ class WarehouseProduct extends BaseModel protected $name = 'warehouse_product'; protected $deleteTime = 'delete_time'; + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find, $where),'warehouse_product','更新前'); + } catch (Throwable $e) { + Log::error('warehouse_product:' . $e->getMessage()); + } + } + public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'warehouse_product','更新前'); channelLog($data->toArray(),'warehouse_product','更新后'); }catch(Throwable $e){ Log::error('warehouse_product:'.$e->getMessage()); diff --git a/app/common/model/warehouse_product_storege/WarehouseProductStorege.php b/app/common/model/warehouse_product_storege/WarehouseProductStorege.php index 9d86d6924..e120dcf09 100644 --- a/app/common/model/warehouse_product_storege/WarehouseProductStorege.php +++ b/app/common/model/warehouse_product_storege/WarehouseProductStorege.php @@ -18,10 +18,20 @@ class WarehouseProductStorege extends BaseModel use SoftDelete; protected $name = 'warehouse_product_storege'; protected $deleteTime = 'delete_time'; + + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find, $where), 'warehouse_product_storege', '更新前'); + } catch (Throwable $e) { + Log::error('warehouse_product_storege:' . $e->getMessage()); + } + } public static function onAfterWrite($data) { try { - channelLog($data->getOrigin(), 'warehouse_product_storege', '更新前'); channelLog($data->toArray(), 'warehouse_product_storege', '更新后'); } catch (Throwable $e) { Log::error('warehouse_product_storege:' . $e->getMessage());