|
|
@ -61,6 +61,9 @@ public class IeRealNameAuthServiceImpl implements IeRealNameAuthService { |
|
|
private static final DateTimeFormatter BIRTHDAY_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|
|
private static final DateTimeFormatter BIRTHDAY_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|
|
private static final int MAX_CERT_PICTURE_BASE64_BYTES = 50 * 1024; |
|
|
private static final int MAX_CERT_PICTURE_BASE64_BYTES = 50 * 1024; |
|
|
private static final String REAL_NAME_AUDIT_ENABLED_KEY = "IE:REVIEW:REAL_NAME_AUDIT_ENABLED"; |
|
|
private static final String REAL_NAME_AUDIT_ENABLED_KEY = "IE:REVIEW:REAL_NAME_AUDIT_ENABLED"; |
|
|
|
|
|
private static final String ALIYUN_CONSISTENT_PASS = "1"; |
|
|
|
|
|
private static final String ALIYUN_CONSISTENT_PHOTO_MISMATCH = "0"; |
|
|
|
|
|
private static final String REPEATED_PHOTO_MISMATCH_AUTO_PASS_REASON = "连续两次照片识别为非同一人,系统默认通过实名认证"; |
|
|
|
|
|
|
|
|
private final OkHttpClient httpClient = new OkHttpClient(); |
|
|
private final OkHttpClient httpClient = new OkHttpClient(); |
|
|
private final SecureRandom secureRandom = new SecureRandom(); |
|
|
private final SecureRandom secureRandom = new SecureRandom(); |
|
|
@ -144,7 +147,21 @@ public class IeRealNameAuthServiceImpl implements IeRealNameAuthService { |
|
|
|
|
|
|
|
|
// 阿里云返回 Data.IsConsistent = "1" 才代表姓名、身份证号、人像照片为同一人。
|
|
|
// 阿里云返回 Data.IsConsistent = "1" 才代表姓名、身份证号、人像照片为同一人。
|
|
|
verifyResult = callAliyunThreeElement(normalizedName, normalizedCertNo, normalizedPicture, normalizedRegionId, userId); |
|
|
verifyResult = callAliyunThreeElement(normalizedName, normalizedCertNo, normalizedPicture, normalizedRegionId, userId); |
|
|
if (!"1".equals(verifyResult.getIsConsistent())) { |
|
|
if (!ALIYUN_CONSISTENT_PASS.equals(verifyResult.getIsConsistent())) { |
|
|
|
|
|
if (shouldAutoPassRepeatedPhotoMismatch(userId, verifyResult)) { |
|
|
|
|
|
profile = ensureProfile(userId); |
|
|
|
|
|
Date now = new Date(); |
|
|
|
|
|
profile.setUpdateTime(now); |
|
|
|
|
|
userProfileMapper.updateById(profile); |
|
|
|
|
|
user = saveRealNameToUser(userId, User.REAL_NAME_AUTH_STATUS_VERIFIED, normalizedName, normalizedCertNo, birthday, age, now); |
|
|
|
|
|
realNameAuthRecordService.recordResult(authRecordId, |
|
|
|
|
|
IeRealNameAuthRecordService.AUTH_STATUS_VERIFIED, |
|
|
|
|
|
verifyResult.getRequestId(), verifyResult.getIsConsistent(), REPEATED_PHOTO_MISMATCH_AUTO_PASS_REASON); |
|
|
|
|
|
recordedResult = true; |
|
|
|
|
|
IeRealNameAuthVO vo = buildAuthVO(user, profile); |
|
|
|
|
|
vo.setMessage("实名认证已通过"); |
|
|
|
|
|
return vo; |
|
|
|
|
|
} |
|
|
throw new IeBusinessException(aliyunResultMessage(verifyResult.getIsConsistent())); |
|
|
throw new IeBusinessException(aliyunResultMessage(verifyResult.getIsConsistent())); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -309,7 +326,7 @@ public class IeRealNameAuthServiceImpl implements IeRealNameAuthService { |
|
|
AliyunThreeElementResult result = new AliyunThreeElementResult(); |
|
|
AliyunThreeElementResult result = new AliyunThreeElementResult(); |
|
|
result.setIsConsistent(data == null ? null : data.getStr("IsConsistent")); |
|
|
result.setIsConsistent(data == null ? null : data.getStr("IsConsistent")); |
|
|
result.setRequestId(json.getStr("RequestId")); |
|
|
result.setRequestId(json.getStr("RequestId")); |
|
|
recordRealNameBilling(regionId, userId, "1".equals(result.getIsConsistent()) ? "pass" : "failed", |
|
|
recordRealNameBilling(regionId, userId, ALIYUN_CONSISTENT_PASS.equals(result.getIsConsistent()) ? "pass" : "failed", |
|
|
result.getRequestId(), "isConsistent=" + result.getIsConsistent()); |
|
|
result.getRequestId(), "isConsistent=" + result.getIsConsistent()); |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
@ -393,8 +410,15 @@ public class IeRealNameAuthServiceImpl implements IeRealNameAuthService { |
|
|
return value.trim(); |
|
|
return value.trim(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean shouldAutoPassRepeatedPhotoMismatch(Long userId, AliyunThreeElementResult verifyResult) { |
|
|
|
|
|
if (verifyResult == null || !ALIYUN_CONSISTENT_PHOTO_MISMATCH.equals(verifyResult.getIsConsistent())) { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
return realNameAuthRecordService.countFailedByResultCode(userId, ALIYUN_CONSISTENT_PHOTO_MISMATCH) >= 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private String aliyunResultMessage(String isConsistent) { |
|
|
private String aliyunResultMessage(String isConsistent) { |
|
|
if ("0".equals(isConsistent)) { |
|
|
if (ALIYUN_CONSISTENT_PHOTO_MISMATCH.equals(isConsistent)) { |
|
|
return "姓名与身份证号匹配,但照片识别为非同一人,请重新上传本人清晰照片"; |
|
|
return "姓名与身份证号匹配,但照片识别为非同一人,请重新上传本人清晰照片"; |
|
|
} |
|
|
} |
|
|
if ("2".equals(isConsistent)) { |
|
|
if ("2".equals(isConsistent)) { |
|
|
|