Просмотр исходного кода

调整客户列表检索功能

yb 2 месяцев назад
Родитель
Сommit
8ff5fd4e98
1 измененных файлов с 32 добавлено и 26 удалено
  1. 32 26
      app/admin/service/consultant/CustomService.php

+ 32 - 26
app/admin/service/consultant/CustomService.php

@@ -4,15 +4,11 @@
 namespace app\admin\service\consultant;
 
 
-use app\admin\service\member\MemberService;
 use app\model\Consultant;
 use app\model\MarketCustomer;
 use app\model\MarketCustomerFollow;
 use app\model\MarketCustomerLogs;
-use app\model\Member;
 use app\model\SysDept;
-use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
-use PhpOffice\PhpSpreadsheet\IOFactory;
 use PhpOffice\PhpSpreadsheet\Reader\Csv;
 use PhpOffice\PhpSpreadsheet\Reader\Xls;
 use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
@@ -42,6 +38,7 @@ class CustomService
         $currentTime = time();
         $diffNums = self::DIFF_TIME;
         $deptIds = TeamService::getIdsByUser();
+        $belongStatus = $params['belong_status'] ?? 1;
         if (false === $deptIds) {
             //无权限
             $where[] = ['dept_id', '=', 0];
@@ -57,8 +54,10 @@ class CustomService
             $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)");
+                    ->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2)")
+                    ->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND (visit_time + ({$diffNums} * 4)) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
             }];
+
         } else {
             if (!empty($params['dept_id'])) {
                 $deptId = end($params['dept_id']);
@@ -127,11 +126,17 @@ class CustomService
 
         if (!empty($params['current_status'])) {
             $currentStatus = $params['current_status'];
-            if ($currentStatus == 1) {
-                $where[] = ['current_status', '=', $currentStatus];
+            if ($currentStatus == -2) {
+                //检索公池状态
+                $where[] = [function($query) use ($diffNums, $currentTime){
+                    $query->whereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND (visit_time + ({$diffNums} * 4)) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)");
+                }];
             } else {
-                $where[] = [function($query) use ($currentStatus){
-                    $query->where('current_status', '=', $currentStatus)->where('check_status', '<>', 1);
+                $where[] = ['current_status', '=', $currentStatus];
+                $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)");
                 }];
             }
         }
@@ -1269,25 +1274,26 @@ class CustomService
                             $val[10] = '客户已转到访,无法二次录入';
 //                            throw new \Exception($line.'客户已转到访,无法二次录入');
                         }
-                        //查看手机号是否存在
-                        $insertData = [
-                            'name' => $val[1],
-                            'mobile' => $mobile,
-                            'level' => $level ?? null,
-                            'consultant_id' => $consultantId,
-                            'report_consultant_id' => $reportConsultantId,
-                            'create_consultant_id' => $reportConsultantId,
-                            'dept_id' => $deptId ?? 0,
-                            'belong_status' => 1,
-                            'current_status' => 2,
-                            'check_status' => 2,
-                            'check_note' => '导入的客户信息,无审核人员',
-                            'type' => 1,
-                            'visit_time' => strtotime('2024-08-31 00:00:00'),
-                            'created_at' => strtotime('2024-08-31 00:00:00')
-                        ];
+
                         $result = false;
                         if (empty($msg)) {
+                            //查看手机号是否存在
+                            $insertData = [
+                                'name' => $val[1],
+                                'mobile' => $mobile,
+                                'level' => $level ?? null,
+                                'consultant_id' => $consultantId,
+                                'report_consultant_id' => $reportConsultantId,
+                                'create_consultant_id' => $reportConsultantId,
+                                'dept_id' => $deptId ?? 0,
+                                'belong_status' => 1,
+                                'current_status' => 2,
+                                'check_status' => 2,
+                                'check_note' => '导入的客户信息,无审核人员',
+                                'type' => 1,
+                                'visit_time' => strtotime($val[0]),
+                                'created_at' => strtotime($val[0])
+                            ];
                             $result = Db::table('market_customer')->insert($insertData);
                         } else {
                             $val[11] = $line;