Przeglądaj źródła

[智价云] 增加操作日志记录

tangyuanwang 2 miesięcy temu
rodzic
commit
1c673b9fb2

+ 28 - 22
app/Http/Controllers/Controller.php

@@ -1,8 +1,11 @@
-<?php namespace App\Http\Controllers;
+<?php
+
+namespace App\Http\Controllers;
 
 // 基础控制器
 use App\Models\Manager\AdminHistory;
 use Illuminate\Routing\Controller as BaseController;
+
 /**
  * 控制器总控
  * 
@@ -10,49 +13,52 @@ use Illuminate\Routing\Controller as BaseController;
 class Controller extends BaseController
 {
     /**
-	 * 构造方法,初始化
-	 * 
-	 * */
-	public function __construct(){
-		// 初始化
-		if( method_exists($this, '_initialize') ) $this->_initialize();
-		// 初始化
-		if( method_exists($this, '__init') ) $this->__init();
-	}
+     * 构造方法,初始化
+     * 
+     * */
+    public function __construct()
+    {
+        // 初始化
+        if (method_exists($this, '_initialize')) $this->_initialize();
+        // 初始化
+        if (method_exists($this, '__init')) $this->__init();
+    }
 
 
-	/**
+    /**
      * 操作错误跳转的快捷方法
      * @param  Mixed     $msg 提示信息
      * @param  String    $url 跳转的URL地址
      * @param  Int   $wait 跳转等待时间
-	 * 
+     * 
      * @return Void
      */
     protected function error($msg = '', $url = null, $wait = 3)
-	{
-		if ( is_null($url) ) {
+    {
+        if (is_null($url)) {
             $url = request()->ajax() ? '' : 'javascript:history.back(-1);';
         } elseif ('' !== $url) {
             $url = (strpos($url, '://') || 0 === strpos($url, '/')) ? $url : url($url);
         }
-		// 返回结果
-		return		view('error',['msg'=>$msg,'url'=>$url,'wait'=>$wait]);
-	}
+        // 返回结果
+        return        view('error', ['msg' => $msg, 'url' => $url, 'wait' => $wait]);
+    }
     /**
      * 保存用户操作历史
-     *
+     * @param   String      $admin_menu_name       模块菜单名称
      * @param   Int         $uid        用户ID
      * @param   String      $table      操作表
-     * @param   Int         $type       操作类型
+     * @param   Int         $type       操作类型,1添加,2修改,3=删除
      * @param   Array       $oldData    旧数据
      * @param   Array       $oldData    新数据
+     * @param   String       $general_description    操作描述
      *
      */
-    protected function addAdminHistory($uid,$table,$id,$type,$oldData,$newData) {
+    protected function addAdminHistory($admin_menu_name, $uid, $table, $type, $oldData, $newData, $general_description ='')
+    {
         //记录详细操作历史
-        $AdminHistory			= (new AdminHistory());
+        $AdminHistory            = (new AdminHistory());
         // 记录数据
-        $AdminHistory->addAll($uid,$table,$id,$type,$oldData,$newData);
+        $AdminHistory->addAll($admin_menu_name, $uid, $table, $type, $oldData, $newData, $general_description);
     }
 }

+ 37 - 8
app/Http/Controllers/Manager/Personnel/Department.php

@@ -120,6 +120,11 @@ class Department extends Controller
         $result     =  $DepartmentModel->addDepartment($all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '新增失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $DepartmentModel->getTable();
+        $notes_type = 1; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('人员信息管理-部门管理', $admin_id, $table_name, $notes_type, [], $all_data, '新增了部门' . $all_data['name'] . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '新增成功']);
     }
@@ -140,15 +145,22 @@ class Department extends Controller
         $all_data = request()->all();
         $store_scope = request('store_scope', '');
         $all_data['store_scope'] = $store_scope;
+        $where = ['id' => $id];
+        $Department = $DepartmentModel->where($where)->first();
+        if (!$Department) return json_send(['code' => 'error', 'msg' => '记录不存在']);
         //查询是否存在
         $map = ['name' => $all_data['name']];
         $data = $DepartmentModel->where($map)->where('id', '!=', $id)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 更新数据表
-        $where = ['id' => $id];
-        $result =  $DepartmentModel->updateDepartment($where, $all_data);
+        $result =  $DepartmentModel->editDepartment_content($Department, $all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '修改失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $DepartmentModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('人员信息管理-部门管理', $admin_id, $table_name, $notes_type, $Department->toArray(), $all_data, '修改了部门' . $Department->name . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '修改成功']);
     }
@@ -160,7 +172,7 @@ class Department extends Controller
      * @date      2025-12-04
      * 
      */
-    public function set_status(Request $request, DepartmentModel $DepartmentModel,EmployeeModel $EmployeeModel)
+    public function set_status(Request $request, DepartmentModel $DepartmentModel, EmployeeModel $EmployeeModel)
     {
         // 验证参数
         $request->scene('set_status')->validate();
@@ -176,9 +188,18 @@ class Department extends Controller
         // 查询用户
         $where = ['id' => $id];
         // 执行修改
-        $result            =  $DepartmentModel->changeStatus($where, $status);
+        $Department = $DepartmentModel->where($where)->first();
+        if (!$Department) return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        $Department->status = $status;
+        $Department->update_time = time();
+        $result = $Department->save();
         // 提示新增失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '设置失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $DepartmentModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('人员信息管理-部门管理', $admin_id, $table_name, $notes_type, [], ['status' => $status], '修改了部门' . $Department->name . '状态');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '设置成功']);
     }
@@ -191,22 +212,30 @@ class Department extends Controller
      * @date      2025-12-04
      * 
      */
-    public function delete(Request $request, DepartmentModel $DepartmentModel,EmployeeModel $EmployeeModel)
+    public function delete(Request $request, DepartmentModel $DepartmentModel, EmployeeModel $EmployeeModel)
     {
         // 验证参数
         $request->scene('delete')->validate();
         // 接收数据
         $id = request('id', 0);
         // 查询部门下是否有员工
-        $map = ['department_id' => $id];
+        $map = ['department_ids' => $id];
         $data = $EmployeeModel->where($map)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '该部门下存在员工,不能删除']);
         // 查询用户
         $where = ['id' => $id];
-        // 执行删除
-        $result =  $DepartmentModel->deleteDepartment($where);
+        $Department = $DepartmentModel->where($where)->first();
+        if (!$Department) {
+            return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        }
+        $result = $Department->delete();
         // 提示删除失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '删除失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $DepartmentModel->getTable();
+        $notes_type = 3; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('人员信息管理-部门管理', $admin_id, $table_name, $notes_type, $Department->toArray(), [], '删除了部门' . $Department->name . '信息');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '删除成功']);
     }

+ 41 - 9
app/Http/Controllers/Manager/Personnel/Employee.php

