From 0a14baad1619b92ebf5fe57cd385b6244323f8b9 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: Thu, 28 Nov 2024 10:56:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/redis/enums/RedisLockKey.java | 3 +- .../ss/risk/domain/enums/RiskSubmitType.java | 3 +- .../ss/riskInfo/domain/RiskInfoQuery.java | 2 + .../ss/riskInfo/mapper/RiskInfoMapper.xml | 3 + .../service/impl/RiskInfoServiceImpl.java | 63 ++++++++++++------- .../service/impl/RiskInfoValidatorImpl.java | 18 ++++++ .../staff/StaffDashboardController.java | 21 +++++++ 7 files changed, 88 insertions(+), 25 deletions(-) create mode 100644 smart-switch-web/src/main/java/com/ruoyi/web/controller/staff/StaffDashboardController.java diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/redis/enums/RedisLockKey.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/redis/enums/RedisLockKey.java index 8065e84b..0827703c 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/redis/enums/RedisLockKey.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/redis/enums/RedisLockKey.java @@ -26,7 +26,8 @@ public enum RedisLockKey { PAY_BILL_SUCCESS("pay_bill_success", "支付订单成功处理"), RECOVER_DEVICE_BALANCE("recover_device_balance", "恢复设备余额"), ADD_USER_WX_OPEN_ID("add_user_wx_open_id", "微信注册用户"), - ADD_USER_MOBILE("add_user_mobile", "手机号注册用户"); + ADD_USER_MOBILE("add_user_mobile", "手机号注册用户"), + SUBMIT_RISK_INFO("submit_risk_info", "提交风控材料"); private final String key; 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 index 675edbad..4ecda997 100644 --- 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 @@ -14,7 +14,8 @@ public enum RiskSubmitType { ID_CARD("2", "身份证正反面"), ID_CARD_HAND("3", "手持身份证照片"), VIDEO("4", "使用场景视频"), - BUSINESS_LICENCE("5", "营业执照"); + BUSINESS_LICENCE("5", "营业执照"), + DUTY_VIDEO("6", "责任视频"); private final String code; private final String msg; diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/domain/RiskInfoQuery.java b/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/domain/RiskInfoQuery.java index 43b3b93c..5415c3bf 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/domain/RiskInfoQuery.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/domain/RiskInfoQuery.java @@ -15,4 +15,6 @@ public class RiskInfoQuery extends RiskInfoVO { @ApiModelProperty("状态列表") private List statusList; + @ApiModelProperty("排除的ID") + private Long excludeInfoId; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/mapper/RiskInfoMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/mapper/RiskInfoMapper.xml index c577e26b..0331d44d 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/mapper/RiskInfoMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/mapper/RiskInfoMapper.xml @@ -54,6 +54,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and sri.verify_remark like concat('%', #{query.verifyRemark}, '%') and sr.user_id = #{query.userId} and if(su.is_real, su.real_name, su.user_name) like concat('%', #{query.userName}, '%') + + and sri.info_id != #{query.excludeInfoId} + and sri.status in diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/impl/RiskInfoServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/impl/RiskInfoServiceImpl.java index 12b70f4a..931b2e42 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/impl/RiskInfoServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/impl/RiskInfoServiceImpl.java @@ -4,6 +4,8 @@ import java.time.LocalDateTime; import java.util.List; import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.redis.RedisLock; +import com.ruoyi.common.core.redis.enums.RedisLockKey; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.ServiceUtil; @@ -41,6 +43,9 @@ public class RiskInfoServiceImpl implements RiskInfoService @Autowired private RiskService riskService; + @Autowired + private RedisLock redisLock; + /** * 查询风控材料 * @@ -124,31 +129,41 @@ public class RiskInfoServiceImpl implements RiskInfoService // 校验数据 RiskInfoVO old = this.selectRiskInfoByInfoId(infoId); - riskInfoValidator.preSubmitCheck(old); + ServiceUtil.assertion(old == null || old.getRiskId() == null, "待提交的数据不存在"); + Long lockKey = old.getRiskId(); + ServiceUtil.assertion(!redisLock.lock(RedisLockKey.SUBMIT_RISK_INFO, lockKey), "正在处理,请勿重复提交"); - Integer result = transactionTemplate.execute(status -> { - RiskInfoVO data = new RiskInfoVO(); - data.setSubmitTime(LocalDateTime.now()); - data.setStatus(RiskInfoStatus.WAIT_VERIFY.getStatus()); - RiskInfoQuery query = new RiskInfoQuery(); - query.setInfoId(infoId); - query.setStatusList(RiskInfoStatus.canSubmit()); - int submit = this.updateByQuery(data, query); - ServiceUtil.assertion(submit != 1, "提交失败"); + try { + // 校验 + riskInfoValidator.preSubmitCheck(old); + // 操作 + Integer result = transactionTemplate.execute(status -> { + RiskInfoVO data = new RiskInfoVO(); + data.setSubmitTime(LocalDateTime.now()); + data.setStatus(RiskInfoStatus.WAIT_VERIFY.getStatus()); + RiskInfoQuery query = new RiskInfoQuery(); + query.setInfoId(infoId); + query.setStatusList(RiskInfoStatus.canSubmit()); + int submit = this.updateByQuery(data, query); + ServiceUtil.assertion(submit != 1, "提交失败"); - // 若开启了提交后自动通过,则直接通过 - if (old.getRiskUnsealSelf() != null && old.getRiskUnsealSelf()) { - RiskInfoVerifyDTO dto = new RiskInfoVerifyDTO(); - dto.setInfoId(infoId); - dto.setPass(true); - dto.setVerifyRemark("免审核通过"); - this.verify(dto, LoginUser.system()); - } + // 若开启了提交后自动通过,则直接通过 + if (old.getRiskUnsealSelf() != null && old.getRiskUnsealSelf()) { + RiskInfoVerifyDTO dto = new RiskInfoVerifyDTO(); + dto.setInfoId(infoId); + dto.setPass(true); + dto.setVerifyRemark("免审核通过"); + this.verify(dto, LoginUser.system()); + } - return submit; - }); + return submit; + }); + + return result == null ? 0 : result; + } finally { + redisLock.unlock(RedisLockKey.SUBMIT_RISK_INFO, lockKey); + } - return result == null ? 0 : result; } @Override @@ -185,8 +200,10 @@ public class RiskInfoServiceImpl implements RiskInfoService ServiceUtil.assertion(update != 1, "当前风控材料状态已发生变化,请刷新后重试"); // 解封 - int finish = riskService.finish(old.getRiskId()); - ServiceUtil.assertion(finish != 1, "解封失败,请重试"); + if (dto.getPass() != null && dto.getPass()) { + int finish = riskService.finish(old.getRiskId()); + ServiceUtil.assertion(finish != 1, "解封失败,请重试"); + } return update; }); diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/impl/RiskInfoValidatorImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/impl/RiskInfoValidatorImpl.java index 6d1137ff..57bb19fc 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/impl/RiskInfoValidatorImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/impl/RiskInfoValidatorImpl.java @@ -8,6 +8,7 @@ import com.ruoyi.ss.realName.service.RealNameService; import com.ruoyi.ss.risk.domain.enums.RiskSubmitType; import com.ruoyi.ss.risk.service.RiskValidator; import com.ruoyi.ss.riskInfo.domain.RiskInfo; +import com.ruoyi.ss.riskInfo.domain.RiskInfoQuery; import com.ruoyi.ss.riskInfo.domain.RiskInfoVO; import com.ruoyi.ss.riskInfo.domain.enums.RiskInfoStatus; import com.ruoyi.ss.riskInfo.service.RiskInfoService; @@ -71,6 +72,9 @@ public class RiskInfoValidatorImpl implements RiskInfoValidator { ServiceUtil.assertion(data == null, "参数错误"); ServiceUtil.assertion(!RiskInfoStatus.canSubmit().contains(data.getStatus()), "风控材料当前状态不允许提交"); + // 判断是否已有提交的,不允许重复提交 + this.checkRepeatSubmit(data.getRiskId(), data.getInfoId()); + if (CollectionUtils.isEmptyElement(data.getRiskSubmitType())) { return; } @@ -89,9 +93,23 @@ public class RiskInfoValidatorImpl implements RiskInfoValidator { if (types.contains(RiskSubmitType.VIDEO.getCode())) { ServiceUtil.assertion(StringUtils.isAnyBlank(data.getVideo()), "请上传使用场景视频"); } + if (types.contains(RiskSubmitType.DUTY_VIDEO.getCode())) { + ServiceUtil.assertion(StringUtils.isAnyBlank(data.getDutyVideo()), "请上传责任视频"); + } if (types.contains(RiskSubmitType.BUSINESS_LICENCE.getCode())) { ServiceUtil.assertion(StringUtils.isAnyBlank(data.getBusinessLicence()), "请上传营业执照"); } } + + private void checkRepeatSubmit(Long riskId, Long infoId) { + if (riskId == null) { + return; + } + RiskInfoQuery query = new RiskInfoQuery(); + query.setRiskId(riskId); + query.setExcludeInfoId(infoId); + query.setStatus(RiskInfoStatus.WAIT_VERIFY.getStatus()); + ServiceUtil.assertion(riskInfoService.selectCount(query) > 0, "当前风控有正在审核中的材料,请勿重复提交"); + } } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/staff/StaffDashboardController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/staff/StaffDashboardController.java new file mode 100644 index 00000000..d1884def --- /dev/null +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/staff/StaffDashboardController.java @@ -0,0 +1,21 @@ +package com.ruoyi.web.controller.staff; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.dashboard.service.DashboardService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 合伙人报表Controller + * @author wjh + * 2024/11/28 + */ +@RestController +@RequestMapping("/staff/dashboard") +public class StaffDashboardController extends BaseController { + + @Autowired + DashboardService dashboardService; + +}