|
|
@@ -131,11 +131,14 @@ public class IdentityAuthService {
|
|
|
// }
|
|
|
|
|
|
public static void validate(String name, String phone, String idno) {
|
|
|
- String body = HttpRequest.get("https://mobilecert.market.alicloudapi.com/mobile3MetaSimple?userName="
|
|
|
+ HttpRequest request = HttpRequest.get("https://mobilecert.market.alicloudapi.com/mobile3MetaSimple?userName="
|
|
|
+ URLEncoder.encode(name, StandardCharsets.UTF_8)
|
|
|
+ "&identifyNum=" + idno + "&mobile=" + phone)
|
|
|
- .header("Authorization", "APPCODE af29c2d37c4f415fac930d82f01fb559")
|
|
|
- .body();
|
|
|
+ .header("Authorization", "APPCODE 1af29c2d37c4f415fac930d82f01fb559");
|
|
|
+ String body = request.body();
|
|
|
+ if (request.code() == 403) {
|
|
|
+ throw new BusinessException("403", 403);
|
|
|
+ }
|
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
log.info("validate {} {} \n{}", name, idno, JSON.toJSONString(jsonObject, SerializerFeature.PrettyFormat));
|
|
|
if (jsonObject.getInteger("code") != 200) {
|
|
|
@@ -256,7 +259,7 @@ public class IdentityAuthService {
|
|
|
int count = identityAuthRepo.countByIdNoAndStatus(identityAuth.getIdNo(), AuthStatus.SUCCESS);
|
|
|
|
|
|
if (count >= 3) {
|
|
|
- result.put("status", AuthStatus.PENDING);
|
|
|
+ result.put("status", AuthStatus.FAIL);
|
|
|
result.put("reason", "同一身份证注册超过3个");
|
|
|
} else {
|
|
|
try {
|
|
|
@@ -264,8 +267,12 @@ public class IdentityAuthService {
|
|
|
result.put("status", AuthStatus.SUCCESS);
|
|
|
} catch (Exception e) {
|
|
|
log.error("自动实名出错", e);
|
|
|
- result.put("status", AuthStatus.FAIL);
|
|
|
- result.put("reason", e.getMessage());
|
|
|
+ if (e instanceof BusinessException && ((BusinessException) e).getCode() == 403) {
|
|
|
+ result.put("status", AuthStatus.FAIL);
|
|
|
+ } else {
|
|
|
+ result.put("status", AuthStatus.FAIL);
|
|
|
+ result.put("reason", e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|