@@ -90,8 +90,8 @@ class Employee extends Controller
         if (isset($result['data']) && count($result['data']) > 0) {
             foreach ($result['data'] as $key => $value) {
                 //查询部门信息
-                $department_ids = $value['department_ids'] !='' ? explode(',',$value['department_ids']):'';
-                $department_name = $department_ids ? $DepartmentModel->whereIn('id',$department_ids)->pluck('name')->toarray():'';
+                $department_ids = $value['department_ids'] != '' ? explode(',', $value['department_ids']) : '';
+                $department_name = $department_ids ? $DepartmentModel->whereIn('id', $department_ids)->pluck('name')->toarray() : '';
                 //查询角色信息
                 $role_info = $RolesModel->where(['id' => $value['role_id']])->first();
                 //查询城市信息
@@ -116,7 +116,7 @@ class Employee extends Controller
      * @date      2025-12-12
      * 
      */
-    public function all(Request $request, EmployeeModel $EmployeeModel,RolesModel $RolesModel,EmployeeAreaModel $EmployeeAreaModel, EmployeeDepartmentModel $EmployeeDepartmentModel)
+    public function all(Request $request, EmployeeModel $EmployeeModel, RolesModel $RolesModel, EmployeeAreaModel $EmployeeAreaModel, EmployeeDepartmentModel $EmployeeDepartmentModel)
     {
         $request->scene('all')->validate();
         // 查询条件
@@ -149,7 +149,7 @@ class Employee extends Controller
         if ($role_name) {
             $role_ids = $RolesModel->where('name', 'like', "%$role_name%")->pluck('id')->toarray();
         }
-        $field = ['id','name'];
+        $field = ['id', 'name'];
         // 查询数据
         if ($role_name) {
             $EmployeeModel = $EmployeeModel->whereIn('role_id', $role_ids);
@@ -198,7 +198,7 @@ class Employee extends Controller
         if (!$data)     return json_send(['code' => 'error', 'msg' => '记录不存在']);
         // 查询部门信息
         $department_ids = explode(',', $data['department_ids']);
-        $department_info = $DepartmentModel->whereIn('id',$department_ids)->select(['id','name'])->get()->toarray();
+        $department_info = $DepartmentModel->whereIn('id', $department_ids)->select(['id', 'name'])->get()->toarray();
         // 查询角色信息
         $role_info = $RolesModel->where(['id' => $data['role_id']])->first();
         // 查询城市信息
@@ -241,6 +241,11 @@ class Employee extends Controller
         $result     =  $EmployeeModel->addEmployee($all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '新增失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $EmployeeModel->getTable();
+        $notes_type = 1; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('人员信息管理-员工管理', $admin_id, $table_name, $notes_type, [], $all_data, '新增了员工' . $all_data['name'] . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '新增成功']);
     }
@@ -264,6 +269,9 @@ class Employee extends Controller
         $city_ids =  request('city_ids', '');
         $all_data['city_ids'] = $city_ids;
         $all_data['password'] = request('password', '');
+        $where = ['id' => $id];
+        $Employee = $EmployeeModel->where($where)->first();
+        if (!$Employee) return json_send(['code' => 'error', 'msg' => '记录不存在']);
         //查询是否存在
         $map = ['name' => $all_data['name']];
         $data = $EmployeeModel->where($map)->where('id', '!=', $id)->first();
@@ -272,10 +280,14 @@ class Employee extends Controller
         $data = $EmployeeModel->where($map)->where('id', '!=', $id)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '员工手机号记录已存在']);
         // 更新数据表
-        $where = ['id' => $id];
-        $result =  $EmployeeModel->updateEmployee($where, $all_data);
+        $result =  $EmployeeModel->updateEmployee($Employee, $all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '修改失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $EmployeeModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('人员信息管理-员工管理', $admin_id, $table_name, $notes_type, $Employee->toarray(), $all_data, '修改了员工' . $Employee->name . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '修改成功']);
     }
@@ -297,9 +309,20 @@ class Employee extends Controller
         // 查询用户
         $where = ['id' => $id];
         // 执行修改
-        $result            =  $EmployeeModel->changeStatus($where, $status);
+        $Employee = $EmployeeModel->where($where)->first();
+        if (!$Employee) {
+            return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        }
+        $Employee->status = $status;
+        $Employee->update_time = time();
+        $result = $Employee->save();
         // 提示新增失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '设置失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $EmployeeModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('人员信息管理-员工管理', $admin_id, $table_name, $notes_type, [], ['status' => $status], '修改了员工' . $Employee->name . '状态');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '设置成功']);
     }
@@ -321,9 +344,18 @@ class Employee extends Controller
         // 查询用户
         $where = ['id' => $id];
         // 执行删除
-        $result =  $EmployeeModel->deleteEmployee($where);
+        $Employee = $EmployeeModel->where($where)->first();
+        if (!$Employee) {
+            return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        }
+        $result = $Employee->delete();
         // 提示删除失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '删除失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $EmployeeModel->getTable();
+        $notes_type = 3; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('人员信息管理-员工管理', $admin_id, $table_name, $notes_type, $Employee->toarray(), [], '删除了员工' . $Employee->name . '信息');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '删除成功']);
     }

+ 40 - 6
app/Http/Controllers/Manager/Personnel/Roles.php

@@ -120,6 +120,11 @@ class Roles extends Controller
         $result     =  $RolesModel->addRoles($all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '新增失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $RolesModel->getTable();
+        $notes_type = 1; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('人员信息管理-角色管理', $admin_id, $table_name, $notes_type, [], $all_data, '新增了角色' . $all_data['name'] . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '新增成功']);
     }
@@ -146,9 +151,18 @@ class Roles extends Controller
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 更新数据表
         $where = ['id' => $id];
-        $result =  $RolesModel->updateRoles($where, $all_data);
+        $Roles = $RolesModel->where($where)->first();
+        if (!$Roles) {
+            return json_send(['code' => 'error', 'msg' => '记录不存在']);;
+        }
+        $result =  $RolesModel->editRoles_content($Roles, $all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '修改失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $RolesModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('人员信息管理-角色管理', $admin_id, $table_name, $notes_type, $Roles->toarray(), $all_data, '修改了角色' . $Roles->name . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '修改成功']);
     }
@@ -160,14 +174,14 @@ class Roles extends Controller
      * @date      2025-12-05
      * 
      */
-    public function set_status(Request $request, RolesModel $RolesModel,EmployeeModel $EmployeeModel)
+    public function set_status(Request $request, RolesModel $RolesModel, EmployeeModel $EmployeeModel)
     {
         // 验证参数
         $request->scene('set_status')->validate();
         // 接收数据
         $id                = request('id', 0);
         $status            = request('status', 0);
-        if($status == 1){
+        if ($status == 1) {
             // 查询是否有员工使用该角色
             $employee_data = $EmployeeModel->where('role_id', $id)->first();
             if ($employee_data)    return json_send(['code' => 'error', 'msg' => '该角色已被使用,不能禁用']);
@@ -175,9 +189,20 @@ class Roles extends Controller
         // 查询用户
         $where = ['id' => $id];
         // 执行修改
-        $result            =  $RolesModel->changeStatus($where, $status);
+        $Roles = $RolesModel->where($where)->first();
+        if (!$Roles) {
+            return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        }
+        $Roles->status = $status;
+        $Roles->update_time = time();
+        $result = $Roles->save();
         // 提示新增失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '设置失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $RolesModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('人员信息管理-角色管理', $admin_id, $table_name, $notes_type, [], ['status' => $status], '修改了角色' . $Roles->name . '状态');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '设置成功']);
     }
@@ -190,7 +215,7 @@ class Roles extends Controller
      * @date      2025-12-05
      * 
      */
-    public function delete(Request $request, RolesModel $RolesModel,EmployeeModel $EmployeeModel)
+    public function delete(Request $request, RolesModel $RolesModel, EmployeeModel $EmployeeModel)
     {
         // 验证参数
         $request->scene('delete')->validate();
@@ -204,9 +229,18 @@ class Roles extends Controller
         // 查询用户
         $where = ['id' => $id];
         // 执行删除
-        $result =  $RolesModel->deleteRoles($where);
+        $Roles = $RolesModel->where($where)->first();
+        if (!$Roles) {
+            return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        }
+        $result = $Roles->delete();
         // 提示删除失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '删除失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $RolesModel->getTable();
+        $notes_type = 3; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('人员信息管理-角色管理', $admin_id, $table_name, $notes_type, $Roles->toarray(), [], '删除了角色' . $Roles->name . '信息');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '删除成功']);
     }

+ 29 - 3
app/Http/Controllers/Manager/WashConfig/CompanyCategory.php

@@ -120,6 +120,11 @@ class CompanyCategory extends Controller
         $result     =  $CompanyCategoryModel->addCompanyCategory($all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '新增失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $CompanyCategoryModel->getTable();
+        $notes_type = 1; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-公司分类管理', $admin_id, $table_name, $notes_type,[],$all_data, '新增了分类' . $all_data['name'] . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '新增成功']);
     }
