Browse Source

[智价云] 店铺员工姓名搜索补充

tangyuanwang 10 hours ago
parent
commit
afb0273ed8
1 changed files with 11 additions and 2 deletions
  1. 11 2
      app/Http/Controllers/Manager/WashConfig/ViolationStore.php

+ 11 - 2
app/Http/Controllers/Manager/WashConfig/ViolationStore.php

@@ -6,8 +6,6 @@ use App\Http\Controllers\Controller;
 use App\Http\Requests\Manager\WashConfig\ViolationStore as Request;
 use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
 use App\Models\Manager\Personnel\Employee as EmployeeModel;
-use App\Models\Manager\WashConfig\CompanyCategory as CompanyCategoryModel;
-use App\Models\Manager\Citys as CitysModel;
 
 /**
  * 数据清洗-违规店铺配置
@@ -40,6 +38,7 @@ class ViolationStore extends Controller
         $store_type = request('store_type', '');//店铺类型:1=黑名单2=白名单
         $platforms = request('platforms', '');//平台
         $employee_ids = request('employee_ids', '');//员工ID
+        $employee_name = request('employee_name', '');//员工姓名
         // 时间条件
         if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
         if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
@@ -53,6 +52,16 @@ class ViolationStore extends Controller
         }else{
             $map[] = ['company_id', '=', $admin_company_id];
         }
+        if (!empty($employee_name)) {
+            $employee_name_ids = $EmployeeModel->where('name', 'like', "%$employee_name%")->pluck('id')->toArray();
+            if (!empty($employee_name_ids)) {
+                foreach ($employee_name_ids as $employee_name_id) {
+                    if (empty($employee_name_id) || $employee_name_id == '') continue;
+                    $ViolationStoreModel = $ViolationStoreModel
+                        ->whereRaw("FIND_IN_SET(?, employee_ids)", [$employee_name_id]);
+                }
+            }
+        }
         if (!empty($platforms) && $platforms != '') {
             $platforms = explode(',', $platforms);
             foreach ($platforms as $platform) {