风控实名修改(一半)

This commit is contained in:
磷叶 2024-11-23 18:00:20 +08:00
parent 9e32072aab
commit 1c8a9d78de
13 changed files with 230 additions and 35 deletions

View File

@ -12,6 +12,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;
/**
* 风控对象 ss_risk
@ -43,12 +44,60 @@ public class Risk extends BaseEntity
@ApiModelProperty("结束时间")
private LocalDateTime endTime;
@Excel(name = "实名认证ID")
@ApiModelProperty("实名认证ID")
private Long realNameId;
@Excel(name = "是否允许自行解封")
@ApiModelProperty("是否允许自行解封")
private Boolean unsealSelf;
@Excel(name = "需要提交的材料类型列表")
@ApiModelProperty("需要提交的材料类型列表")
private List<String> submitType;
@Excel(name = "实名认证ID")
@ApiModelProperty("实名认证ID")
private Long realNameId;
@Excel(name = "身份证正面")
@ApiModelProperty("身份证正面")
private String idCardFront;
@Excel(name = "身份证反面")
@ApiModelProperty("身份证反面")
private String idCardBack;
@Excel(name = "手持身份证照片")
@ApiModelProperty("手持身份证照片")
private String idCardHand;
@Excel(name = "使用场景视频")
@ApiModelProperty("使用场景视频")
private String video;
@Excel(name = "视频自定义词汇")
@ApiModelProperty("视频自定义词汇")
private String videoWords;
@Excel(name = "营业执照")
@ApiModelProperty("营业执照")
private String businessLicence;
@Excel(name = "审核人ID")
@ApiModelProperty("审核人ID")
private Long verifyId;
@Excel(name = "审核人名称")
@ApiModelProperty("审核人名称")
private String verifyBy;
@Excel(name = "审核意见")
@ApiModelProperty("审核意见")
private String verifyRemark;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("审核时间")
private LocalDateTime verifyTime;
@Excel(name = "审核状态", readConverterExp = "1=待审核,2=已通过,3=未通过")
@ApiModelProperty("审核状态")
private String verifyStatus;
}

View File

@ -0,0 +1,22 @@
package com.ruoyi.ss.risk.domain.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author wjh
* 2024/11/23
*/
@Getter
@AllArgsConstructor
public enum RiskSubmitType {
REAL_NAME("1", "实名信息"),
ID_CARD("2", "身份证正反面"),
ID_CARD_HAND("3", "手持身份证照片"),
VIDEO("4", "使用场景视频"),
BUSINESS_LICENCE("5", "营业执照");
private final String code;
private final String msg;
}

View File

@ -66,10 +66,8 @@ public interface RiskMapper
/**
* 批量修改结束时间
* @param riskIds ID列表
* @param endTime 结束时间
* @return
*/
int batchFinish(@Param("riskIds") List<Long> riskIds,
@Param("endTime") LocalDateTime endTime,
@Param("realNameId") Long realNameId);
int batchSetRealName(@Param("riskIds") List<Long> riskIds,
@Param("realNameId") Long realNameId);
}

View File