@@ -146,9 +151,16 @@ class CompanyCategory extends Controller
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 更新数据表
         $where = ['id' => $id];
-        $result =  $CompanyCategoryModel->updateCompanyCategory($where, $all_data);
+        $CompanyCategory = $CompanyCategoryModel->where($where)->first();
+        if (!$CompanyCategory) return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        $result =  $CompanyCategoryModel->editCompanyCategory_content($CompanyCategory, $all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '修改失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $CompanyCategoryModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-公司分类管理', $admin_id, $table_name, $notes_type,$CompanyCategory->toarray(),$all_data, '修改了分类' .$CompanyCategory->name . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '修改成功']);
     }
@@ -169,10 +181,17 @@ class CompanyCategory extends Controller
         $status            = request('status', 0);
         // 查询用户
         $where = ['id' => $id];
+        $CompanyCategory = $CompanyCategoryModel->where($where)->first();
+        if (!$CompanyCategory) return json_send(['code' => 'error', 'msg' => '记录不存在']);
         // 执行修改
-        $result            =  $CompanyCategoryModel->changeStatus($where, $status);
+        $result            =  $CompanyCategoryModel->changeStatus($CompanyCategory, $status);
         // 提示新增失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '设置失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $CompanyCategoryModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-公司分类管理', $admin_id, $table_name, $notes_type,[], ['status' => $status], '修改了分类' .$CompanyCategory->name . '状态');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '设置成功']);
     }
@@ -194,9 +213,16 @@ class CompanyCategory extends Controller
         // 查询用户
         $where = ['id' => $id];
         // 执行删除
-        $result =  $CompanyCategoryModel->deleteCompanyCategory($where);
+        $CompanyCategory = $CompanyCategoryModel->where($where)->first();
+        if (!$CompanyCategory) return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        $result = $CompanyCategory->delete();
         // 提示删除失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '删除失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $CompanyCategoryModel->getTable();
+        $notes_type = 3; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-公司分类管理', $admin_id, $table_name, $notes_type, $CompanyCategory->toArray(), [], '删除了分类' .$CompanyCategory->name . '信息');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '删除成功']);
     }

+ 59 - 19
app/Http/Controllers/Manager/WashConfig/LowPriceGoods.php

@@ -8,7 +8,7 @@ use App\Models\Manager\WashConfig\LowPriceGoods as LowPriceGoodsModel;
 use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
 use App\Models\Manager\WashConfig\LowPriceGoodsCompany as LowPriceGoodsCompanyModel;
 use App\Models\Manager\WashConfig\ProductCategory as ProductCategoryModel;
-
+use Illuminate\Support\Facades\DB;
 
 /**
  * 数据清洗-低价产品配置
@@ -46,8 +46,8 @@ class LowPriceGoods extends Controller
         if (is_numeric($status)) $map[] = ['status', '=', $status];
         if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
         if ($platform) $map[] = ['platform', 'like', "%$platform%"];
-        if ($store_scope) $map[] = ['store_scope', '=',$store_scope];
-        if ($company_scope) $map[] = ['company_scope', '=',$company_scope];
+        if ($store_scope) $map[] = ['store_scope', '=', $store_scope];
+        if ($company_scope) $map[] = ['company_scope', '=', $company_scope];
         if ($category_id) $map[] = ['category_id', '=', $category_id];
         // 查询数据
         $result = $LowPriceGoodsModel->query()
@@ -59,7 +59,7 @@ class LowPriceGoods extends Controller
         if (isset($result['data']) && count($result['data']) > 0) {
             foreach ($result['data'] as $key => $value) {
                 $result['data'][$key]['platform'] = isset($value['platform']) ? explode(',', $value['platform']) : '';
-                $category_name = $value['category_id'] > 0 ? $ProductCategoryModel->where('id', $value['category_id'])->value('name'):'';
+                $category_name = $value['category_id'] > 0 ? $ProductCategoryModel->where('id', $value['category_id'])->value('name') : '';
                 $result['data'][$key]['category_name'] = $category_name;
                 //查询店铺名称
                 if ($value['store_scope'] == '1') {
@@ -88,7 +88,7 @@ class LowPriceGoods extends Controller
      * @version   1.0
      * @date      2025-12-02
      */
-    public function detail(Request $request, LowPriceGoodsModel $LowPriceGoodsModel,LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel, ProductCategoryModel $ProductCategoryModel)
+    public function detail(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel, ProductCategoryModel $ProductCategoryModel)
     {
         $request->scene('detail')->validate();
         // 接收参数
@@ -105,7 +105,7 @@ class LowPriceGoods extends Controller
         //查询公司名称
         if ($data->company_scope == '1') {
             $data->company_name = ['全部公司'];
-            $data->company_ids ='';
+            $data->company_ids = '';
         } else {
             $company_data = $LowPriceGoodsCompanyModel->where('lowprice_product_logid', $data->id)
                 ->join('washconfig_violation_store', 'washconfig_violation_store.id', '=', 'washconfig_lowprice_product_company.company_id')
@@ -113,8 +113,8 @@ class LowPriceGoods extends Controller
             $data->company_name = !empty($company_data) ? array_column($company_data, 'company_name') : '';
             $data->company_ids = !empty($company_data) ? array_column($company_data, 'company_id') : '';
         }
-        $data->platform = isset($data->platform) ? explode(',',$data->platform) : '';
-        $data->category_name = $data->category_id > 0 ? $ProductCategoryModel->where('id', $data->category_id)->value('name'):'';
+        $data->platform = isset($data->platform) ? explode(',', $data->platform) : '';
+        $data->category_name = $data->category_id > 0 ? $ProductCategoryModel->where('id', $data->category_id)->value('name') : '';
         // 加载模板
         return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $data]);
     }
@@ -144,8 +144,8 @@ class LowPriceGoods extends Controller
         $sampling_start_time = request('sampling_start_time', '');
         $sampling_end_time = request('sampling_end_time', '');
         $all_data['sampling_cycle'] = $sampling_cycle;
-        $all_data['sampling_start_time'] = strtotime($sampling_start_time.'00:00:00');
-        $all_data['sampling_end_time'] = strtotime($sampling_end_time.'23:59:59');
+        $all_data['sampling_start_time'] = strtotime($sampling_start_time . '00:00:00');
+        $all_data['sampling_end_time'] = strtotime($sampling_end_time . '23:59:59');
         //查询是否存在
         $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
         $data = $LowPriceGoodsModel->where($map)->first();
@@ -154,6 +154,11 @@ class LowPriceGoods extends Controller
         $result     =  $LowPriceGoodsModel->addLowProduct($all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '新增失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $LowPriceGoodsModel->getTable();
+        $notes_type = 1; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-低价商品管理', $admin_id, $table_name, $notes_type, [], $all_data, '新增了低价商品' . $all_data['product_name'] . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '新增成功']);
     }
@@ -185,17 +190,24 @@ class LowPriceGoods extends Controller
         $sampling_start_time = request('sampling_start_time', '');
         $sampling_end_time = request('sampling_end_time', '');
         $all_data['sampling_cycle'] = $sampling_cycle;
-        $all_data['sampling_start_time'] = strtotime($sampling_start_time.'00:00:00');
-        $all_data['sampling_end_time'] = strtotime($sampling_end_time.'23:59:59');
+        $all_data['sampling_start_time'] = strtotime($sampling_start_time . '00:00:00');
+        $all_data['sampling_end_time'] = strtotime($sampling_end_time . '23:59:59');
         //查询是否存在
         $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
         $data = $LowPriceGoodsModel->where($map)->where('id', '!=', $id)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 更新数据表
         $where = ['id' => $id];
