Browse Source

fixbug:手机号两侧的空格

yb 2 months ago
parent
commit
e7ce85c552
1 changed files with 6 additions and 4 deletions
  1. 6 4
      app/admin/service/consultant/CustomService.php

+ 6 - 4
app/admin/service/consultant/CustomService.php

@@ -1214,7 +1214,9 @@ class CustomService
                 try {
                     foreach ($data as $key => $val) {
                         if ($val[3] == 1) {$level = 1;} else if ($val[4] == 1) {$level = 2;} else if ($val[5] == 1) {$level = 3;} else if ($val[6] == 1) {$level = 4;}
-                        $line = '手机号:'.$val[2].' 姓名:'.$val[1].' 第'.($key + 2).'行:';
+                        $line = '姓名:'.$val[1].' 第'.($key + 2).'行:';
+                        $mobile = $val[2] ?? '';
+                        $mobile = trim($mobile);
                         if (empty($val[7]) && empty($val[8])) {
                             throw new \Exception($line.'报备人和顾问必须存在其中之一');
                         }
@@ -1224,10 +1226,10 @@ class CustomService
                         if ($val[0] == '1970-01-01 08:00:00') {
                             throw new \Exception($line.'日期格式错误');
                         }
-                        if (empty($val[2])) {
+                        if (empty($mobile)) {
                             throw new \Exception($line.'手机号不能为空');
                         }
-                        if (!preg_match($validate, $val[2])) {
+                        if (!preg_match($validate, $mobile)) {
                             throw new \Exception($line.'手机号格式非法');
                         }
                         $consultantName = $val[7];
@@ -1259,7 +1261,7 @@ class CustomService
                         //查看手机号是否存在
                         $insertData = [
                             'name' => $val[1],
-                            'mobile' => $val[2],
+                            'mobile' => $mobile,
                             'level' => $level ?? null,
                             'consultant_id' => $consultantId,
                             'report_consultant_id' => $reportConsultantId,