From 1c8a9d78de162095eab57c3cc08cb6dd00601dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?= <14103883+leaf-phos@user.noreply.gitee.com> Date: Sat, 23 Nov 2024 18:00:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=8E=E6=8E=A7=E5=AE=9E=E5=90=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=88=E4=B8=80=E5=8D=8A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/ss/risk/domain/Risk.java | 57 ++++++++++++++++-- .../ss/risk/domain/enums/RiskSubmitType.java | 22 +++++++ .../com/ruoyi/ss/risk/mapper/RiskMapper.java | 6 +- .../com/ruoyi/ss/risk/mapper/RiskMapper.xml | 60 +++++++++++++++++-- .../ruoyi/ss/risk/service/RiskService.java | 9 ++- .../ruoyi/ss/risk/service/RiskValidator.java | 14 +++++ .../ss/risk/service/impl/RiskServiceImpl.java | 15 ++++- .../risk/service/impl/RiskValidatorImpl.java | 21 +++++++ .../ruoyi/ss/user/domain/dto/UserFaceDTO.java | 3 + .../ss/user/domain/dto/UserRealNameDTO.java | 3 + .../ruoyi/ss/user/service/ISmUserService.java | 5 +- .../user/service/impl/SmUserServiceImpl.java | 34 ++++++----- .../web/controller/app/AppUserController.java | 16 ++++- 13 files changed, 230 insertions(+), 35 deletions(-) create mode 100644 smart-switch-service/src/main/java/com/ruoyi/ss/risk/domain/enums/RiskSubmitType.java create mode 100644 smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/RiskValidator.java create mode 100644 smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/impl/RiskValidatorImpl.java diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/domain/Risk.java b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/domain/Risk.java index b1488e24..a4284f6f 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/domain/Risk.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/domain/Risk.java @@ -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 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; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/domain/enums/RiskSubmitType.java b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/domain/enums/RiskSubmitType.java new file mode 100644 index 00000000..675edbad --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/domain/enums/RiskSubmitType.java @@ -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; + +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/mapper/RiskMapper.java b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/mapper/RiskMapper.java index 6a58bed1..a1b930f9 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/mapper/RiskMapper.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/mapper/RiskMapper.java @@ -66,10 +66,8 @@ public interface RiskMapper /** * 批量修改结束时间 * @param riskIds ID列表 - * @param endTime 结束时间 * @return */ - int batchFinish(@Param("riskIds") List riskIds, - @Param("endTime") LocalDateTime endTime, - @Param("realNameId") Long realNameId); + int batchSetRealName(@Param("riskIds") List riskIds, + @Param("realNameId") Long realNameId); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/mapper/RiskMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/mapper/RiskMapper.xml index 50e5d894..58cb6de2 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/mapper/RiskMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/mapper/RiskMapper.xml @@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -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, 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" and sr.real_name_id = #{query.realNameId} and unseal_self = #{query.unsealSelf} + and video_words like concat('%', #{query.videoWords}, '%') + and verify_id = #{query.verifyId} + and verify_by like concat('%', #{query.verifyBy}, '%') + and verify_remark like concat('%', #{query.verifyRemark}, '%') + and verify_status = #{query.verifyStatus} and and ! @@ -69,6 +87,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_time, real_name_id, unseal_self, + submit_type, + id_card_front, + id_card_back, + id_card_hand, + video, + video_words, + business_licence, + verify_id, + verify_by, + verify_remark, + verify_time, + verify_status, #{userId}, @@ -78,6 +108,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{createTime}, #{realNameId}, #{unsealSelf}, + #{submitType,typeHandler=com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler}, + #{idCardFront}, + #{idCardBack}, + #{idCardHand}, + #{video}, + #{videoWords}, + #{businessLicence}, + #{verifyId}, + #{verifyBy}, + #{verifyRemark}, + #{verifyTime}, + #{verifyStatus}, @@ -89,15 +131,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where risk_id = #{data.riskId} - + update ss_risk - set end_time = #{endTime}, - real_name_id = #{realNameId} + set real_name_id = #{realNameId} where risk_id in #{item} - and unseal_self = true @@ -108,6 +148,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_time = #{data.createTime}, real_name_id = #{data.realNameId}, unseal_self = #{data.unsealSelf}, + submit_type = #{data.submitType,typeHandler=com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler}, + id_card_front = #{data.idCardFront}, + id_card_back = #{data.idCardBack}, + id_card_hand = #{data.idCardHand}, + video = #{data.video}, + video_words = #{data.videoWords}, + business_licence = #{data.businessLicence}, + verify_id = #{data.verifyId}, + verify_by = #{data.verifyBy}, + verify_remark = #{data.verifyRemark}, + verify_time = #{data.verifyTime}, + verify_status = #{data.verifyStatus}, diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/RiskService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/RiskService.java index 39c5b9da..1cc16128 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/RiskService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/RiskService.java @@ -67,9 +67,9 @@ public interface RiskService List selectNotFinishedList(RiskQuery query); /** - * 批量结束 + * 批量设置实名认证ID */ - int batchFinish(List riskIds, Long realNameId); + int batchSetRealName(List 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); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/RiskValidator.java b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/RiskValidator.java new file mode 100644 index 00000000..a0591355 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/RiskValidator.java @@ -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); +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/impl/RiskServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/impl/RiskServiceImpl.java index 1c9af353..2fac8346 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/impl/RiskServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/impl/RiskServiceImpl.java @@ -106,11 +106,11 @@ public class RiskServiceImpl implements RiskService } @Override - public int batchFinish(List riskIds, Long realNameId) { + public int batchSetRealName(List 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); + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/impl/RiskValidatorImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/impl/RiskValidatorImpl.java new file mode 100644 index 00000000..d0706506 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/impl/RiskValidatorImpl.java @@ -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()); + } +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/domain/dto/UserFaceDTO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/domain/dto/UserFaceDTO.java index 51c88cd4..589902c7 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/domain/dto/UserFaceDTO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/domain/dto/UserFaceDTO.java @@ -17,4 +17,7 @@ public class UserFaceDTO { private String idCard; private String mobile; + // 风控ID + private Long riskId; + } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/domain/dto/UserRealNameDTO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/domain/dto/UserRealNameDTO.java index e0609925..02740afc 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/domain/dto/UserRealNameDTO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/domain/dto/UserRealNameDTO.java @@ -39,4 +39,7 @@ public class UserRealNameDTO { @Pattern(regexp = RegexpUtils.MOBILE_PHONE_REGEXP, message = "手机号格式错误") private String realPhone; + @ApiModelProperty("风控ID") + private Long riskId; + } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/ISmUserService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/ISmUserService.java index ef9b6bef..0fd62026 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/ISmUserService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/ISmUserService.java @@ -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); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/SmUserServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/SmUserServiceImpl.java index 6f70b056..6b22379f 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/SmUserServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/SmUserServiceImpl.java @@ -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 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()); diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppUserController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppUserController.java index 6358d9b0..2a712d6f 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppUserController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppUserController.java @@ -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("刷新用户实名认证结果")