Commit cc6c0e71 authored by liwei's avatar liwei

修改了实名认证接口

parent 763e5d3d
......@@ -112,15 +112,52 @@ public class FaceVerifyServiceImpl extends ServiceImpl<MemInfoRepository, MemInf
map.put("requestId", response.getBody().getRequestId());
map.put("certifyId", response.getBody().getResultObject().getCertifyId());
map.put("certifyUrl", response.getBody().getResultObject().getCertifyUrl());
} else if ("401".equals(response.getBody().getCode())) {
log.error("发起认证请求失败:" + response.getBody().getMessage());
throw new CyServiceException("输入的姓名或者身份证号码有误");
} else if ("418".equals(response.getBody().getCode())) {
log.error("发起认证请求失败:" + response.getBody().getMessage());
throw new CyServiceException("当天刷脸认证次数过多,请明天再试。");
} else {
log.error("发起认证请求失败:" + response.getBody().getMessage());
throw new CyServiceException("发起认证请求失败");
HttpServletRequest request1 = ((ServletRequestAttributes) (RequestContextHolder.getRequestAttributes())).getRequest();
String ip = CyAddressUtils.IpUtils.getIpAddr(request1);
Object ipMin = cyRedisServiceImpl.get(FaceVerifyRedisBean.FACEVERIFY_IP_MINUTES + ip);
// 1 设置 ip 每分钟的失败次数
if (ipMin != null) {
int count = (int)ipMin;
cyRedisServiceImpl.setValueNotTime(FaceVerifyRedisBean.FACEVERIFY_IP_MINUTES + ip, count+1, 0);
} else
cyRedisServiceImpl.set(FaceVerifyRedisBean.FACEVERIFY_IP_MINUTES + ip, 1, 60L);
Object ipDay = cyRedisServiceImpl.get(FaceVerifyRedisBean.FACEVERIFY_IP_DAY + ip);
// 1 设置 ip 每天的失败次数
if (ipDay != null) {
int count = (int)ipDay;
cyRedisServiceImpl.setValueNotTime(FaceVerifyRedisBean.FACEVERIFY_IP_DAY + ip, count+1, 0);
} else {
long time = TimeUtil.getTimeSecond(new Date(), TimeUtil.getTodayEndTime());
cyRedisServiceImpl.set(FaceVerifyRedisBean.FACEVERIFY_IP_DAY + ip, 1, time);
}
Object idCardMin = cyRedisServiceImpl.get(FaceVerifyRedisBean.FACEVERIFY_IDCARD_MINUTES + idCard);
// 1 设置 ip 每分钟的失败次数
if (idCardMin != null) {
int count = (int)idCardMin;
cyRedisServiceImpl.setValueNotTime(FaceVerifyRedisBean.FACEVERIFY_IDCARD_MINUTES + idCard, count+1, 0);
} else
cyRedisServiceImpl.set(FaceVerifyRedisBean.FACEVERIFY_IDCARD_MINUTES + idCard, 1, 60L);
Object idCardDay = cyRedisServiceImpl.get(FaceVerifyRedisBean.FACEVERIFY_IDCARD_DAY + idCard);
// 1 设置 ip 每天的失败次数
if (idCardDay != null) {
int count = (int)idCardDay;
cyRedisServiceImpl.setValueNotTime(FaceVerifyRedisBean.FACEVERIFY_IDCARD_DAY + idCard, count+1, 0);
} else {
long time = TimeUtil.getTimeSecond(new Date(), TimeUtil.getTodayEndTime());
cyRedisServiceImpl.set(FaceVerifyRedisBean.FACEVERIFY_IDCARD_DAY + idCard, 1, time);
}
if ("401".equals(response.getBody().getCode())) {
log.error("发起认证请求失败:" + response.getBody().getMessage());
throw new CyServiceException("输入的姓名或者身份证号码有误");
} else if ("418".equals(response.getBody().getCode())) {
log.error("发起认证请求失败:" + response.getBody().getMessage());
throw new CyServiceException("当天刷脸认证次数过多,请明天再试。");
} else {
log.error("发起认证请求失败:" + response.getBody().getMessage());
throw new CyServiceException("发起认证请求失败");
}
}
return map;
} else
......
......@@ -565,14 +565,14 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
if (captcha != null) {
int count = (int)captcha;
if (count >= faceVerifyAliComp.getIpMinCount())
throw new CyServiceException("实名认证发起频繁,请稍后重试");
throw new CyServiceException("当前IP实名认证发起频繁,请稍后重试");
}
//2. 同一IP,每天失败次数
captcha = cyRedisServiceImpl.get(FaceVerifyRedisBean.FACEVERIFY_IP_DAY + ip);
if (captcha != null) {
int count = (int)captcha;
if (count >= faceVerifyAliComp.getIpDayCount())
throw new CyServiceException("实名认证次数已达上限,请明日再试!");
throw new CyServiceException("当前IP实名认证次数已达上限,请明日再试!");
}
//3. 同一身份证,每分钟失败次数
captcha = cyRedisServiceImpl.get(FaceVerifyRedisBean.FACEVERIFY_IDCARD_MINUTES + memInfo.getMemIdcard());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment