|
|
@@ -30,6 +30,7 @@ import java.nio.charset.StandardCharsets;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ForkJoinPool;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.regex.Pattern;
|
|
|
@@ -134,10 +135,10 @@ public class IdentityAuthService {
|
|
|
HttpRequest request = HttpRequest.get("https://mobilecert.market.alicloudapi.com/mobile3MetaSimple?userName="
|
|
|
+ URLEncoder.encode(name, StandardCharsets.UTF_8)
|
|
|
+ "&identifyNum=" + idno + "&mobile=" + phone)
|
|
|
- .header("Authorization", "APPCODE 1af29c2d37c4f415fac930d82f01fb559");
|
|
|
+ .header("Authorization", "APPCODE af29c2d37c4f415fac930d82f01fb559");
|
|
|
String body = request.body();
|
|
|
- if (request.code() == 403) {
|
|
|
- throw new BusinessException("403", 403);
|
|
|
+ if (request.code() != 200) {
|
|
|
+ throw new BusinessException(request.code() + "", request.code());
|
|
|
}
|
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
log.info("validate {} {} \n{}", name, idno, JSON.toJSONString(jsonObject, SerializerFeature.PrettyFormat));
|
|
|
@@ -217,10 +218,13 @@ public class IdentityAuthService {
|
|
|
}
|
|
|
try {
|
|
|
List<IdentityAuth> list = identityAuthRepo.findByStatusAndAutoValidated(AuthStatus.PENDING, false);
|
|
|
- list.parallelStream().forEach(identityAuth -> {
|
|
|
- Map<String, Object> map = auth(identityAuth);
|
|
|
- audit(identityAuth.getId(), (AuthStatus) map.get("status"), (String) map.get("reason"));
|
|
|
- });
|
|
|
+ new ForkJoinPool(2).submit(() -> {
|
|
|
+ list.parallelStream().forEach(identityAuth -> {
|
|
|
+ Map<String, Object> map = auth(identityAuth);
|
|
|
+ audit(identityAuth.getId(), (AuthStatus) map.get("status"), (String) map.get("reason"));
|
|
|
+ });
|
|
|
+ }).get();
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
log.error("批量自动实名出错", e);
|
|
|
}
|
|
|
@@ -268,7 +272,7 @@ public class IdentityAuthService {
|
|
|
} catch (Exception e) {
|
|
|
log.error("自动实名出错", e);
|
|
|
if (e instanceof BusinessException && ((BusinessException) e).getCode() == 403) {
|
|
|
- result.put("status", AuthStatus.FAIL);
|
|
|
+ result.put("status", AuthStatus.PENDING);
|
|
|
} else {
|
|
|
result.put("status", AuthStatus.FAIL);
|
|
|
result.put("reason", e.getMessage());
|