@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="RiskVO" id="RiskResult" autoMapping="true">
<result column="type" property="type" typeHandler="com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler"/>
<result column="submit_type" property="submitType" typeHandler="com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler"/>
</resultMap>
<sql id="isFinished">
@ -22,6 +23,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sr.create_time,
sr.real_name_id,
sr.unseal_self,
sr.submit_type,
sr.id_card_front,
sr.id_card_back,
sr.id_card_hand,
sr.video,
sr.video_words,
sr.business_licence,
sr.verify_id,
sr.verify_by,
sr.verify_remark,
sr.verify_time,
sr.verify_status,
<include refid="isFinished"/> as is_finished,
if(su.is_real, su.real_name, su.user_name) as user_name
from ss_risk sr
@ -41,6 +54,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
<if test="query.realNameId != null "> and sr.real_name_id = #{query.realNameId}</if>
<if test="query.unsealSelf != null "> and unseal_self = #{query.unsealSelf}</if>
<if test="query.videoWords != null and query.videoWords != ''"> and video_words like concat('%', #{query.videoWords}, '%')</if>
<if test="query.verifyId != null "> and verify_id = #{query.verifyId}</if>
<if test="query.verifyBy != null and query.verifyBy != ''"> and verify_by like concat('%', #{query.verifyBy}, '%')</if>
<if test="query.verifyRemark != null and query.verifyRemark != ''"> and verify_remark like concat('%', #{query.verifyRemark}, '%')</if>
<if test="query.verifyStatus != null and query.verifyStatus != ''"> and verify_status = #{query.verifyStatus}</if>
<if test="query.isFinished != null">
<if test="query.isFinished">and <include refid="isFinished"/></if>
<if test="!query.isFinished">and !<include refid="isFinished"/></if>
@ -69,6 +87,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time,</if>
<if test="realNameId != null">real_name_id,</if>
<if test="unsealSelf != null">unseal_self,</if>
<if test="submitType != null">submit_type,</if>
<if test="idCardFront != null">id_card_front,</if>
<if test="idCardBack != null">id_card_back,</if>
<if test="idCardHand != null">id_card_hand,</if>
<if test="video != null">video,</if>
<if test="videoWords != null">video_words,</if>
<if test="businessLicence != null">business_licence,</if>
<if test="verifyId != null">verify_id,</if>
<if test="verifyBy != null">verify_by,</if>
<if test="verifyRemark != null">verify_remark,</if>
<if test="verifyTime != null">verify_time,</if>
<if test="verifyStatus != null">verify_status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
@ -78,6 +108,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if>
<if test="realNameId != null">#{realNameId},</if>
<if test="unsealSelf != null">#{unsealSelf},</if>
<if test="submitType != null">#{submitType,typeHandler=com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler},</if>
<if test="idCardFront != null">#{idCardFront},</if>
<if test="idCardBack != null">#{idCardBack},</if>
<if test="idCardHand != null">#{idCardHand},</if>
<if test="video != null">#{video},</if>
<if test="videoWords != null">#{videoWords},</if>
<if test="businessLicence != null">#{businessLicence},</if>
<if test="verifyId != null">#{verifyId},</if>
<if test="verifyBy != null">#{verifyBy},</if>
<if test="verifyRemark != null">#{verifyRemark},</if>
<if test="verifyTime != null">#{verifyTime},</if>
<if test="verifyStatus != null">#{verifyStatus},</if>
</trim>
</insert>
@ -89,15 +131,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where risk_id = #{data.riskId}
</update>
<update id="batchFinish">
<update id="batchSetRealName">
update ss_risk
set end_time = #{endTime},
real_name_id = #{realNameId}
set real_name_id = #{realNameId}
where risk_id in
<foreach item="item" collection="riskIds" open="(" separator="," close=")">
#{item}
</foreach>
and unseal_self = true
</update>
<sql id="updateColumns">
@ -108,6 +148,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="data.createTime != null">create_time = #{data.createTime},</if>
<if test="data.realNameId != null">real_name_id = #{data.realNameId},</if>
<if test="data.unsealSelf != null">unseal_self = #{data.unsealSelf},</if>
<if test="data.submitType != null">submit_type = #{data.submitType,typeHandler=com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler},</if>
<if test="data.idCardFront != null">id_card_front = #{data.idCardFront},</if>
<if test="data.idCardBack != null">id_card_back = #{data.idCardBack},</if>
<if test="data.idCardHand != null">id_card_hand = #{data.idCardHand},</if>
<if test="data.video != null">video = #{data.video},</if>
<if test="data.videoWords != null">video_words = #{data.videoWords},</if>
<if test="data.businessLicence != null">business_licence = #{data.businessLicence},</if>
<if test="data.verifyId != null">verify_id = #{data.verifyId},</if>
<if test="data.verifyBy != null">verify_by = #{data.verifyBy},</if>
<if test="data.verifyRemark != null">verify_remark = #{data.verifyRemark},</if>
<if test="data.verifyTime != null">verify_time = #{data.verifyTime},</if>
<if test="data.verifyStatus != null">verify_status = #{data.verifyStatus},</if>
</sql>
<delete id="deleteRiskByRiskId" parameterType="Long">

View File

@ -67,9 +67,9 @@ public interface RiskService
List<RiskVO> selectNotFinishedList(RiskQuery query);
/**
* 批量结束
* 批量设置实名认证ID
*/
int batchFinish(List<Long> riskIds, Long realNameId);
int batchSetRealName(List<Long> riskIds, Long realNameId);
/**
* 限制提现
@ -77,4 +77,9 @@ public interface RiskService
* @param reason 限制原因
*/
int limitWithdraw(Long userId, String reason);
/**
* 修改风控实名认证ID
*/
int updateRealNameId(Long riskId, Long realNameId);
}

View File

@ -0,0 +1,14 @@
package com.ruoyi.ss.risk.service;
import com.ruoyi.ss.risk.domain.RiskVO;
/**
* @author wjh
* 2024/11/23
*/
public interface RiskValidator {
/**
* 判断风控是否属于当前用户
*/
boolean isUser(RiskVO risk, Long userId);
}

View File

@ -106,11 +106,11 @@ public class RiskServiceImpl implements RiskService
}
@Override
public int batchFinish(List<Long> riskIds, Long realNameId) {
public int batchSetRealName(List<Long> riskIds, Long realNameId) {
if (CollectionUtils.isEmptyElement(riskIds)) {
return 0;
}
return riskMapper.batchFinish(riskIds, LocalDateTime.now(), realNameId);
return riskMapper.batchSetRealName(riskIds, realNameId);
}
@Override
@ -123,4 +123,15 @@ public class RiskServiceImpl implements RiskService
risk.setUnsealSelf(true);
return this.insertRisk(risk);
}
@Override
public int updateRealNameId(Long riskId, Long realNameId) {
if (riskId == null || realNameId == null) {
return 0;
}
Risk data = new Risk();
data.setRiskId(riskId);
data.setRealNameId(realNameId);
return this.updateRisk(data);
}
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.ss.risk.service.impl;
import com.ruoyi.ss.risk.domain.RiskVO;
import com.ruoyi.ss.risk.service.RiskValidator;
import org.springframework.stereotype.Service;
import java.util.Objects;
import static com.ruoyi.common.utils.SecurityUtils.getUserId;
/**
* @author wjh
* 2024/11/23
*/
@Service
public class RiskValidatorImpl implements RiskValidator {
@Override
public boolean isUser(RiskVO risk, Long userId) {
return risk != null && userId != null && Objects.equals(risk.getUserId(), getUserId());
}
}

View File

@ -17,4 +17,7 @@ public class UserFaceDTO {
private String idCard;
private String mobile;
// 风控ID
private Long riskId;
}

View File

@ -39,4 +39,7 @@ public class UserRealNameDTO {
@Pattern(regexp = RegexpUtils.MOBILE_PHONE_REGEXP, message = "手机号格式错误")
private String realPhone;
@ApiModelProperty("风控ID")
private Long riskId;
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.ss.user.service;
import com.ruoyi.common.core.domain.entity.SmUser;
import com.ruoyi.common.enums.UserType;
import com.ruoyi.ss.recordBalance.domain.enums.RecordBalanceBstType;
import com.ruoyi.ss.risk.domain.RiskVO;
import com.ruoyi.ss.user.domain.SmUserQuery;
import com.ruoyi.ss.user.domain.SmUserVO;
import com.ruoyi.ss.user.domain.dto.UserRealNameDTO;
@ -255,7 +256,7 @@ public interface ISmUserService
/**
* 风控实名认证
*
* @param userId@return
* @param risk @return
*/
UserRealNameVO riskRealName(Long userId);
UserRealNameVO riskRealName(RiskVO risk);
}

View File

@ -32,9 +32,8 @@ import com.ruoyi.ss.realName.service.RealNameService;
import com.ruoyi.ss.realName.service.RealNameValidator;
import com.ruoyi.ss.recordBalance.domain.enums.RecordBalanceBstType;
import com.ruoyi.ss.recordBalance.service.RecordBalanceService;
import com.ruoyi.ss.risk.domain.Risk;
import com.ruoyi.ss.risk.domain.RiskQuery;
import com.ruoyi.ss.risk.domain.RiskVO;
import com.ruoyi.ss.risk.domain.enums.RiskSubmitType;
import com.ruoyi.ss.risk.service.RiskService;
import com.ruoyi.ss.store.domain.StoreQuery;
import com.ruoyi.ss.store.domain.StoreVo;
@ -384,6 +383,7 @@ public class SmUserServiceImpl implements ISmUserService
faceDto.setMobile(dto.getRealPhone());
faceDto.setIdCard(dto.getRealIdCard());
faceDto.setType(dto.getType());
faceDto.setRiskId(dto.getRiskId());
redisCache.setCacheObject(cacheKey, faceDto, 10, TimeUnit.MINUTES);
// 返回数据
@ -453,7 +453,7 @@ public class SmUserServiceImpl implements ISmUserService
}
// 风控实名修改用户风控信息
else {
return this.handleRiskRealName(realName, cacheKey);
return this.handleRiskRealName(realName, cacheKey, face.getRiskId());
}
}
@ -462,22 +462,19 @@ public class SmUserServiceImpl implements ISmUserService
* @param realName 实名认证
* @param cacheKey 缓存key
*/
private int handleRiskRealName(RealName realName, String cacheKey) {
private int handleRiskRealName(RealName realName, String cacheKey, Long riskId) {
// 查询用户是否有风控信息
RiskQuery query = new RiskQuery();
query.setUserId(realName.getUserId());
List<RiskVO> riskList = riskService.selectNotFinishedList(query);
RiskVO risk = riskService.selectRiskByRiskId(riskId);
ServiceUtil.assertion(risk == null, "风控信息不存在");
Integer result = transactionTemplate.execute(status -> {
// 插入实名认证信息
int insert = realNameService.insertRealName(realName);
ServiceUtil.assertion(insert != 1, "新增实名认证失败");
// 修改风控信息
if (CollectionUtils.isNotEmptyElement(riskList)) {
int update = riskService.batchFinish(CollectionUtils.map(riskList, Risk::getRiskId), realName.getId());
ServiceUtil.assertion(update != riskList.size(), "修改风控信息失败");
}
// 修改实名认证ID
int update = riskService.updateRealNameId(riskId, realName.getId());
ServiceUtil.assertion(update != 1, "修改风控信息失败");
// 删除缓存
redisCache.deleteObject(cacheKey);
@ -585,12 +582,19 @@ public class SmUserServiceImpl implements ISmUserService
}
@Override
public UserRealNameVO riskRealName(Long userId) {
public UserRealNameVO riskRealName(RiskVO risk) {
UserRealNameDTO dto = new UserRealNameDTO();
dto.setType(RealNameType.RISK.getType());
dto.setUserId(userId);
SmUserVO user = this.selectSmUserByUserId(dto.getUserId());
ServiceUtil.assertion(risk == null, "风控信息不存在");
ServiceUtil.assertion(risk.getIsFinished() != null && risk.getIsFinished(), "当前风控已结束,无需实名认证");
ServiceUtil.assertion(CollectionUtils.isEmpty(risk.getSubmitType())
|| !risk.getSubmitType().contains(RiskSubmitType.REAL_NAME.getCode()),
"当前风控无需提交实名认证"
);
dto.setRiskId(risk.getRiskId());
SmUserVO user = this.selectSmUserByUserId(risk.getUserId());
if (user.getIsReal()) {
if (user.getRealName() != null) {
dto.setRealName(user.getRealName());

View File

@ -14,6 +14,9 @@ import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.service.SysPasswordService;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.ss.realName.domain.enums.RealNameType;
import com.ruoyi.ss.risk.domain.RiskVO;
import com.ruoyi.ss.risk.service.RiskService;
import com.ruoyi.ss.risk.service.RiskValidator;
import com.ruoyi.ss.user.domain.SmUserQuery;
import com.ruoyi.ss.user.domain.SmUserVO;
import com.ruoyi.ss.user.domain.dto.UserChangeMobileDTO;
@ -33,6 +36,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* 用户信息Controller
@ -62,6 +66,12 @@ public class AppUserController extends BaseController {
@Autowired
private UserConverter userConvert;
@Autowired
private RiskService riskService;
@Autowired
private RiskValidator riskValidator;
@ApiOperation("获取当前登录前台用户的信息")
@GetMapping("/userInfo")
@JsonView(JsonViewProfile.AppMch.class)
@ -112,8 +122,10 @@ public class AppUserController extends BaseController {
@ApiOperation("用户风控实名认证")
@PutMapping("/riskRealName")
public AjaxResult riskRealName() {
return success(userService.riskRealName(getUserId()));
public AjaxResult riskRealName(@RequestParam Long riskId) {
RiskVO risk = riskService.selectRiskByRiskId(riskId);
ServiceUtil.assertion(!riskValidator.isUser(risk, getUserId()), "风控信息不存在");
return success(userService.riskRealName(risk));
}
@ApiOperation("刷新用户实名认证结果")