Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
bf6299ddc1
|
@ -57,7 +57,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="mobile != null">mobile,</if>
|
<if test="mobile != null">mobile,</if>
|
||||||
<if test="status != null and status != ''">status,</if>
|
<if test="status != null and status != ''">status,</if>
|
||||||
<if test="createTime != null">create_time,</if>
|
<if test="createTime != null">create_time,</if>
|
||||||
<if test="updateTime != null">update_time,</if>
|
|
||||||
<if test="userId != null">user_id,</if>
|
<if test="userId != null">user_id,</if>
|
||||||
<if test="type != null and type != ''">type,</if>
|
<if test="type != null and type != ''">type,</if>
|
||||||
<if test="result != null and result != ''">result,</if>
|
<if test="result != null and result != ''">result,</if>
|
||||||
|
@ -70,7 +69,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="mobile != null">#{mobile},</if>
|
<if test="mobile != null">#{mobile},</if>
|
||||||
<if test="status != null and status != ''">#{status},</if>
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
<if test="createTime != null">#{createTime},</if>
|
<if test="createTime != null">#{createTime},</if>
|
||||||
<if test="updateTime != null">#{updateTime},</if>
|
|
||||||
<if test="userId != null">#{userId},</if>
|
<if test="userId != null">#{userId},</if>
|
||||||
<if test="type != null and type != ''">#{type},</if>
|
<if test="type != null and type != ''">#{type},</if>
|
||||||
<if test="result != null and result != ''">#{result},</if>
|
<if test="result != null and result != ''">#{result},</if>
|
||||||
|
@ -93,7 +91,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="data.mobile != null">mobile = #{data.mobile},</if>
|
<if test="data.mobile != null">mobile = #{data.mobile},</if>
|
||||||
<if test="data.status != null and data.status != ''">status = #{data.status},</if>
|
<if test="data.status != null and data.status != ''">status = #{data.status},</if>
|
||||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||||
<if test="data.updateTime != null">update_time = #{data.updateTime},</if>
|
|
||||||
<if test="data.userId != null">user_id = #{data.userId},</if>
|
<if test="data.userId != null">user_id = #{data.userId},</if>
|
||||||
<if test="data.type != null and data.type != ''">type = #{data.type},</if>
|
<if test="data.type != null and data.type != ''">type = #{data.type},</if>
|
||||||
<if test="data.result != null and data.result != ''">result = #{data.result},</if>
|
<if test="data.result != null and data.result != ''">result = #{data.result},</if>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.ruoyi.bst.realName.service.impl;
|
package com.ruoyi.bst.realName.service.impl;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -126,7 +125,7 @@ public class RealNameServiceImpl implements RealNameService
|
||||||
public RealNameFaceVO faceRealName(RealName realName) {
|
public RealNameFaceVO faceRealName(RealName realName) {
|
||||||
UserVO user = userService.selectUserById(realName.getUserId());
|
UserVO user = userService.selectUserById(realName.getUserId());
|
||||||
ServiceUtil.assertion(user == null,"用户信息不存在");
|
ServiceUtil.assertion(user == null,"用户信息不存在");
|
||||||
|
ServiceUtil.assertion(user.getIsReal() != null && user.getIsReal(),"用户已实名认证");
|
||||||
|
|
||||||
// 获取活体检测token
|
// 获取活体检测token
|
||||||
LivenessResponseTokenData tokenData = LivenessUtils.getToken(LIVENESS_RETURN_URL, null, null);
|
LivenessResponseTokenData tokenData = LivenessUtils.getToken(LIVENESS_RETURN_URL, null, null);
|
||||||
|
@ -186,8 +185,9 @@ public class RealNameServiceImpl implements RealNameService
|
||||||
// 判断活体是否匹配
|
// 判断活体是否匹配
|
||||||
FaceResponseData faceIdb = FaceUtils.getFaceIdb(face.getIdCard(), face.getName(), livenessResult.getFaceImage(), null);
|
FaceResponseData faceIdb = FaceUtils.getFaceIdb(face.getIdCard(), face.getName(), livenessResult.getFaceImage(), null);
|
||||||
ServiceUtil.assertion(faceIdb == null, "人证比对数据不存在");
|
ServiceUtil.assertion(faceIdb == null, "人证比对数据不存在");
|
||||||
ServiceUtil.assertion(!FaceIncorrect.isSuccess(faceIdb.getIncorrect()), "人证比对未通过:" + faceIdb.getMsg());
|
|
||||||
ServiceUtil.assertion(!FaceScoreResult.isSame(faceIdb.getScore()), "人证比对未通过,分数:" + faceIdb.getScore());
|
boolean isSuccess = FaceIncorrect.isSuccess(faceIdb.getIncorrect());
|
||||||
|
boolean isScoreSuccess = FaceScoreResult.isSame(faceIdb.getScore());
|
||||||
|
|
||||||
// 通过,构造实名认证表
|
// 通过,构造实名认证表
|
||||||
RealName realName = new RealName();
|
RealName realName = new RealName();
|
||||||
|
@ -197,28 +197,29 @@ public class RealNameServiceImpl implements RealNameService
|
||||||
realName.setMobile(face.getMobile());
|
realName.setMobile(face.getMobile());
|
||||||
realName.setScore(faceIdb.getScore());
|
realName.setScore(faceIdb.getScore());
|
||||||
realName.setPicture(imageUrl);
|
realName.setPicture(imageUrl);
|
||||||
realName.setStatus(RealNameStatus.REAL.getCode());
|
realName.setStatus(isSuccess && isScoreSuccess ? RealNameStatus.REAL.getCode() : RealNameStatus.FAILED.getCode());
|
||||||
Date now = new Date();
|
realName.setType(RealNameType.FACE.getCode());
|
||||||
realName.setUpdateTime(now);
|
realName.setResult(isSuccess && isScoreSuccess ? "认证成功" : "人证比对未通过,分数:" + faceIdb.getScore());
|
||||||
realName.setCreateTime(now);
|
|
||||||
|
|
||||||
int result = this.handleNormalRealName(realName, cacheKey);
|
int result = this.handleNormalRealName(realName, cacheKey);
|
||||||
ServiceUtil.assertion(result != 1, "实名认证失败");
|
|
||||||
vo.setPass(true);
|
vo.setPass(isSuccess && isScoreSuccess);
|
||||||
|
ServiceUtil.assertion(result != 1 || !vo.getPass(), "实名认证失败");
|
||||||
|
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int twoElementRealName(RealNameTowEleDTO dto) {
|
public int twoElementRealName(RealNameTowEleDTO dto) {
|
||||||
// TODO 判断用户是否已经实名认证
|
// 判断用户是否已经实名认证
|
||||||
|
UserVO user = userService.selectUserById(dto.getUserId());
|
||||||
|
ServiceUtil.assertion(user == null,"用户信息不存在");
|
||||||
|
ServiceUtil.assertion(user.getIsReal() != null && user.getIsReal(),"用户已实名认证");
|
||||||
|
|
||||||
IDResponse idRes = TwoEleUtil.verifyIdentity(dto.getIdCard(), dto.getUserName());
|
IDResponse idRes = TwoEleUtil.verifyIdentity(dto.getIdCard(), dto.getUserName());
|
||||||
|
|
||||||
boolean isSuccess = IDResponse.isSuccess(idRes);
|
boolean isSuccess = IDResponse.isSuccess(idRes);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 保存实名信息
|
// 保存实名信息
|
||||||
RealName realName = new RealName();
|
RealName realName = new RealName();
|
||||||
realName.setUserId(dto.getUserId());
|
realName.setUserId(dto.getUserId());
|
||||||
|
@ -228,25 +229,7 @@ public class RealNameServiceImpl implements RealNameService
|
||||||
realName.setType(RealNameType.TWO_ELEMENT.getCode());
|
realName.setType(RealNameType.TWO_ELEMENT.getCode());
|
||||||
realName.setResult(isSuccess ? "认证成功" : idRes.getReason());
|
realName.setResult(isSuccess ? "认证成功" : idRes.getReason());
|
||||||
|
|
||||||
Integer result = transactionTemplate.execute(status -> {
|
return this.handleNormalRealName(realName, null);
|
||||||
int insert = this.insertRealName(realName);
|
|
||||||
|
|
||||||
if (insert > 0) {
|
|
||||||
if (isSuccess) {
|
|
||||||
// 修改用户实名信息
|
|
||||||
UserVO user = new UserVO();
|
|
||||||
user.setUserId(dto.getUserId());
|
|
||||||
user.setRealName(dto.getUserName());
|
|
||||||
user.setRealIdCard(dto.getIdCard());
|
|
||||||
user.setIsReal(true);
|
|
||||||
int update = userService.updateUserRealName(user);
|
|
||||||
ServiceUtil.assertion(update != 1, "更新用户信息失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return insert;
|
|
||||||
});
|
|
||||||
|
|
||||||
return result == null ? 0 : result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int handleNormalRealName(RealName realName, String cacheKey) {
|
private int handleNormalRealName(RealName realName, String cacheKey) {
|
||||||
|
@ -261,18 +244,22 @@ public class RealNameServiceImpl implements RealNameService
|
||||||
|
|
||||||
// 数据库操作
|
// 数据库操作
|
||||||
Integer result = transactionTemplate.execute(status -> {
|
Integer result = transactionTemplate.execute(status -> {
|
||||||
// 修改用户实名信息
|
|
||||||
int update = userService.updateUserRealName(data);
|
|
||||||
ServiceUtil.assertion(update != 1, "更新用户信息失败");
|
|
||||||
|
|
||||||
// 插入实名认证表
|
// 插入实名认证表
|
||||||
int insert = this.insertRealName(realName);
|
int insert = this.insertRealName(realName);
|
||||||
ServiceUtil.assertion(insert != 1, "新增实名认证失败");
|
ServiceUtil.assertion(insert != 1, "新增实名认证失败");
|
||||||
|
|
||||||
// 删除缓存
|
if (realName.getStatus().equals(RealNameStatus.REAL.getCode())) {
|
||||||
redisCache.deleteObject(cacheKey);
|
// 修改用户实名信息
|
||||||
|
int update = userService.updateUserRealName(data);
|
||||||
|
ServiceUtil.assertion(update != 1, "更新用户信息失败");
|
||||||
|
}
|
||||||
|
|
||||||
return update;
|
// 删除缓存
|
||||||
|
if (cacheKey != null) {
|
||||||
|
redisCache.deleteObject(cacheKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return insert;
|
||||||
});
|
});
|
||||||
|
|
||||||
return result == null ? 0 : result;
|
return result == null ? 0 : result;
|
||||||
|
|
|
@ -96,6 +96,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="status != null">
|
<if test="status != null">
|
||||||
AND status = #{status}
|
AND status = #{status}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="operUrl != null and operUrl != ''">
|
||||||
|
AND oper_url like concat('%', #{operUrl}, '%')
|
||||||
|
</if>
|
||||||
<if test="operName != null and operName != ''">
|
<if test="operName != null and operName != ''">
|
||||||
AND oper_name like concat('%', #{operName}, '%')
|
AND oper_name like concat('%', #{operName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user