-        $result =  $LowPriceGoodsModel->updateLowProduct($where, $all_data);
+        $LowProduct = $LowPriceGoodsModel->where($where)->first();
+        if (!$LowProduct) return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        $result =  $LowPriceGoodsModel->editLowProduct_content($LowProduct, $all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '修改失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $LowPriceGoodsModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-低价商品管理', $admin_id, $table_name, $notes_type, $LowProduct->toarray(), $all_data, '修改了低价商品' . $LowProduct->product_name . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '修改成功']);
     }
@@ -216,10 +228,17 @@ class LowPriceGoods extends Controller
         $status            = request('status', 0);
         // 查询用户
         $where = ['id' => $id];
+        $LowProduct = $LowPriceGoodsModel->where($where)->first();
+        if (!$LowProduct) return json_send(['code' => 'error', 'msg' => '记录不存在']);
         // 执行修改
-        $result            =  $LowPriceGoodsModel->changeStatus($where, $status);
+        $result            =  $LowPriceGoodsModel->changeStatus($LowProduct, $status);
         // 提示新增失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '设置失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $LowPriceGoodsModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-低价商品管理', $admin_id, $table_name, $notes_type, [], ['status' => $status], '修改了低价商品' . $LowProduct->product_name . '状态');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '设置成功']);
     }
@@ -241,10 +260,31 @@ class LowPriceGoods extends Controller
         // 查询用户
         $where = ['id' => $id];
         // 执行删除
-        $result =  $LowPriceGoodsModel->deleteLowProduct($where);
-        // 提示删除失败
-        if (!$result)    return json_send(['code' => 'error', 'msg' => '删除失败']);
-        // 告知结果
-        return             json_send(['code' => 'success', 'msg' => '删除成功']);
+        $LowProduct = $LowPriceGoodsModel->where($where)->first();
+        if (!$LowProduct) {
+            return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        }
+        DB::beginTransaction();
+        try {
+            $LowPriceGoodsCompanyModel = new LowPriceGoodsCompanyModel();
+            $company_id_log = $LowPriceGoodsCompanyModel->where('lowprice_product_logid', $LowProduct->id)->get();
+            if (!empty($company_id_log)) {
+                $LowPriceGoodsCompanyModel->where('lowprice_product_logid', $LowProduct->id)->delete();
+            }
+            $LowProduct->delete();
+            // 记录行为
+            $admin_id   = request('access_token.uid', 0); //用户ID
+            $table_name = $LowPriceGoodsModel->getTable();
+            $notes_type = 3; //操作类型,1添加,2修改,3=删除
+            $this->addAdminHistory('清洗配置-低价商品管理', $admin_id, $table_name, $notes_type, $LowProduct->toarray(), [], '删除了低价商品' . $LowProduct->product_name . '状态');
+            DB::commit();
+            // 告知结果
+            return             json_send(['code' => 'success', 'msg' => '删除成功']);
+            // 成功处理...
+        } catch (\Exception $e) {
+            DB::rollBack();
+            // 错误处理...
+            return json_send(['code' => 'error', 'msg' => '删除失败']);
+        }
     }
 }

+ 31 - 3
app/Http/Controllers/Manager/WashConfig/ProductCategory.php

@@ -118,6 +118,11 @@ class ProductCategory extends Controller
         $result     =  $ProductCategoryModel->addProductCategory($all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '新增失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $ProductCategoryModel->getTable();
+        $notes_type = 1; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-商品分类管理', $admin_id, $table_name,$notes_type, [], $all_data, '新增了商品分类' . $all_data['name'] . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '新增成功']);
     }
@@ -144,9 +149,16 @@ class ProductCategory extends Controller
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 更新数据表
         $where = ['id' => $id];
-        $result =  $ProductCategoryModel->updateProductCategory($where, $all_data);
+        $ProductCategory = $ProductCategoryModel->where($where)->first();
+        if (!$ProductCategory) return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        $result =  $ProductCategoryModel->editProductCategory_content($ProductCategory, $all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '修改失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $ProductCategoryModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-商品分类管理', $admin_id, $table_name, $notes_type, $ProductCategory->toarray(), $all_data, '修改了商品分类' . $ProductCategory->name . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '修改成功']);
     }
@@ -167,10 +179,17 @@ class ProductCategory extends Controller
         $status            = request('status', 0);
         // 查询用户
         $where = ['id' => $id];
+        $ProductCategory = $ProductCategoryModel->where($where)->first();
+        if (!$ProductCategory) return json_send(['code' => 'error', 'msg' => '记录不存在']);
         // 执行修改
-        $result            =  $ProductCategoryModel->changeStatus($where, $status);
+        $result            =  $ProductCategoryModel->changeStatus($ProductCategory, $status);
         // 提示新增失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '设置失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $ProductCategoryModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-商品分类管理', $admin_id, $table_name, $notes_type, [], ['status' => $status], '修改了商品分类' . $ProductCategory->name . '状态');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '设置成功']);
     }
@@ -192,9 +211,18 @@ class ProductCategory extends Controller
         // 查询用户
         $where = ['id' => $id];
         // 执行删除
-        $result =  $ProductCategoryModel->deleteProductCategory($where);
+        $ProductCategory = $ProductCategoryModel->where($where)->first();
+        if (!$ProductCategory) {
+            return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        }
+        $result = $ProductCategory->delete();
         // 提示删除失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '删除失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $ProductCategoryModel->getTable();
+        $notes_type = 3; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-商品分类管理', $admin_id, $table_name, $notes_type, $ProductCategory->toarray(), [], '删除了商品分类' . $ProductCategory->name . '信息');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '删除成功']);
     }

+ 77 - 36
app/Http/Controllers/Manager/WashConfig/ViolationProduct.php

@@ -8,6 +8,7 @@ use App\Models\Manager\WashConfig\ViolationProduct as ViolationProductModel;
 use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
 use App\Models\Manager\WashConfig\ViolationProductCompany as ViolationProductCompanyModel;
 use App\Models\Manager\WashConfig\ProductCategory as ProductCategoryModel;
+use Illuminate\Support\Facades\DB;
 
 /**
  * 数据清洗-违规产品配置
@@ -24,7 +25,7 @@ class ViolationProduct extends Controller
      * @date      2025-12-03
      * 
      */
-    public function list(Request $request, ViolationProductModel $ViolationProductModel,ViolationStoreModel $ViolationStoreModel,ViolationProductCompanyModel $ViolationProductCompanyModel, ProductCategoryModel $ProductCategoryModel)
+    public function list(Request $request, ViolationProductModel $ViolationProductModel, ViolationStoreModel $ViolationStoreModel, ViolationProductCompanyModel $ViolationProductCompanyModel, ProductCategoryModel $ProductCategoryModel)
     {
         $request->scene('list')->validate();
         // 查询条件
@@ -45,8 +46,8 @@ class ViolationProduct extends Controller
         if (is_numeric($status)) $map[] = ['status', '=', $status];
         if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
         if ($platform) $map[] = ['platform', 'like', "%$platform%"];
-        if ($store_scope) $map[] = ['store_scope', '=',$store_scope];
-        if ($company_scope) $map[] = ['company_scope', '=',$company_scope];
+        if ($store_scope) $map[] = ['store_scope', '=', $store_scope];
+        if ($company_scope) $map[] = ['company_scope', '=', $company_scope];
         if ($category_id) $map[] = ['category_id', '=', $category_id];
         // 查询数据
         $result = $ViolationProductModel->query()
@@ -55,25 +56,25 @@ class ViolationProduct extends Controller
             ->paginate($limit)->toarray();
         // 分配数据
         if (!$result)  return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => []]);
