Browse Source

Merge branch 'dev' into 2D展厅

licailing 3 years ago
parent
commit
3dd7a44e2e

+ 8 - 2
src/main/java/com/izouma/nineth/service/IdentityAuthService.java

@@ -63,6 +63,8 @@ public class IdentityAuthService {
         identityAuthRepo.save(identityAuth);
         identityAuthRepo.save(identityAuth);
         user.setAuthStatus(AuthStatus.PENDING);
         user.setAuthStatus(AuthStatus.PENDING);
         userRepo.save(user);
         userRepo.save(user);
+
+        identityAuthRepo.deleteDuplicated(identityAuth.getUserId(), identityAuth.getId());
     }
     }
 
 
     public void audit(Long id, AuthStatus status, String reason) {
     public void audit(Long id, AuthStatus status, String reason) {
@@ -83,6 +85,7 @@ public class IdentityAuthService {
         auth.setAutoValidated(true);
         auth.setAutoValidated(true);
         identityAuthRepo.save(auth);
         identityAuthRepo.save(auth);
 
 
+        identityAuthRepo.deleteDuplicated(auth.getUserId(), auth.getId());
     }
     }
 
 
     public List<User> repeat(String idNo, Long userId) {
     public List<User> repeat(String idNo, Long userId) {
@@ -141,7 +144,7 @@ public class IdentityAuthService {
 
 
     public void removeDuplicated() {
     public void removeDuplicated() {
         boolean hasMore = true;
         boolean hasMore = true;
-        int pageNum = 1;
+        int pageNum = 0;
         AtomicInteger count = new AtomicInteger();
         AtomicInteger count = new AtomicInteger();
         while (hasMore) {
         while (hasMore) {
             Page<Long> page = identityAuthRepo.listUserId(PageRequest.of(pageNum, 100));
             Page<Long> page = identityAuthRepo.listUserId(PageRequest.of(pageNum, 100));
@@ -202,6 +205,7 @@ public class IdentityAuthService {
         try {
         try {
             List<IdentityAuth> list = identityAuthRepo.findByStatusAndAutoValidated(AuthStatus.PENDING, false);
             List<IdentityAuth> list = identityAuthRepo.findByStatusAndAutoValidated(AuthStatus.PENDING, false);
             list.parallelStream().forEach(identityAuth -> {
             list.parallelStream().forEach(identityAuth -> {
+                log.info("实名 {}", identityAuth.getRealName());
                 boolean success = false;
                 boolean success = false;
                 String reason = null;
                 String reason = null;
                 User user = userRepo.findById(identityAuth.getUserId()).orElseThrow(new BusinessException("用户不存在"));
                 User user = userRepo.findById(identityAuth.getUserId()).orElseThrow(new BusinessException("用户不存在"));
@@ -235,12 +239,14 @@ public class IdentityAuthService {
                         validate(identityAuth.getRealName(), user.getPhone(), identityAuth.getIdNo());
                         validate(identityAuth.getRealName(), user.getPhone(), identityAuth.getIdNo());
                         success = true;
                         success = true;
                     } catch (Exception e) {
                     } catch (Exception e) {
+                        log.error("自动实名出错", e);
                         reason = e.getMessage();
                         reason = e.getMessage();
                     }
                     }
                 }
                 }
                 audit(identityAuth.getId(), success ? AuthStatus.SUCCESS : AuthStatus.PENDING, reason);
                 audit(identityAuth.getId(), success ? AuthStatus.SUCCESS : AuthStatus.PENDING, reason);
             });
             });
-        } catch (Exception ignored) {
+        } catch (Exception e) {
+            log.error("批量自动实名出错", e);
         }
         }
     }
     }
 }
 }