Forráskód Böngészése

调整公池搜索和操作栏功能按钮

yb 2 hónapja
szülő
commit
22b1c2b83d
1 módosított fájl, 17 hozzáadás és 27 törlés
  1. 17 27
      app/admin/service/consultant/CustomService.php

+ 17 - 27
app/admin/service/consultant/CustomService.php

@@ -54,6 +54,11 @@ class CustomService
             $where[] = [function($query) use ($deptIds) {
                 $query->whereIn('dept_id', $deptIds);
             }];
+            $where[] = [function($query) use ($diffNums, $currentTime){
+                $query->orWhereRaw("check_status IN (-1, 1)")
+                    ->orWhereRaw("check_status = 2 AND current_status IN (-1,3,4)")
+                    ->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2)");
+            }];
         } else {
             if (!empty($params['dept_id'])) {
                 $deptId = end($params['dept_id']);
@@ -76,35 +81,20 @@ class CustomService
                 $query->where('mobile', 'like', "%{$mobile}%");
             }];
         }
-        if (!empty($params['report_status'])) {
-            $where[] = ['check_status', '=', $params['report_status']];
-//            if ($params['report_status'] == -1) {
-//                //待审核
-//                $where[] = ['check_status', '=', 1];
-//            } else {
-//                $where[] = ['check_status', '=', 2];
-//            }
-//            if ($params['report_status'] == 1) {
-//                //已报备
-//                $where[] = [function($query) use ($diffNums, $currentTime) {
-//                    $query->whereRaw("((visit_time + {$diffNums}) - {$currentTime} > 0)")->where('current_status', '=', 1);
-//                }];
-//            } else if ($params['report_status'] == 3) {
-//                //已锁定
-//                $where[] = [function($query) {
-//                    $query->whereIn('current_status', [2,3,4]);
-//                }];
-//            } else if ($params['report_status'] == 2) {
-//                //已失效
-//                $where[] = [function($query) use ($diffNums, $currentTime){
-//                    $query->orWhere('current_status', '=', -1)->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND current_status = 1 AND check_status = 2)");
-//                }];
-//            }
-        }
         if (!empty($params['consultant_name'])) {
-            $consultantIds = Consultant::where('name', 'like', "%{$params['consultant_name']}%")->pluck('id');
+            $consultantIds = Consultant::where('name', 'like', "%{$params['consultant_name']}%")
+                ->where('mobile', 'like', "%{$params['consultant_name']}%")
+                ->pluck('id')->toArray();
+            $where[] = [function($query) use ($consultantIds) {
+                $query->whereIn('consultant_id', $consultantIds);
+            }];
+        }
+        if (!empty($params['report_name'])) {
+            $consultantIds = Consultant::where('name', 'like', "%{$params['report_name']}%")
+                ->where('mobile', 'like', "%{$params['report_name']}%")
+                ->pluck('id')->toArray();
             $where[] = [function($query) use ($consultantIds) {
-                $query->orWhereIn('consultant_id', $consultantIds)->orWhereIn('report_consultant_id', $consultantIds);
+                $query->whereIn('report_consultant_id', $consultantIds);
             }];
         }
         if (!empty($params['type'])) {