Commit 36d5fdae authored by hanfeng's avatar hanfeng

修改实名认证

parent 19bc328c
......@@ -45,6 +45,8 @@ import java.util.*;
@Service
@Slf4j
public class CertificationService {
@Value("${}")
private Integer FREQUENCY;
@Autowired
private UserAuthentication authentication;
......@@ -62,7 +64,8 @@ public class CertificationService {
private UserPictureParsing userPictureParsing;
/**
* 一、身份证图片进行实名认证
* 一、身份证图片进行实名认证
*
* @param idInformation
* @return
*/
......@@ -98,10 +101,18 @@ public class CertificationService {
String name = credentialsData.getName();
String number = credentialsData.getCode();
if (idInformation.getName().equals(name)) {
ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "姓名不一致");
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "姓名不一致");
}
if (idInformation.getIdNumber().equals(number)) {
ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "证件号不一致");
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "证件号不一致");
}
//判断是否超过认证次数
Example exa = new Example(IdInformation.class);
exa.createCriteria().andEqualTo("idNumber", number);
List<IdInformation> idInformatics = idInformationMapper.selectByExample(exa);
if (CollectionUtils.isNotEmpty(idInformatics) && idInformatics.size() > FREQUENCY) {
log.error("该身份证已超过最大认证次数");
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "该身份证已超过最大认证次数");
}
//3.验证
boolean result = authentication.certificate(new UserMessage() {{
......@@ -159,23 +170,12 @@ public class CertificationService {
@Transactional(rollbackFor = Exception.class)
public ObjectRestResponse<Integer> addIdInformation(IdInformation idInformation) {
log.info("----idInformation=========" + idInformation);
//保存认证信息
try {
Example exa = new Example(IdInformation.class);
Example.Criteria criteria = exa.createCriteria();
criteria.andEqualTo("idNumber", idInformation.getIdNumber());
List<IdInformation> idInformatics = idInformationMapper.selectByExample(exa);
if (CollectionUtils.isEmpty(idInformatics)) {
idInformation.setCrtTime(new Date());
idInformationMapper.insertSelective(idInformation);
} else {
log.error("该身份证已存在,不要重复认证");
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "该身份证已存在,不要重复认证");
}
idInformationMapper.insertSelective(idInformation);
log.info("----addIdInformation---userid===" + idInformation.getUserLoginId() + "----name====" + idInformation.getName() + "---IdNumber===" + idInformation.getIdNumber());
//认证成功后修改用户,用户认证状态
ObjectRestResponse authentication = userFeign.authentication(idInformation.getUserLoginId(), idInformation.getName(), idInformation.getIdNumber(), 1);
userFeign.authentication(idInformation.getUserLoginId(), idInformation.getName(), idInformation.getIdNumber(), 1);
return ObjectRestResponse.succ(idInformation.getId());
} catch (Exception e) {
log.error(e.getMessage(), e);
......
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