mirror of
https://gitee.com/dromara/dax-pay
synced 2026-08-10 06:46:04 +08:00
refactor(risk): 风险命中记录移除运营处置流程, 删除 handle 接口/枚举/参数与处理字段
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"pending": "Pending",
|
||||
"ignored": "Ignored",
|
||||
"added_blacklist": "Added to blacklist",
|
||||
"merchant_disabled": "Merchant marked disabled",
|
||||
"other": "Other"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"pending": "Pending",
|
||||
"ignored": "Ignored",
|
||||
"added_blacklist": "Added to blacklist",
|
||||
"merchant_disabled": "Merchant marked disabled",
|
||||
"other": "Other"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"pending": "Pending",
|
||||
"ignored": "Ignored",
|
||||
"added_blacklist": "Added to blacklist",
|
||||
"merchant_disabled": "Merchant marked disabled",
|
||||
"other": "Other"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"pending": "Pending",
|
||||
"ignored": "Ignored",
|
||||
"added_blacklist": "Added to blacklist",
|
||||
"merchant_disabled": "Merchant marked disabled",
|
||||
"other": "Other"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"pending": "Pending",
|
||||
"ignored": "Ignored",
|
||||
"added_blacklist": "Added to blacklist",
|
||||
"merchant_disabled": "Merchant marked disabled",
|
||||
"other": "Other"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"pending": "Pending",
|
||||
"ignored": "Ignored",
|
||||
"added_blacklist": "Added to blacklist",
|
||||
"merchant_disabled": "Merchant marked disabled",
|
||||
"other": "Other"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"pending": "Pending",
|
||||
"ignored": "Ignored",
|
||||
"added_blacklist": "Added to blacklist",
|
||||
"merchant_disabled": "Merchant marked disabled",
|
||||
"other": "Other"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"pending": "待处理",
|
||||
"ignored": "已忽略",
|
||||
"added_blacklist": "已加入黑名单",
|
||||
"merchant_disabled": "已标记停用商户",
|
||||
"other": "其他"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"pending": "待处理",
|
||||
"ignored": "已忽略",
|
||||
"added_blacklist": "已加入黑名单",
|
||||
"merchant_disabled": "已标记停用商户",
|
||||
"other": "其他"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"pending": "待处理",
|
||||
"ignored": "已忽略",
|
||||
"added_blacklist": "已加入黑名单",
|
||||
"merchant_disabled": "已标记停用商户",
|
||||
"other": "其他"
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import cn.daxpay.open.platform.core.rest.Res;
|
||||
import cn.daxpay.open.platform.core.rest.param.PageParam;
|
||||
import cn.daxpay.open.platform.core.rest.result.PageResult;
|
||||
import cn.daxpay.open.platform.core.rest.result.Result;
|
||||
import cn.daxpay.open.plugin.risk.param.PayRiskHitHandleParam;
|
||||
import cn.daxpay.open.plugin.risk.param.PayRiskHitQuery;
|
||||
import cn.daxpay.open.plugin.risk.result.PayRiskHitResult;
|
||||
import cn.daxpay.open.plugin.risk.service.PayRiskHitService;
|
||||
@@ -42,12 +41,4 @@ public class PayRiskHitAdminController {
|
||||
public Result<PayRiskHitResult> get(@NotNull(message = "{validation.field.id.notNull}") Long id) {
|
||||
return Res.ok(payRiskHitService.findById(id));
|
||||
}
|
||||
|
||||
@PermCode(code = PermCodes.Action.MANAGE)
|
||||
@Operation(summary = "处理命中")
|
||||
@PostMapping("/handle")
|
||||
public Result<Void> handle(@RequestBody @Validated PayRiskHitHandleParam param) {
|
||||
payRiskHitService.handle(param);
|
||||
return Res.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package cn.daxpay.open.plugin.risk.entity;
|
||||
import cn.daxpay.open.platform.common.mybatisplus.base.MpBaseEntity;
|
||||
import cn.daxpay.open.platform.common.mybatisplus.function.ToResult;
|
||||
import cn.daxpay.open.plugin.risk.convert.PayRiskHitConvert;
|
||||
import cn.daxpay.open.plugin.risk.enums.PayRiskHitHandleStatusEnum;
|
||||
import cn.daxpay.open.plugin.risk.enums.PayRiskHitPhaseEnum;
|
||||
import cn.daxpay.open.plugin.risk.enums.PayRiskHitSceneEnum;
|
||||
import cn.daxpay.open.plugin.risk.result.PayRiskHitResult;
|
||||
@@ -13,8 +12,6 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/// # 支付风险命中记录
|
||||
///
|
||||
/// 记录事前拦截与事后命中,供运营预警与处置。
|
||||
@@ -78,19 +75,6 @@ public class PayRiskHit extends MpBaseEntity implements ToResult<PayRiskHitResul
|
||||
/// @see PayRiskHitSceneEnum
|
||||
private String scene;
|
||||
|
||||
/// 处理状态
|
||||
/// @see PayRiskHitHandleStatusEnum
|
||||
private String handleStatus;
|
||||
|
||||
/// 处理说明
|
||||
private String handleRemark;
|
||||
|
||||
/// 处理人
|
||||
private Long handleUserId;
|
||||
|
||||
/// 处理时间
|
||||
private OffsetDateTime handleTime;
|
||||
|
||||
/// 备注
|
||||
private String remark;
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package cn.daxpay.open.plugin.risk.enums;
|
||||
|
||||
import cn.daxpay.open.platform.core.i18n.I18nSupport;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
/// # 风险命中处理状态
|
||||
///
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum PayRiskHitHandleStatusEnum implements I18nSupport {
|
||||
|
||||
/// 待处理
|
||||
PENDING("pending"),
|
||||
/// 已忽略
|
||||
IGNORED("ignored"),
|
||||
/// 已加入黑名单
|
||||
ADDED_BLACKLIST("added_blacklist"),
|
||||
/// 已标记停用商户(仅状态,不自动改商户)
|
||||
MERCHANT_DISABLED("merchant_disabled"),
|
||||
/// 其他
|
||||
OTHER("other");
|
||||
|
||||
private final String code;
|
||||
|
||||
@Override
|
||||
public String getI18nPrefix() {
|
||||
return "enum.pay_risk_hit_handle_status";
|
||||
}
|
||||
|
||||
public static Optional<PayRiskHitHandleStatusEnum> findByCode(String code) {
|
||||
return Arrays.stream(values()).filter(e -> e.code.equals(code)).findFirst();
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package cn.daxpay.open.plugin.risk.param;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/// # 风险命中处理参数
|
||||
///
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "风险命中处理参数")
|
||||
public class PayRiskHitHandleParam {
|
||||
|
||||
@Schema(description = "主键")
|
||||
@NotNull(message = "{validation.field.id.notNull}")
|
||||
private Long id;
|
||||
|
||||
/// 处理状态:ignored / added_blacklist / merchant_disabled / other
|
||||
@Schema(description = "处理状态")
|
||||
@NotBlank(message = "{validation.field.status.notBlank}")
|
||||
@Size(max = 32, message = "{validation.field.product.size}")
|
||||
private String handleStatus;
|
||||
|
||||
@Schema(description = "处理说明")
|
||||
@Size(max = 500, message = "{validation.field.remark.size}")
|
||||
private String handleRemark;
|
||||
}
|
||||
@@ -29,9 +29,6 @@ public class PayRiskHitQuery {
|
||||
@Schema(description = "商户号")
|
||||
private String mchNo;
|
||||
|
||||
@Schema(description = "处理状态")
|
||||
private String handleStatus;
|
||||
|
||||
@Schema(description = "来源场景")
|
||||
private String scene;
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/// # 风险命中结果
|
||||
///
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -78,18 +76,6 @@ public class PayRiskHitResult extends BaseResult {
|
||||
@Schema(description = "来源场景")
|
||||
private String scene;
|
||||
|
||||
@Schema(description = "处理状态")
|
||||
private String handleStatus;
|
||||
|
||||
@Schema(description = "处理说明")
|
||||
private String handleRemark;
|
||||
|
||||
@Schema(description = "处理人")
|
||||
private Long handleUserId;
|
||||
|
||||
@Schema(description = "处理时间")
|
||||
private OffsetDateTime handleTime;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
package cn.daxpay.open.plugin.risk.service;
|
||||
|
||||
import cn.daxpay.open.payment.strategy.risk.PayRiskCheckContext;
|
||||
import cn.daxpay.open.platform.capability.auth.util.SecurityUtil;
|
||||
import cn.daxpay.open.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.daxpay.open.platform.common.translate.service.TransService;
|
||||
import cn.daxpay.open.platform.core.code.PayErrorCode;
|
||||
import cn.daxpay.open.platform.core.exception.BizInfoException;
|
||||
import cn.daxpay.open.platform.core.exception.DataNotExistException;
|
||||
import cn.daxpay.open.platform.core.rest.param.PageParam;
|
||||
import cn.daxpay.open.platform.core.rest.result.PageResult;
|
||||
import cn.daxpay.open.plugin.risk.dao.PayRiskHitManager;
|
||||
import cn.daxpay.open.plugin.risk.entity.PayBlacklist;
|
||||
import cn.daxpay.open.plugin.risk.entity.PayRiskHit;
|
||||
import cn.daxpay.open.plugin.risk.enums.PayRiskHitHandleStatusEnum;
|
||||
import cn.daxpay.open.plugin.risk.enums.PayRiskHitPhaseEnum;
|
||||
import cn.daxpay.open.plugin.risk.enums.PayRiskHitSceneEnum;
|
||||
import cn.daxpay.open.plugin.risk.param.PayRiskHitHandleParam;
|
||||
import cn.daxpay.open.plugin.risk.param.PayRiskHitQuery;
|
||||
import cn.daxpay.open.plugin.risk.result.PayRiskHitResult;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -24,9 +18,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
|
||||
/// # 风险命中服务
|
||||
///
|
||||
@Slf4j
|
||||
@@ -35,7 +26,6 @@ import java.time.ZoneOffset;
|
||||
public class PayRiskHitService {
|
||||
|
||||
private final PayRiskHitManager payRiskHitManager;
|
||||
private final PayBlacklistService payBlacklistService;
|
||||
private final TransService transService;
|
||||
|
||||
/// 分页
|
||||
@@ -54,30 +44,6 @@ public class PayRiskHitService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/// 处理命中
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void handle(PayRiskHitHandleParam param) {
|
||||
PayRiskHitHandleStatusEnum status = PayRiskHitHandleStatusEnum.findByCode(param.getHandleStatus())
|
||||
.orElseThrow(() -> new BizInfoException(PayErrorCode.OPERATION_FAIL,
|
||||
"pay.error.risk.handleStatusInvalid"));
|
||||
PayRiskHit entity = getEntity(param.getId());
|
||||
if (status == PayRiskHitHandleStatusEnum.ADDED_BLACKLIST) {
|
||||
// 微信名单需 wxAppId;命中快照无该字段时无法自动写入
|
||||
PayBlacklist bl = payBlacklistService.ensureBlacklist(
|
||||
entity.getHitType(),
|
||||
entity.getHitValue(),
|
||||
entity.getChannel(),
|
||||
null,
|
||||
param.getHandleRemark());
|
||||
entity.setBlacklistId(bl.getId());
|
||||
}
|
||||
entity.setHandleStatus(status.getCode());
|
||||
entity.setHandleRemark(param.getHandleRemark());
|
||||
entity.setHandleUserId(SecurityUtil.getUserIdOrDefaultId());
|
||||
entity.setHandleTime(OffsetDateTime.now(ZoneOffset.UTC));
|
||||
payRiskHitManager.updateById(entity);
|
||||
}
|
||||
|
||||
/// 记录命中(支付接入 / 检查器调用)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void recordHit(PayRiskCheckContext ctx, String hitType, String hitValue, Long blacklistId) {
|
||||
@@ -101,8 +67,7 @@ public class PayRiskHitService {
|
||||
.setClientIp(ctx.getClientIp())
|
||||
.setOpenid(ctx.getOpenId())
|
||||
.setBuyerId(ctx.getBuyerId())
|
||||
.setScene(StrUtil.blankToDefault(ctx.getScene(), PayRiskHitSceneEnum.UNKNOWN.getCode()))
|
||||
.setHandleStatus(PayRiskHitHandleStatusEnum.PENDING.getCode());
|
||||
.setScene(StrUtil.blankToDefault(ctx.getScene(), PayRiskHitSceneEnum.UNKNOWN.getCode()));
|
||||
payRiskHitManager.save(hit);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user