xiongzhu 3 лет назад
Родитель
Сommit
a46617128e

+ 11 - 4
src/main/java/com/izouma/nineth/service/IdentityAuthService.java

@@ -144,12 +144,12 @@ public class IdentityAuthService {
         } else {
             JSONObject data = jsonObject.getJSONObject("data");
             Integer bizCode = Optional.ofNullable(data.getInteger("bizCode")).orElse(3);
-            if (bizCode != 1) {
-                throw new BusinessException("不匹配");
-            } else {
+            if (bizCode == 1) {
                 log.info("{} {} {} 实名认证通过", name, phone, idno);
+                return;
             }
         }
+        throw new BusinessException("不匹配");
     }
 
     public void removeDuplicated() {
@@ -239,7 +239,14 @@ public class IdentityAuthService {
         } else {
             LocalDate birth = DateTimeUtils.toLocalDate(identityAuth.getIdNo().substring(6, 14), "yyyyMMdd");
             long age = ChronoUnit.YEARS.between(birth, LocalDate.now());
-            if (age < 18) {
+            if (user.getPhone().startsWith("170") ||
+                    user.getPhone().startsWith("171") ||
+                    user.getPhone().startsWith("162") ||
+                    user.getPhone().startsWith("165") ||
+                    user.getPhone().startsWith("167")) {
+                result.put("status", AuthStatus.FAIL);
+                result.put("reason", "虚拟号");
+            } else if (age < 18) {
                 result.put("status", AuthStatus.FAIL);
                 result.put("reason", "未满18岁");
             } else if (age > 60) {

+ 1 - 1
src/test/java/com/izouma/nineth/CommonTest.java

@@ -546,6 +546,6 @@ public class CommonTest {
 
     @Test
     public void testAuth() {
-        IdentityAuthService.validate ("班祥佳", "17025596046", "45213119921012413X");
+        IdentityAuthService.validate ("蔡文峰", "15077886171", "431202199707283637");
     }
 }