-        if(isset($result['data']) && count($result['data']) > 0){
+        if (isset($result['data']) && count($result['data']) > 0) {
             foreach ($result['data'] as $key => $value) {
-                 $result['data'][$key]['platform'] = isset($value['platform']) ? explode(',',$value['platform']) : '';
-                 $category_name = $value['category_id'] > 0 ? $ProductCategoryModel->where('id', $value['category_id'])->value('name'):'';
-                 $result['data'][$key]['category_name'] = $category_name;
+                $result['data'][$key]['platform'] = isset($value['platform']) ? explode(',', $value['platform']) : '';
+                $category_name = $value['category_id'] > 0 ? $ProductCategoryModel->where('id', $value['category_id'])->value('name') : '';
+                $result['data'][$key]['category_name'] = $category_name;
                 //查询店铺名称
-                if(trim($value['store_scope']) == ''){
-                    $result['data'][$key]['store_name'] =['全部店铺'];
-                }else{
+                if (trim($value['store_scope']) == '') {
+                    $result['data'][$key]['store_name'] = ['全部店铺'];
+                } else {
                     $result['data'][$key]['store_name'] = '';
                 }
                 //查询公司名称
-                if($value['company_scope'] == '1'){
-                    $result['data'][$key]['company_name'] =['全部公司'];
-                }else{
-                    $company_data = $ViolationProductCompanyModel->where('violation_product_logid',$value['id'])
-                    ->join('washconfig_violation_store', 'washconfig_violation_store.id', '=', 'washconfig_violation_product_company.company_id')
-                    ->select(['washconfig_violation_store.id','washconfig_violation_store.company_name','washconfig_violation_product_company.company_id'])->get()->toArray();
-                    $result['data'][$key]['company_name'] = !empty($company_data) ? array_column($company_data,'company_name') : '';
+                if ($value['company_scope'] == '1') {
+                    $result['data'][$key]['company_name'] = ['全部公司'];
+                } else {
+                    $company_data = $ViolationProductCompanyModel->where('violation_product_logid', $value['id'])
+                        ->join('washconfig_violation_store', 'washconfig_violation_store.id', '=', 'washconfig_violation_product_company.company_id')
+                        ->select(['washconfig_violation_store.id', 'washconfig_violation_store.company_name', 'washconfig_violation_product_company.company_id'])->get()->toArray();
+                    $result['data'][$key]['company_name'] = !empty($company_data) ? array_column($company_data, 'company_name') : '';
                 }
             }
         }
@@ -87,7 +88,7 @@ class ViolationProduct extends Controller
      * @version   1.0
      * @date      2025-12-03
      */
-    public function detail(Request $request, ViolationProductModel $ViolationProductModel,ViolationProductCompanyModel $ViolationProductCompanyModel, ProductCategoryModel $ProductCategoryModel)
+    public function detail(Request $request, ViolationProductModel $ViolationProductModel, ViolationProductCompanyModel $ViolationProductCompanyModel, ProductCategoryModel $ProductCategoryModel)
     {
         $request->scene('detail')->validate();
         // 接收参数
@@ -96,15 +97,15 @@ class ViolationProduct extends Controller
         $data = $ViolationProductModel->where($map)->first();
         if (!$data)     return json_send(['code' => 'error', 'msg' => '记录不存在']);
         //查询店铺名称
-        if(trim($data['store_scope']) == ''){
+        if (trim($data['store_scope']) == '') {
             $data['store_name'] = ['全部店铺'];
-        }else{
+        } else {
             $data['store_name'] = '';
         }
         //查询公司名称
         if ($data->company_scope == '1') {
             $data->company_name = ['全部公司'];
-            $data->company_ids ='';
+            $data->company_ids = '';
         } else {
             $company_data = $ViolationProductCompanyModel->where('violation_product_logid', $data->id)
                 ->join('washconfig_violation_store', 'washconfig_violation_store.id', '=', 'washconfig_violation_product_company.company_id')
@@ -112,8 +113,8 @@ class ViolationProduct extends Controller
             $data->company_name = !empty($company_data) ? array_column($company_data, 'company_name') : '';
             $data->company_ids = !empty($company_data) ? array_column($company_data, 'company_id') : '';
         }
-        $data->platform = isset($data->platform) ? explode(',',$data->platform) : '';
-        $data->category_name = $data->category_id > 0 ? $ProductCategoryModel->where('id', $data->category_id)->value('name'):'';
+        $data->platform = isset($data->platform) ? explode(',', $data->platform) : '';
+        $data->category_name = $data->category_id > 0 ? $ProductCategoryModel->where('id', $data->category_id)->value('name') : '';
         // 加载模板
         return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $data]);
     }
@@ -143,16 +144,21 @@ class ViolationProduct extends Controller
         $sampling_start_time = request('sampling_start_time', '');
         $sampling_end_time = request('sampling_end_time', '');
         $all_data['sampling_cycle'] = $sampling_cycle;
-        $all_data['sampling_start_time'] = strtotime($sampling_start_time.'00:00:00');
-        $all_data['sampling_end_time'] = strtotime($sampling_end_time.'23:59:59');
+        $all_data['sampling_start_time'] = strtotime($sampling_start_time . '00:00:00');
+        $all_data['sampling_end_time'] = strtotime($sampling_end_time . '23:59:59');
         //查询是否存在
-        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'],'platform'=> $all_data['platform']];
+        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
         $data = $ViolationProductModel->where($map)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 写入数据表
         $result     =  $ViolationProductModel->addViolationProduct($all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '新增失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $ViolationProductModel->getTable();
+        $notes_type = 1; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-禁止商品管理', $admin_id, $table_name, $notes_type, [], $all_data, '新增了违规商品' . $all_data['product_name'] . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '新增成功']);
     }
@@ -184,17 +190,24 @@ class ViolationProduct extends Controller
         $sampling_start_time = request('sampling_start_time', '');
         $sampling_end_time = request('sampling_end_time', '');
         $all_data['sampling_cycle'] = $sampling_cycle;
-        $all_data['sampling_start_time'] = strtotime($sampling_start_time.'00:00:00');
-        $all_data['sampling_end_time'] = strtotime($sampling_end_time.'23:59:59');
+        $all_data['sampling_start_time'] = strtotime($sampling_start_time . '00:00:00');
+        $all_data['sampling_end_time'] = strtotime($sampling_end_time . '23:59:59');
         //查询是否存在
-        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'],'platform'=> $all_data['platform']];
+        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
         $data = $ViolationProductModel->where($map)->where('id', '!=', $id)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 更新数据表
         $where = ['id' => $id];
-        $result =  $ViolationProductModel->updateViolationProduct($where, $all_data);
+        $ViolationProduct = $ViolationProductModel->where($where)->first();
+        if (!$ViolationProduct) return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        $result =  $ViolationProductModel->editViolationProduct_content($ViolationProduct, $all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '修改失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $ViolationProductModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-禁止商品管理', $admin_id, $table_name, $notes_type, $ViolationProduct->toarray(), $all_data, '修改了违规商品' . $ViolationProduct->product_name . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '修改成功']);
     }
@@ -215,10 +228,17 @@ class ViolationProduct extends Controller
         $status            = request('status', 0);
         // 查询用户
         $where = ['id' => $id];
+        $ViolationProduct = $ViolationProductModel->where($where)->first();
+        if (!$ViolationProduct) return json_send(['code' => 'error', 'msg' => '记录不存在']);
         // 执行修改
-        $result            =  $ViolationProductModel->changeStatus($where, $status);
+        $result            =  $ViolationProductModel->changeStatus($ViolationProduct, $status);
         // 提示新增失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '设置失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $ViolationProductModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-禁止商品管理', $admin_id, $table_name, $notes_type,[],['status'=> $status], '修改了违规商品' . $ViolationProduct->product_name . '状态');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '设置成功']);
     }
@@ -240,10 +260,31 @@ class ViolationProduct extends Controller
         // 查询用户
         $where = ['id' => $id];
         // 执行删除
