|
|
@@ -131,10 +131,33 @@ public class IdentityAuthService {
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
+ public static void validateV2(String name, String phone, String idno) {
|
|
|
+ String body = HttpRequest.post("https://zid.market.alicloudapi.com/idcheck/Post")
|
|
|
+ .header("Authorization", "APPCODE af29c2d37c4f415fac930d82f01fb559")
|
|
|
+ .contentType(HttpRequest.CONTENT_TYPE_FORM)
|
|
|
+ .form("cardNo", idno)
|
|
|
+ .form("realName", name)
|
|
|
+ .body();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
+ log.info("validate {} {} \n{}", name, idno, JSON.toJSONString(jsonObject, SerializerFeature.PrettyFormat));
|
|
|
+ if (jsonObject.getInteger("error_code") != 0) {
|
|
|
+ String msg = jsonObject.getString("reason");
|
|
|
+ throw new BusinessException(msg);
|
|
|
+ } else {
|
|
|
+ JSONObject data = jsonObject.getJSONObject("result");
|
|
|
+ boolean isOK = Optional.ofNullable(data.getBoolean("isok")).orElse(Boolean.FALSE);
|
|
|
+ if (!isOK) {
|
|
|
+ throw new BusinessException("不匹配");
|
|
|
+ } else {
|
|
|
+ log.info("{} {} {} 实名认证通过", name, phone, idno);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static void validate(String name, String phone, String idno) {
|
|
|
HttpRequest request = HttpRequest.get("https://mobilecert.market.alicloudapi.com/mobile3MetaSimple?userName="
|
|
|
- + URLEncoder.encode(name, StandardCharsets.UTF_8)
|
|
|
- + "&identifyNum=" + idno + "&mobile=" + phone)
|
|
|
+ + URLEncoder.encode(name, StandardCharsets.UTF_8)
|
|
|
+ + "&identifyNum=" + idno + "&mobile=" + phone)
|
|
|
.header("Authorization", "APPCODE af29c2d37c4f415fac930d82f01fb559");
|
|
|
String body = request.body();
|
|
|
if (request.code() != 200) {
|
|
|
@@ -267,7 +290,7 @@ public class IdentityAuthService {
|
|
|
result.put("reason", "同一身份证注册超过3个");
|
|
|
} else {
|
|
|
try {
|
|
|
- validate(identityAuth.getRealName(), identityAuth.getPhone(), identityAuth.getIdNo());
|
|
|
+ validateV2(identityAuth.getRealName(), identityAuth.getPhone(), identityAuth.getIdNo());
|
|
|
result.put("status", AuthStatus.SUCCESS);
|
|
|
} catch (Exception e) {
|
|
|
log.error("自动实名出错", e);
|