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