-        $result =  $ViolationProductModel->deleteViolationProduct($where);
-        // 提示删除失败
-        if (!$result)    return json_send(['code' => 'error', 'msg' => '删除失败']);
-        // 告知结果
-        return             json_send(['code' => 'success', 'msg' => '删除成功']);
+        $ViolationProduct = $ViolationProductModel->where($where)->first();
+        if (!$ViolationProduct) {
+            return false;
+        }
+        DB::beginTransaction();
+        try {
+            $ViolationProductCompanyModel = new ViolationProductCompanyModel();
+            $company_id_log = $ViolationProductCompanyModel->where('violation_product_logid', $ViolationProduct->id)->get();
+            if (!empty($company_id_log)) {
+                $ViolationProductCompanyModel->where('violation_product_logid', $ViolationProduct->id)->delete();
+            }
+            $ViolationProduct->delete();
+            // 记录行为
+            $admin_id   = request('access_token.uid', 0); //用户ID
+            $table_name = $ViolationProductModel->getTable();
+            $notes_type = 3; //操作类型,1添加,2修改,3=删除
+            $this->addAdminHistory('清洗配置-禁止商品管理', $admin_id, $table_name, $notes_type, $ViolationProduct->toarray(), [], '删除了违规商品' . $ViolationProduct->product_name . '信息');
+            // 告知结果
+            DB::commit();
+            return             json_send(['code' => 'success', 'msg' => '删除成功']);
+            // 成功处理...
+        } catch (\Exception $e) {
+            DB::rollBack();
+            // 错误处理...
+            return             json_send(['code' => 'error', 'msg' => '删除失败']);
+        }
     }
 }

+ 45 - 21
app/Http/Controllers/Manager/WashConfig/ViolationStore.php

@@ -26,7 +26,7 @@ class ViolationStore extends Controller
      * @date      2025-12-03
      * 
      */
