mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-04 11:37:37 +00:00
feat 异常体系完善
This commit is contained in:
@@ -9,6 +9,7 @@ import cn.daxpay.single.core.param.payment.transfer.TransferParam;
|
||||
import cn.daxpay.single.service.annotation.InitPaymentContext;
|
||||
import cn.daxpay.single.service.core.order.transfer.service.TransferOrderQueryService;
|
||||
import cn.daxpay.single.service.core.order.transfer.service.TransferOrderService;
|
||||
import cn.daxpay.single.service.core.payment.transfer.service.TransferService;
|
||||
import cn.daxpay.single.service.dto.order.transfer.TransferOrderDto;
|
||||
import cn.daxpay.single.service.param.order.TransferOrderQuery;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -28,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TransferOrderController {
|
||||
private final TransferOrderQueryService queryService;
|
||||
private final TransferOrderService transferOrderService;
|
||||
private final TransferService transferService;
|
||||
|
||||
|
||||
@Operation(summary = "分页查询")
|
||||
@@ -53,6 +55,7 @@ public class TransferOrderController {
|
||||
@Operation(summary = "手动发起转账")
|
||||
@PostMapping("/transfer")
|
||||
public ResResult<Void> transfer(@RequestBody TransferParam param){
|
||||
transferService.transfer(param);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,7 @@ package cn.daxpay.single.core.code;
|
||||
* @author xxm
|
||||
* @since 2024/6/17
|
||||
*/
|
||||
public interface DaxPayCommonErrorCode {
|
||||
public interface DaxPayErrorCode {
|
||||
/** 未归类的错误 */
|
||||
int UNCLASSIFIED_ERROR = 20000;
|
||||
|
||||
@@ -73,5 +73,5 @@ public interface DaxPayCommonErrorCode {
|
||||
int DATA_ERROR = 20091;
|
||||
|
||||
/** 未知异常,系统无法处理 */
|
||||
int SYSTEM_UNKNOWN_ERROR = 20000;
|
||||
int SYSTEM_UNKNOWN_ERROR = 30000;
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 金额超过限额
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class AmountExceedLimitException extends PayFailureException{
|
||||
|
||||
public AmountExceedLimitException(String message) {
|
||||
super(DaxPayCommonErrorCode.AMOUNT_EXCEED_LIMIT,message);
|
||||
super(DaxPayErrorCode.AMOUNT_EXCEED_LIMIT,message);
|
||||
}
|
||||
|
||||
public AmountExceedLimitException() {
|
||||
super(DaxPayCommonErrorCode.AMOUNT_EXCEED_LIMIT,"金额超过限额");
|
||||
super(DaxPayErrorCode.AMOUNT_EXCEED_LIMIT,"金额超过限额");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 支付通道未启用
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class ChannelNotEnableException extends PayFailureException{
|
||||
|
||||
public ChannelNotEnableException(String message) {
|
||||
super(DaxPayCommonErrorCode.CHANNEL_NOT_ENABLE,message);
|
||||
super(DaxPayErrorCode.CHANNEL_NOT_ENABLE,message);
|
||||
}
|
||||
|
||||
public ChannelNotEnableException() {
|
||||
super(DaxPayCommonErrorCode.CHANNEL_NOT_ENABLE,"支付通道未启用");
|
||||
super(DaxPayErrorCode.CHANNEL_NOT_ENABLE,"支付通道未启用");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 不存在的支付通道
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class ChannelNotExistException extends PayFailureException{
|
||||
|
||||
public ChannelNotExistException(String message) {
|
||||
super(DaxPayCommonErrorCode.CHANNEL_NOT_EXIST,message);
|
||||
super(DaxPayErrorCode.CHANNEL_NOT_EXIST,message);
|
||||
}
|
||||
|
||||
public ChannelNotExistException() {
|
||||
super(DaxPayCommonErrorCode.CHANNEL_NOT_EXIST,"不存在的支付通道");
|
||||
super(DaxPayErrorCode.CHANNEL_NOT_EXIST,"不存在的支付通道");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 配置错误
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class ConfigErrorException extends PayFailureException{
|
||||
|
||||
public ConfigErrorException(String message) {
|
||||
super(DaxPayCommonErrorCode.CONFIG_ERROR,message);
|
||||
super(DaxPayErrorCode.CONFIG_ERROR,message);
|
||||
}
|
||||
|
||||
public ConfigErrorException() {
|
||||
super(DaxPayCommonErrorCode.CONFIG_ERROR,"配置错误");
|
||||
super(DaxPayErrorCode.CONFIG_ERROR,"配置错误");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 配置未启用
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class ConfigNotEnableException extends PayFailureException{
|
||||
|
||||
public ConfigNotEnableException(String message) {
|
||||
super(DaxPayCommonErrorCode.CONFIG_NOT_ENABLE,message);
|
||||
super(DaxPayErrorCode.CONFIG_NOT_ENABLE,message);
|
||||
}
|
||||
|
||||
public ConfigNotEnableException() {
|
||||
super(DaxPayCommonErrorCode.CONFIG_NOT_ENABLE,"配置未启用");
|
||||
super(DaxPayErrorCode.CONFIG_NOT_ENABLE,"配置未启用");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 数据错误
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class DataErrorException extends PayFailureException{
|
||||
|
||||
public DataErrorException(String message) {
|
||||
super(DaxPayCommonErrorCode.DATA_ERROR,message);
|
||||
super(DaxPayErrorCode.DATA_ERROR,message);
|
||||
}
|
||||
|
||||
public DataErrorException() {
|
||||
super(DaxPayCommonErrorCode.DATA_ERROR,"数据错误");
|
||||
super(DaxPayErrorCode.DATA_ERROR,"数据错误");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 支付方式未启用
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class MethodNotEnableException extends PayFailureException{
|
||||
|
||||
public MethodNotEnableException(String message) {
|
||||
super(DaxPayCommonErrorCode.METHOD_NOT_ENABLE,message);
|
||||
super(DaxPayErrorCode.METHOD_NOT_ENABLE,message);
|
||||
}
|
||||
|
||||
public MethodNotEnableException() {
|
||||
super(DaxPayCommonErrorCode.METHOD_NOT_ENABLE,"支付方式未启用");
|
||||
super(DaxPayErrorCode.METHOD_NOT_ENABLE,"支付方式未启用");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 不存在的支付方式
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class MethodNotExistException extends PayFailureException{
|
||||
|
||||
public MethodNotExistException(String message) {
|
||||
super(DaxPayCommonErrorCode.METHOD_NOT_EXIST,message);
|
||||
super(DaxPayErrorCode.METHOD_NOT_EXIST,message);
|
||||
}
|
||||
|
||||
public MethodNotExistException() {
|
||||
super(DaxPayCommonErrorCode.METHOD_NOT_EXIST,"不存在的支付方式");
|
||||
super(DaxPayErrorCode.METHOD_NOT_EXIST,"不存在的支付方式");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 操作失败
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class OperationFailException extends PayFailureException{
|
||||
|
||||
public OperationFailException(String message) {
|
||||
super(DaxPayCommonErrorCode.OPERATION_FAIL,message);
|
||||
super(DaxPayErrorCode.OPERATION_FAIL,message);
|
||||
}
|
||||
|
||||
public OperationFailException() {
|
||||
super(DaxPayCommonErrorCode.OPERATION_FAIL,"操作失败");
|
||||
super(DaxPayErrorCode.OPERATION_FAIL,"操作失败");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 操作处理中, 请勿重复操作
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class OperationProcessingException extends PayFailureException{
|
||||
|
||||
public OperationProcessingException(String message) {
|
||||
super(DaxPayCommonErrorCode.OPERATION_PROCESSING,message);
|
||||
super(DaxPayErrorCode.OPERATION_PROCESSING,message);
|
||||
}
|
||||
|
||||
public OperationProcessingException() {
|
||||
super(DaxPayCommonErrorCode.OPERATION_PROCESSING,"操作处理中, 请勿重复操作");
|
||||
super(DaxPayErrorCode.OPERATION_PROCESSING,"操作处理中, 请勿重复操作");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 不支持的操作
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class OperationUnsupportedException extends PayFailureException{
|
||||
|
||||
public OperationUnsupportedException(String message) {
|
||||
super(DaxPayCommonErrorCode.OPERATION_UNSUPPORTED,message);
|
||||
super(DaxPayErrorCode.OPERATION_UNSUPPORTED,message);
|
||||
}
|
||||
|
||||
public OperationUnsupportedException() {
|
||||
super(DaxPayCommonErrorCode.OPERATION_UNSUPPORTED,"不支持的操作");
|
||||
super(DaxPayErrorCode.OPERATION_UNSUPPORTED,"不支持的操作");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 参数校验未通过
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class ParamValidationFailException extends PayFailureException{
|
||||
|
||||
public ParamValidationFailException(String message) {
|
||||
super(DaxPayCommonErrorCode.PARAM_VALIDATION_FAIL,message);
|
||||
super(DaxPayErrorCode.PARAM_VALIDATION_FAIL,message);
|
||||
}
|
||||
|
||||
public ParamValidationFailException() {
|
||||
super(DaxPayCommonErrorCode.PARAM_VALIDATION_FAIL,"参数校验未通过");
|
||||
super(DaxPayErrorCode.PARAM_VALIDATION_FAIL,"参数校验未通过");
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.bootx.platform.common.core.exception.BizException;
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 支付错误
|
||||
@@ -17,11 +17,11 @@ public class PayFailureException extends BizException {
|
||||
}
|
||||
|
||||
public PayFailureException(String message) {
|
||||
super(DaxPayCommonErrorCode.UNCLASSIFIED_ERROR, message);
|
||||
super(DaxPayErrorCode.UNCLASSIFIED_ERROR, message);
|
||||
}
|
||||
|
||||
public PayFailureException() {
|
||||
super(DaxPayCommonErrorCode.UNCLASSIFIED_ERROR, "支付失败");
|
||||
super(DaxPayErrorCode.UNCLASSIFIED_ERROR, "支付失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 对账失败
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class ReconciliationFailException extends PayFailureException{
|
||||
|
||||
public ReconciliationFailException(String message) {
|
||||
super(DaxPayCommonErrorCode.RECONCILE_FAIL,message);
|
||||
super(DaxPayErrorCode.RECONCILE_FAIL,message);
|
||||
}
|
||||
|
||||
public ReconciliationFailException() {
|
||||
super(DaxPayCommonErrorCode.RECONCILE_FAIL,"对账失败");
|
||||
super(DaxPayErrorCode.RECONCILE_FAIL,"对账失败");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 不存在的状态
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class StatusNotExistException extends PayFailureException{
|
||||
|
||||
public StatusNotExistException(String message) {
|
||||
super(DaxPayCommonErrorCode.STATUS_NOT_EXIST,message);
|
||||
super(DaxPayErrorCode.STATUS_NOT_EXIST,message);
|
||||
}
|
||||
|
||||
public StatusNotExistException() {
|
||||
super(DaxPayCommonErrorCode.STATUS_NOT_EXIST,"不存在的状态");
|
||||
super(DaxPayErrorCode.STATUS_NOT_EXIST,"不存在的状态");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 未知异常,系统无法处理
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class SystemUnknownErrorException extends PayFailureException{
|
||||
|
||||
public SystemUnknownErrorException(String message) {
|
||||
super(DaxPayCommonErrorCode.SYSTEM_UNKNOWN_ERROR,message);
|
||||
super(DaxPayErrorCode.SYSTEM_UNKNOWN_ERROR,message);
|
||||
}
|
||||
|
||||
public SystemUnknownErrorException() {
|
||||
super(DaxPayCommonErrorCode.SYSTEM_UNKNOWN_ERROR,"未知异常,系统无法处理");
|
||||
super(DaxPayErrorCode.SYSTEM_UNKNOWN_ERROR,"未知异常,系统无法处理");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 交易已关闭
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class TradeClosedException extends PayFailureException{
|
||||
|
||||
public TradeClosedException(String message) {
|
||||
super(DaxPayCommonErrorCode.TRADE_CLOSED,message);
|
||||
super(DaxPayErrorCode.TRADE_CLOSED,message);
|
||||
}
|
||||
|
||||
public TradeClosedException() {
|
||||
super(DaxPayCommonErrorCode.TRADE_CLOSED,"交易已关闭");
|
||||
super(DaxPayErrorCode.TRADE_CLOSED,"交易已关闭");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 交易失败
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class TradeFaileException extends PayFailureException{
|
||||
|
||||
public TradeFaileException(String message) {
|
||||
super(DaxPayCommonErrorCode.TRADE_FAILE,message);
|
||||
super(DaxPayErrorCode.TRADE_FAILE,message);
|
||||
}
|
||||
|
||||
public TradeFaileException() {
|
||||
super(DaxPayCommonErrorCode.TRADE_FAILE,"交易失败");
|
||||
super(DaxPayErrorCode.TRADE_FAILE,"交易失败");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 交易不存在
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class TradeNotExistException extends PayFailureException{
|
||||
|
||||
public TradeNotExistException(String message) {
|
||||
super(DaxPayCommonErrorCode.TRADE_NOT_EXIST,message);
|
||||
super(DaxPayErrorCode.TRADE_NOT_EXIST,message);
|
||||
}
|
||||
|
||||
public TradeNotExistException() {
|
||||
super(DaxPayCommonErrorCode.TRADE_NOT_EXIST,"交易不存在");
|
||||
super(DaxPayErrorCode.TRADE_NOT_EXIST,"交易不存在");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 交易处理中, 请勿重复操作
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class TradeProcessingException extends PayFailureException{
|
||||
|
||||
public TradeProcessingException(String message) {
|
||||
super(DaxPayCommonErrorCode.TRADE_PROCESSING,message);
|
||||
super(DaxPayErrorCode.TRADE_PROCESSING,message);
|
||||
}
|
||||
|
||||
public TradeProcessingException() {
|
||||
super(DaxPayCommonErrorCode.TRADE_PROCESSING,"交易处理中,请勿重复操作");
|
||||
super(DaxPayErrorCode.TRADE_PROCESSING,"交易处理中,请勿重复操作");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 交易状态错误
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class TradeStatusErrorException extends PayFailureException{
|
||||
|
||||
public TradeStatusErrorException(String message) {
|
||||
super(DaxPayCommonErrorCode.TRADE_STATUS_ERROR,message);
|
||||
super(DaxPayErrorCode.TRADE_STATUS_ERROR,message);
|
||||
}
|
||||
|
||||
public TradeStatusErrorException() {
|
||||
super(DaxPayCommonErrorCode.TRADE_STATUS_ERROR,"交易状态错误");
|
||||
super(DaxPayErrorCode.TRADE_STATUS_ERROR,"交易状态错误");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 不支持该能力
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class UnsupportedAbilityException extends PayFailureException{
|
||||
|
||||
public UnsupportedAbilityException(String message) {
|
||||
super(DaxPayCommonErrorCode.UNSUPPORTED_ABILITY,message);
|
||||
super(DaxPayErrorCode.UNSUPPORTED_ABILITY,message);
|
||||
}
|
||||
|
||||
public UnsupportedAbilityException() {
|
||||
super(DaxPayCommonErrorCode.UNSUPPORTED_ABILITY,"不支持该能力");
|
||||
super(DaxPayErrorCode.UNSUPPORTED_ABILITY,"不支持该能力");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.daxpay.single.core.exception;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
|
||||
/**
|
||||
* 验签失败
|
||||
@@ -10,10 +10,10 @@ import cn.daxpay.single.core.code.DaxPayCommonErrorCode;
|
||||
public class VerifySignFailedException extends PayFailureException{
|
||||
|
||||
public VerifySignFailedException(String message) {
|
||||
super(DaxPayCommonErrorCode.VERIFY_SIGN_FAILED,message);
|
||||
super(DaxPayErrorCode.VERIFY_SIGN_FAILED,message);
|
||||
}
|
||||
|
||||
public VerifySignFailedException() {
|
||||
super(DaxPayCommonErrorCode.VERIFY_SIGN_FAILED,"验签失败");
|
||||
super(DaxPayErrorCode.VERIFY_SIGN_FAILED,"验签失败");
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package cn.daxpay.single.service.common.context;
|
||||
|
||||
import cn.bootx.platform.common.core.exception.BizException;
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@@ -13,8 +15,30 @@ import lombok.experimental.Accessors;
|
||||
public class ErrorInfoLocal {
|
||||
|
||||
/** 错误码 */
|
||||
private String errorCode;
|
||||
private int errorCode;
|
||||
|
||||
/** 错误内容 */
|
||||
private String errorMsg;
|
||||
|
||||
/**
|
||||
* 自动根据传入的异常对象对象进行处理
|
||||
*/
|
||||
public void setException(Exception e) {
|
||||
// 如果业务异常, 获取错误码和错误信息
|
||||
if (e instanceof BizException) {
|
||||
BizException be = (BizException) e;
|
||||
this.errorCode = be.getCode();
|
||||
this.errorMsg = be.getMessage();
|
||||
}
|
||||
// 如果是空指针, 专门记录
|
||||
else if (e instanceof NullPointerException) {
|
||||
this.errorCode = DaxPayErrorCode.UNCLASSIFIED_ERROR;
|
||||
this.errorMsg = "空指针异常";
|
||||
}
|
||||
// 如果是其他异常, 归类到为止异常中
|
||||
else {
|
||||
this.errorCode = DaxPayErrorCode.SYSTEM_UNKNOWN_ERROR;
|
||||
this.errorMsg = "未归类异常,请联系管理人员进行排查";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package cn.daxpay.single.service.core.channel.alipay.service;
|
||||
|
||||
import cn.daxpay.single.core.code.DaxPayErrorCode;
|
||||
import cn.daxpay.single.core.code.RefundStatusEnum;
|
||||
import cn.daxpay.single.core.exception.OperationFailException;
|
||||
import cn.daxpay.single.core.util.PayUtil;
|
||||
@@ -53,10 +54,10 @@ public class AliPayRefundService {
|
||||
try {
|
||||
AlipayTradeRefundResponse response = alipayClient.execute(request);
|
||||
if (!Objects.equals(AliPayCode.SUCCESS, response.getCode())) {
|
||||
errorInfo.setErrorMsg(response.getSubMsg());
|
||||
errorInfo.setErrorCode(response.getCode());
|
||||
OperationFailException operationFailException = new OperationFailException(response.getSubMsg());
|
||||
errorInfo.setException(operationFailException);
|
||||
log.error("网关返回退款失败: {}", response.getSubMsg());
|
||||
throw new OperationFailException(response.getSubMsg());
|
||||
throw operationFailException;
|
||||
}
|
||||
// 默认为退款中状态
|
||||
refundInfo.setStatus(RefundStatusEnum.PROGRESS)
|
||||
@@ -71,8 +72,8 @@ public class AliPayRefundService {
|
||||
catch (AlipayApiException e) {
|
||||
log.error("订单退款失败:", e);
|
||||
errorInfo.setErrorMsg(e.getErrMsg());
|
||||
errorInfo.setErrorCode(e.getErrCode());
|
||||
throw new OperationFailException("订单退款失败");
|
||||
errorInfo.setErrorCode(DaxPayErrorCode.OPERATION_FAIL);
|
||||
throw new OperationFailException(e.getErrMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static cn.daxpay.single.service.code.WeChatPayCode.*;
|
||||
|
||||
@@ -58,9 +57,9 @@ public class WeChatPayRefundService {
|
||||
// 获取证书文件
|
||||
if (StrUtil.isBlank(weChatPayConfig.getP12())){
|
||||
String errorMsg = "微信p.12证书未配置,无法进行退款";
|
||||
errorInfo.setErrorMsg(errorMsg);
|
||||
errorInfo.setErrorCode(RefundStatusEnum.FAIL.getCode());
|
||||
throw new ConfigErrorException(errorMsg);
|
||||
ConfigErrorException configErrorException = new ConfigErrorException(errorMsg);
|
||||
errorInfo.setException(configErrorException);
|
||||
throw configErrorException;
|
||||
}
|
||||
byte[] fileBytes = Base64.decode(weChatPayConfig.getP12());
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(fileBytes);
|
||||
@@ -85,10 +84,10 @@ public class WeChatPayRefundService {
|
||||
errorMsg = result.get(RETURN_MSG);
|
||||
}
|
||||
log.error("订单退款失败 {}", errorMsg);
|
||||
TradeFaileException tradeFaileException = new TradeFaileException(errorMsg);
|
||||
ErrorInfoLocal errorInfo = PaymentContextLocal.get().getErrorInfo();
|
||||
errorInfo.setErrorMsg(errorMsg);
|
||||
errorInfo.setErrorCode(Optional.ofNullable(resultCode).orElse(returnCode));
|
||||
throw new TradeFaileException(errorMsg);
|
||||
errorInfo.setException(tradeFaileException);
|
||||
throw tradeFaileException;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package cn.daxpay.single.service.core.order.transfer.service;
|
||||
|
||||
import cn.daxpay.single.core.param.payment.transfer.TransferParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -17,7 +18,7 @@ public class TransferOrderService {
|
||||
/**
|
||||
* 手动转账
|
||||
*/
|
||||
public void transfer(){
|
||||
public void transfer(TransferParam param){
|
||||
|
||||
}
|
||||
|
||||
|
@@ -120,7 +120,7 @@ public class RefundAssistService {
|
||||
public void updateOrderByError(RefundOrder refundOrder){
|
||||
RefundLocal refundInfo = PaymentContextLocal.get().getRefundInfo();
|
||||
ErrorInfoLocal errorInfo = PaymentContextLocal.get().getErrorInfo();
|
||||
refundOrder.setErrorCode(errorInfo.getErrorCode());
|
||||
refundOrder.setErrorCode(String.valueOf(errorInfo.getErrorCode()));
|
||||
refundOrder.setErrorMsg(errorInfo.getErrorMsg());
|
||||
refundOrder.setStatus(refundInfo.getStatus().getCode());
|
||||
refundOrderManager.updateById(refundOrder);
|
||||
|
@@ -56,7 +56,7 @@ public class TransferAssistService {
|
||||
ErrorInfoLocal errorInfo = PaymentContextLocal.get().getErrorInfo();
|
||||
order.setStatus(TransferStatusEnum.FAIL.getCode())
|
||||
.setErrorMsg(errorInfo.getErrorMsg())
|
||||
.setErrorCode(errorInfo.getErrorCode());
|
||||
.setErrorCode(String.valueOf(errorInfo.getErrorCode()));
|
||||
transferOrderManager.updateById(order);
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,6 @@ public class TransferService {
|
||||
* 转账
|
||||
*/
|
||||
public TransferResult transfer(TransferParam transferParam){
|
||||
|
||||
// 获取策略
|
||||
AbsTransferStrategy transferStrategy = PayStrategyFactory.create(transferParam.getChannel(),AbsTransferStrategy.class);
|
||||
// 检查转账参数
|
||||
@@ -50,6 +49,7 @@ public class TransferService {
|
||||
log.error("转账出现错误", e);
|
||||
// 记录处理失败状态
|
||||
PaymentContextLocal.get().getRefundInfo().setStatus(RefundStatusEnum.FAIL);
|
||||
PaymentContextLocal.get().getErrorInfo().setException(e);
|
||||
// 更新退款失败的记录
|
||||
transferAssistService.updateOrderByError(order);
|
||||
return transferAssistService.buildResult(order);
|
||||
|
Reference in New Issue
Block a user