Browse Source

客户导入失败返回信息调整

yb 2 months ago
parent
commit
c0122157e8
1 changed files with 13 additions and 7 deletions
  1. 13 7
      app/admin/service/consultant/CustomService.php

+ 13 - 7
app/admin/service/consultant/CustomService.php

@@ -1222,22 +1222,27 @@ class CustomService
                         $msg = '';
                         if (empty($val[7]) && empty($val[8])) {
                             $msg = $line.'报备人和顾问必须存在其中之一';
-                            throw new \Exception($line.'报备人和顾问必须存在其中之一');
+                            $val[10] = '报备人和顾问必须存在其中之一';
+//                            throw new \Exception($line.'报备人和顾问必须存在其中之一');
                         }
                         if (empty($val[9])) {
                             $msg = $line.'无团队信息';
-                            throw new \Exception($line.'无团队信息');
+                            $val[10] = '无团队信息';
+//                            throw new \Exception($line.'无团队信息');
                         }
                         if ($val[0] == '1970-01-01 08:00:00') {
                             $msg = $line.'日期格式错误';
+                            $val[10] = '日期格式错误';
 //                            throw new \Exception($line.'日期格式错误');
                         }
                         if (empty($mobile)) {
                             $msg = $line.'手机号不能为空';
+                            $val[10] = '手机号不能为空';
 //                            throw new \Exception($line.'手机号不能为空');
                         }
                         if (!preg_match($validate, $mobile)) {
                             $msg = $line.'手机号格式非法';
+                            $val[10] = '手机号格式非法';
 //                            throw new \Exception($line.'手机号格式非法');
                         }
                         $consultantName = $val[7];
@@ -1249,6 +1254,7 @@ class CustomService
                         $reportConsultantId = $teamKeys[$reportKey]['consultant_id'] ?? 0;
                         if ($consultantId <= 0 && $reportConsultantId <= 0) {
                             $msg = $line.'健康顾问或报备人都不存在';
+                            $val[10] = '健康顾问或报备人都不存在';
 //                            throw new \Exception($line.'健康顾问或报备人都不存在');
                         }
                         if ($consultantId > 0) {
@@ -1263,10 +1269,12 @@ class CustomService
                         }
                         if (empty($deptId)) {
                             $msg =  $line.'健康顾问或报备人都不存在';
+                            $val[10] = '健康顾问或报备人都不存在';
 //                            throw new \Exception($line.'团队不存在');
                         }
                         if (MarketCustomer::checkCustomExists($val[2])) {
                             $msg =  $line.'客户已转到访,无法二次录入';
+                            $val[10] = '客户已转到访,无法二次录入';
 //                            throw new \Exception($line.'客户已转到访,无法二次录入');
                         }
                         //查看手机号是否存在
@@ -1277,7 +1285,7 @@ class CustomService
                             'consultant_id' => $consultantId,
                             'report_consultant_id' => $reportConsultantId,
                             'create_consultant_id' => $reportConsultantId,
-                            'dept_id' => $deptId,
+                            'dept_id' => $deptId ?? 0,
                             'belong_status' => 1,
                             'current_status' => 2,
                             'check_status' => 2,
@@ -1290,10 +1298,8 @@ class CustomService
                         if (empty($msg)) {
                             $result = Db::table('market_customer')->insert($insertData);
                         } else {
-                            $errorData[] = [
-                                'msg' => $msg,
-                                'val' => $val
-                            ];
+                            $val[11] = $line;
+                            $errorData[] = $val;
                         }
                         if ($result) {
                             $sucNums++;