-    public function list(Request $request, ViolationStoreModel $ViolationStoreModel,EmployeeModel $EmployeeModel, CompanyCategoryModel $CompanyCategoryModel,CitysModel $CitysModel)
+    public function list(Request $request, ViolationStoreModel $ViolationStoreModel, EmployeeModel $EmployeeModel, CompanyCategoryModel $CompanyCategoryModel, CitysModel $CitysModel)
     {
         $request->scene('list')->validate();
         // 查询条件
@@ -59,7 +59,7 @@ class ViolationStore extends Controller
         if (!$result)  return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => []]);
         if (isset($result['data']) && count($result['data']) > 0) {
             foreach ($result['data'] as $key => $value) {
-                $employee_ids = $value['employee_ids'] !='' ? explode(',', $value['employee_ids']) : '';
+                $employee_ids = $value['employee_ids'] != '' ? explode(',', $value['employee_ids']) : '';
                 $result['data'][$key]['platform'] = isset($value['platform']) ? explode(',', $value['platform']) : '';
                 $result['data'][$key]['employee_ids'] = $employee_ids;
                 $result['data'][$key]['employee_name'] = $employee_ids ? $EmployeeModel->whereIn('id', $employee_ids)->pluck('name')->toArray() : '';
@@ -119,7 +119,7 @@ class ViolationStore extends Controller
      * @version   1.0
      * @date      2025-12-03
      */
-    public function detail(Request $request, ViolationStoreModel $ViolationStoreModel,EmployeeModel $EmployeeModel, CompanyCategoryModel $CompanyCategoryModel,CitysModel $CitysModel)
+    public function detail(Request $request, ViolationStoreModel $ViolationStoreModel, EmployeeModel $EmployeeModel, CompanyCategoryModel $CompanyCategoryModel, CitysModel $CitysModel)
     {
         $request->scene('detail')->validate();
         // 接收参数
@@ -127,12 +127,12 @@ class ViolationStore extends Controller
         $map = ['id' => $id];
         $data = $ViolationStoreModel->where($map)->first();
         if (!$data)     return json_send(['code' => 'error', 'msg' => '记录不存在']);
-        $employee_ids = $data->employee_ids !='' ? explode(',', $data->employee_ids) : '';
+        $employee_ids = $data->employee_ids != '' ? explode(',', $data->employee_ids) : '';
         $data->employee_ids = $employee_ids;
         $data->employee_name = $employee_ids ? $EmployeeModel->whereIn('id', $employee_ids)->pluck('name')->toArray() : '';
         $data->category_name = $data->category_id ? $CompanyCategoryModel->where('id', $data->category_id)->value('name') : '';
         $province_name = $CitysModel->get_city_name($data->province_id);
-         $data->province_name = $province_name ?? '';
+        $data->province_name = $province_name ?? '';
         $city_name = $CitysModel->get_city_name($data->city_id);
         $data->city_name = $city_name ?? '';
         // 加载模板
@@ -152,7 +152,7 @@ class ViolationStore extends Controller
         // 接收数据
         $all_data = request()->all();
         $store_scope = request('store_scope', '');
-        $all_data['store_scope'] = $store_scope;//店铺范围
+        $all_data['store_scope'] = $store_scope; //店铺范围
         $employee_ids = request('employee_ids', '');
         $all_data['employee_ids'] = $employee_ids;
         $category_id = request('category_id', '0');
@@ -169,6 +169,11 @@ class ViolationStore extends Controller
         $result     =  $ViolationStoreModel->addViolationStore($all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '新增失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $ViolationStoreModel->getTable();
+        $notes_type = 1; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-公司管理', $admin_id, $table_name, $notes_type, [], $all_data, '新增了公司' . $all_data['company_name'] . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '新增成功']);
     }
@@ -187,7 +192,7 @@ class ViolationStore extends Controller
         $id         = request('id', 0);
         // 接收数据
         $all_data = request()->all();
-        $store_scope = request('store_scope','');
+        $store_scope = request('store_scope', '');
         $all_data['store_scope'] = $store_scope;
         $employee_ids = request('employee_ids', '');
         $all_data['employee_ids'] = $employee_ids;
@@ -200,12 +205,19 @@ class ViolationStore extends Controller
         //查询是否存在
         $map = ['social_credit_code' => $all_data['social_credit_code']];
         $data = $ViolationStoreModel->where($map)->where('id', '!=', $id)->first();
-        if ($data)     return json_send(['code' => 'error', 'msg' => '营业执照记录已存在']);
+        if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 更新数据表
         $where = ['id' => $id];
-        $result =  $ViolationStoreModel->updateViolationStore($where, $all_data);
+        $ViolationStore = $ViolationStoreModel->where($where)->first();
+        if (!$ViolationStore) return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        $result =  $ViolationStoreModel->updateViolationStore($ViolationStore, $all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '修改失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $ViolationStoreModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-公司管理', $admin_id, $table_name, $notes_type, $ViolationStore->toarray(), $all_data, '修改了公司' . $ViolationStore->company_name . '信息');
         // 告知结果
         return json_send(['code' => 'success', 'msg' => '修改成功']);
     }
@@ -226,10 +238,17 @@ class ViolationStore extends Controller
         $status            = request('status', 0);
         // 查询用户
         $where = ['id' => $id];
+        $ViolationStore = $ViolationStoreModel->where($where)->first();
+        if (!$ViolationStore) return json_send(['code' => 'error', 'msg' => '记录不存在']);
         // 执行修改
-        $result            =  $ViolationStoreModel->changeStatus($where, $status);
+        $result            =  $ViolationStoreModel->changeStatus($ViolationStore, $status);
         // 提示新增失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '设置失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $ViolationStoreModel->getTable();
+        $notes_type = 2; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-公司管理', $admin_id, $table_name, $notes_type, [], ['status' => $status], '修改了公司' . $ViolationStore->company_name . '状态');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '设置成功']);
     }
@@ -242,29 +261,34 @@ class ViolationStore extends Controller
      * @date      2025-12-03
      * 
      */
-    public function delete(Request $request, ViolationStoreModel $ViolationStoreModel,LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel,ViolationProductCompanyModel $ViolationProductCompanyModel)
+    public function delete(Request $request, ViolationStoreModel $ViolationStoreModel, LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel, ViolationProductCompanyModel $ViolationProductCompanyModel)
     {
         // 验证参数
         $request->scene('delete')->validate();
         // 接收数据
         $id = request('id', 0);
         //查询是否已经被使用
-        if ($id > 0) {
-            $use_low_price_goods_company_log = $LowPriceGoodsCompanyModel->where('company_id', $id)->first();
-            if ($use_low_price_goods_company_log) {
-                return json_send(['code' => 'error', 'msg' => '该记录已被使用在低价商品配置中,不能删除']);
-            }
-            $use_violation_product_company_log = $ViolationProductCompanyModel->where('company_id', $id)->first();
-            if ($use_violation_product_company_log) {
-                return json_send(['code' => 'error', 'msg' => '该记录已被使用在违规商品配置中,不能删除']);
-            }
+        $use_low_price_goods_company_log = $LowPriceGoodsCompanyModel->where('company_id', $id)->first();
+        if ($use_low_price_goods_company_log) {
+            return json_send(['code' => 'error', 'msg' => '该记录已被使用在低价商品配置中,不能删除']);
+        }
+        $use_violation_product_company_log = $ViolationProductCompanyModel->where('company_id', $id)->first();
+        if ($use_violation_product_company_log) {
+            return json_send(['code' => 'error', 'msg' => '该记录已被使用在违规商品配置中,不能删除']);
         }
         // 查询用户
         $where = ['id' => $id];
         // 执行删除
-        $result =  $ViolationStoreModel->deleteViolationStore($where);
+        $ViolationStore = $ViolationStoreModel->where($where)->first();
+        if (!$ViolationStore) return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        $result = $ViolationStore->delete();
         // 提示删除失败
         if (!$result)    return json_send(['code' => 'error', 'msg' => '删除失败']);
+        // 记录行为
+        $admin_id   = request('access_token.uid', 0); //用户ID
+        $table_name = $ViolationStoreModel->getTable();
+        $notes_type = 3; //操作类型,1添加,2修改,3=删除
+        $this->addAdminHistory('清洗配置-公司管理', $admin_id, $table_name, $notes_type, $ViolationStore->toarray(), [], '删除了公司' . $ViolationStore->company_name . '信息');
         // 告知结果
         return             json_send(['code' => 'success', 'msg' => '删除成功']);
     }

+ 22 - 148
app/Models/Manager/AdminHistory.php

@@ -4,7 +4,6 @@ namespace App\Models\Manager;
 
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
-use App\Models\Manager\AdminUser;
 
 /**
  * 后台管理员操作历史
@@ -16,170 +15,45 @@ class AdminHistory extends Model
 
     // 与模型关联的表名
     protected $table        = 'admin_history';
-    // 是否主动维护时间戳
-    public $timestamps      = false;
-    protected   $connection = 'mysql';
-    // 模型日期的存储格式
-    // protected $dateFormat   = 'U';
     // 定义时间戳字段名
     // const CREATED_AT        = 'insert_time';
     // const UPDATED_AT        = 'update_time';
 
-    // 操作表字段
-    private $tableColumn     = [
 
-        'admin' => [
-            '_table_name' => '管理表',
-            'status' => '状态',
-        ],
-        'need'  => [
-            '_table_name' => '需求表',
-            'baseline' => '基线名称',
-            'status' => '状态',
-            'project_id' => '项目ID',
-            'project_type' => '项目类型',
-            'project_title' => '项目类型',
-            'memory_size' => '硬件空间',
-            'template_id' => '项目平台',
-            'custom_uid' => '客户名称',
-        ],
-
-    ];
     /**
      * 添加数据
      * 
      * @param   Int         $uid        用户ID
      * @param   String      $table      操作表
-     * @param   Int         $type       操作类型
+     * @param   Int         $type       操作类型,1添加,2修改,3=删除
      * @param   Array       $oldData    旧数据
      * @param   Array       $oldData    新数据
-     * 
+     * @param   String       $general_description    操作描述
      * 
      */
-    public function addAll($uid, $table, $id, $type, $oldData, $newData)
+    public function addAll($admin_menu_name, $uid, $table,$type, $oldData, $newData, $general_description = '')
     {
-        // 有ID,删除
-        if (isset($oldData['id'])) unset($oldData['id']);
-        if (isset($newData['id'])) unset($newData['id']);
-        // 取差集
-        $diff           = [];
-        // 当前时间
-        $time           = time();
-        // 循环新数据
-        foreach ($newData as $key => $value) {
-            // 如果存在字段,且字段相等。不做处理
-            if (isset($oldData[$key]) && $oldData[$key] == $value) continue;
-            // 获取结果
-            $diff[]     =  [
-                // 操作主键
-                'primary_id'    => $id,
-                // 操作类型
-                'notes_type'    => $type,
-                // 操作表名
-                'table_name'    => $table,
-                // 操作字段
-                'column_name'   => $key,
-                // 操作用户
-                'admin_uid'     => $uid,
-                // 操作之前
-                'before_value'  => empty($oldData[$key]) ? '' : $oldData[$key],
-                // 操作之后
-                'after_value'   => $value,
-                // 时间
-                'insert_time'   => $time,
-                // 时间
-                'update_time'   => $time,
-            ];
-        }
+        $insert_data =  [
+            // 模块菜单名称
+            'module_menu_name'   => $admin_menu_name,
+            //操作描述
+            'general_description'   => $general_description,
+            // 操作类型
+            'notes_type'    => $type,
+            // 操作表名
+            'table_name'    => $table,
+            // 操作用户
+            'admin_uid'     => $uid,
+            // 操作之前
+            'before_value'  => json_encode($oldData),
+            // 操作之后
+            'after_value'   => json_encode($newData),
+            // 时间
+            'insert_time'   => time(),
+        ];
         // 结果
-        $result         = $diff ? $this->query()->insert($diff) : 0;
+        $result         = $this->insertGetId($insert_data);
         // 如果有数据
         return           $result;
     }
-
-    /**
-     * 获取历史
-     * 
-     * @param   String      $table      操作表
-     * @param   Int         $id         操作ID
-     * @param   Bool        $getHtml    是否获取Html
-     * 
-     */
-    public function getHistory($table, $id, $getHtml = true)
-    {
-        // 查询返回结果
-        $data           = $this->query()->where([['table_name', '=', $table], ['primary_id', '=', $id]])->orderByDesc('update_time')->limit($getHtml ? 1 : 3)->get()->toArray();
-        // html
-        $html           = '';
-        // 循环数据
-        foreach ($data as $key => $value) {
-            // 获取字段名称
-            $value['table_name']    = $this->getTableName($table, $value['table_name']);
-            // 获取字段名称
-            $value['notes_type']    = $value['notes_type'] == 1 ? '添加' : ($value['notes_type'] == 2 ? '修改' : '删除');
-            // 获取字段名称
-            $value['column_name']   = $this->getTableColumn($table, $value['column_name']);
-            // 获取字段名称
-            $value['admin_name']    = (new AdminUser())->getOne($value['admin_uid'], 'nickname');
-            // 返回结果
-            $html                   = '<p>' . $value['admin_name'] . ' ' . date('m-d H:i', $value['update_time']) . ' ' . $value['notes_type'] . ' ' . $value['column_name'] . '</p>';
-            // 重组
-            $data[$key]             = $value;
-        }
-        // 返回结果
-        return                     $getHtml ? $html : $data;
-    }
-
-    /**
-     * 获取表格字段名
-     * 
-     * @param   String      $table      操作表
-     * @param   String      $column     操作字段
-     * 
-     */
-    public function getTableColumn($table, $column)
-    {
-        // 结果
-        return  isset($this->tableColumn[$table][$column]) ? $this->tableColumn[$table][$column] : $column;
-    }
-
-
-    /**
-     * 获取表格列表
-     * 
-     * 
-     */
-    public function getTableNameList()
-    {
-        // 结果
-        return  $this->tableColumn;
-    }
-
-
-    /**
-     * 获取表格名
-     * 
-     * @param   String      $table      操作表
-     * 
-     */
-    public function getTableName($table)
-    {
-        // 结果
-        return      isset($this->tableColumn[$table]['_table_name']) ? $this->tableColumn[$table]['_table_name'] : $table;
-    }
-
-
-    /**
-     * 获取最后一次修改值的信息
-     * @param   String      $table      操作表
-     * @param   Int         $id         操作ID
-     * 
-     */
-    public function getLastByValue($table, $id, $column, $value)
-    {
-        // 查询返回结果
-        $data       = $this->query()->where([['table_name', '=', $table], ['primary_id', '=', $id], ['column_name', '=', $column], ['after_value', '=', $value]])->orderByDesc('update_time')->first(['admin_uid', 'update_time']);
-        // 返回结果
-        return      $data ? $data->toArray() : [];
-    }
 }

+ 1 - 5
app/Models/Manager/Personnel/Department.php

@@ -73,12 +73,8 @@ class Department extends Model
      * @param $data
      * @return bool
      */
-    public function editDepartment_content($where, $data)
+    public function editDepartment_content($Department, $data)
     {
-        $Department = $this->where($where)->first();
-        if (!$Department) {
-            return false;
-        }
         $Department->name = $data['name'];
         $Department->update_time = time();
         $Department->save();

+ 2 - 5
app/Models/Manager/Personnel/Employee.php

@@ -180,12 +180,8 @@ class Employee extends Model
      * @param $data
      * @return bool
      */
-    public function updateEmployee($where, $data)
+    public function updateEmployee($Employee, $data)
     {
-        $Employee = $this->where($where)->first();
-        if (!$Employee) {
-            return false;
-        }
         DB::beginTransaction();
         try {
             $EmployeeAreaModel = new EmployeeAreaModel();
@@ -230,6 +226,7 @@ class Employee extends Model
             // 成功处理...
         } catch (\Exception $e) {
             DB::rollBack();
+            print_r($e->getMessage());exit;
             // 错误处理...
             return false;
         }

+ 1 - 5
app/Models/Manager/Personnel/Roles.php

@@ -73,12 +73,8 @@ class Roles extends Model
      * @param $data
      * @return bool
      */
-    public function editRoles_content($where, $data)
+    public function editRoles_content($Roles, $data)
     {
-        $Roles = $this->where($where)->first();
-        if (!$Roles) {
-            return false;
-        }
         $Roles->name = $data['name'];
         $Roles->update_time = time();
         $Roles->save();

+ 2 - 10
app/Models/Manager/WashConfig/CompanyCategory.php

@@ -73,12 +73,8 @@ class CompanyCategory extends Model
      * @param $data
      * @return bool
      */
-    public function editCompanyCategory_content($where, $data)
+    public function editCompanyCategory_content($CompanyCategory, $data)
     {
-        $CompanyCategory = $this->where($where)->first();
-        if (!$CompanyCategory) {
-            return false;
-        }
         $CompanyCategory->name = $data['name'];
         $CompanyCategory->update_time = time();
         $CompanyCategory->save();
@@ -119,12 +115,8 @@ class CompanyCategory extends Model
      * @param $status
      * @return bool
      */
-    public function changeStatus($where, $status)
+    public function changeStatus($CompanyCategory, $status)
     {
-        $CompanyCategory = $this->where($where)->first();
-        if (!$CompanyCategory) {
-            return false;
-        }
         $CompanyCategory->status = $status;
         $CompanyCategory->update_time = time();
         $CompanyCategory->save();

+ 4 - 10
app/Models/Manager/WashConfig/LowPriceGoods.php

@@ -111,12 +111,9 @@ class LowPriceGoods extends Model
      * @param $data
      * @return bool
      */
-    public function editLowProduct_content($where, $data)
+    public function editLowProduct_content($LowProduct, $data)
     {
-        $LowProduct = $this->where($where)->first();
-        if (!$LowProduct) {
-            return false;
-        }
+       
         DB::beginTransaction();
         try {
             $LowPriceGoodsCompanyModel = new LowPriceGoodsCompanyModel();
@@ -192,12 +189,9 @@ class LowPriceGoods extends Model
      * @param $status
      * @return bool
      */
-    public function changeStatus($where, $status)
+    public function changeStatus($LowProduct, $status)
     {
-        $LowProduct = $this->where($where)->first();
-        if (!$LowProduct) {
-            return false;
-        }
+       
         $LowProduct->status = $status;
         $LowProduct->update_time = time();
         $LowProduct->save();

+ 3 - 10
app/Models/Manager/WashConfig/ProductCategory.php

@@ -73,12 +73,9 @@ class ProductCategory extends Model
      * @param $data
      * @return bool
      */
-    public function editProductCategory_content($where, $data)
+    public function editProductCategory_content($ProductCategory, $data)
     {
-        $ProductCategory = $this->where($where)->first();
-        if (!$ProductCategory) {
-            return false;
-        }
+        
         $ProductCategory->name = $data['name'];
         $ProductCategory->update_time = time();
         $ProductCategory->save();
@@ -119,12 +116,8 @@ class ProductCategory extends Model
      * @param $status
      * @return bool
      */
-    public function changeStatus($where, $status)
+    public function changeStatus($ProductCategory, $status)
     {
-        $ProductCategory = $this->where($where)->first();
-        if (!$ProductCategory) {
-            return false;
-        }
         $ProductCategory->status = $status;
         $ProductCategory->update_time = time();
         $ProductCategory->save();

+ 2 - 10
app/Models/Manager/WashConfig/ViolationProduct.php

@@ -109,12 +109,8 @@ class ViolationProduct extends Model
      * @param $data
      * @return bool
      */
-    public function editViolationProduct_content($where, $data)
+    public function editViolationProduct_content($ViolationProduct, $data)
     {
-        $ViolationProduct = $this->where($where)->first();
-        if (!$ViolationProduct) {
-            return false;
-        }
         DB::beginTransaction();
         try {
             $ViolationProductCompanyModel = new ViolationProductCompanyModel();
@@ -189,12 +185,8 @@ class ViolationProduct extends Model
      * @param $status
      * @return bool
      */
-    public function changeStatus($where, $status)
+    public function changeStatus($ViolationProduct, $status)
     {
-        $ViolationProduct = $this->where($where)->first();
-        if (!$ViolationProduct) {
-            return false;
-        }
         $ViolationProduct->status = $status;
         $ViolationProduct->update_time = time();
         $ViolationProduct->save();

+ 4 - 11
app/Models/Manager/WashConfig/ViolationStore.php

@@ -139,15 +139,10 @@ class ViolationStore extends Model
      * @param $data
      * @return bool
      */
-    public function updateViolationStore($where, $data)
+    public function updateViolationStore($ViolationStore, $data)
     {
         DB::beginTransaction();
         try {
-            $ViolationCompanyMemberModel = new ViolationCompanyMemberModel();
-            $ViolationStore = $this->where($where)->first();
-            if (!$ViolationStore) {
-                return false;
-            }
             $ViolationStore->category_id = $data['category_id'];
             $ViolationStore->company_name = $data['company_name'];
             $ViolationStore->social_credit_code = $data['social_credit_code'];
@@ -160,6 +155,7 @@ class ViolationStore extends Model
             $ViolationStore->update_time = time();
             $ViolationStore->save();
 
+            $ViolationCompanyMemberModel = new ViolationCompanyMemberModel();
             $ViolationCompanyMemberModel->where('company_logid', $ViolationStore->id)->delete();
             if ($data['employee_ids'] != '') {
                 $insert_company_data = [];
@@ -191,12 +187,9 @@ class ViolationStore extends Model
      * @param $status
      * @return bool
      */
-    public function changeStatus($where, $status)
+    public function changeStatus($ViolationStore, $status)
     {
-        $ViolationStore = $this->where($where)->first();
-        if (!$ViolationStore) {
-            return false;
-        }
+
         $ViolationStore->status = $status;
         $ViolationStore->update_time = time();
         $ViolationStore->save();