移除资金管理中可能抛出的PayException改为ServiceException,便于后期国际化管理

This commit is contained in:
gaoqr
2025-11-13 14:28:03 +08:00
parent 39eaf87fca
commit e87c4e8728
3 changed files with 7 additions and 24 deletions
@@ -3,7 +3,6 @@ package com.cf.imes.framework.web.core.handler;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.cf.imes.framework.common.exception.PayException;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.util.monitor.TracerUtils;
@@ -99,9 +98,6 @@ public class GlobalExceptionHandler {
if (ex instanceof HttpMessageNotReadableException) {
return httpMessageNotReadableExceptionHandler(request, (HttpMessageNotReadableException) ex);
}
if (ex instanceof PayException) {
return payExceptionHandler((PayException) ex);
}
return defaultExceptionHandler(request, ex);
}
@@ -264,18 +260,6 @@ public class GlobalExceptionHandler {
return CommonResult.error(ex.getCode(), ex.getMessage());
}
/**
* 支付异常 PayException
*
* @param ex
* @return
*/
@ExceptionHandler(value = PayException.class)
public CommonResult payExceptionHandler(PayException ex) {
log.error(String.format("==========[payExceptionHandler]==========%s", ex));
return CommonResult.error(ex.getCode(), ex.getMessage());
}
/**
* 处理数据库DuplicateKeyException,违反唯一约束异常
*
@@ -21,7 +21,6 @@ import com.cf.imes.framework.redis.constants.RedisKeyConstants;
import com.cf.imes.framework.redis.util.RedisLockUtil;
import com.cf.imes.module.system.controller.admin.funds.delay.vo.PreviouProductDelayRespVO;
import com.cf.imes.module.system.controller.admin.pay.vo.PayOrderUnifiedReqDTO;
import com.cf.imes.framework.common.exception.PayException;
import com.cf.imes.framework.pay.core.enums.order.PayOrderStatusRespEnum;
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
import com.cf.imes.module.system.controller.admin.funds.products.vo.product.ProductProcessorRespVO;
@@ -208,7 +207,7 @@ public class PayOrderServiceImpl implements PayOrderService {
if(e instanceof ServiceException) {
throw (ServiceException) e;
} else {
throw new PayException(PAY_ORDER_SUBMIT_CHANNEL_ERROR);
throw new ServiceException(PAY_ORDER_SUBMIT_CHANNEL_ERROR);
}
} finally {
// 软件购买锁解锁
@@ -359,11 +358,11 @@ public class PayOrderServiceImpl implements PayOrderService {
boolean paySuccess = PayOrderStatusRespEnum.SUCCESS.getStatus().equals(payOrderRespDTO.getStatus());
if (!paySuccess) {
throw new PayException(PAY_ORDER_CHANNEL_QUERY_NOT_EXIST);
throw new ServiceException(PAY_ORDER_CHANNEL_QUERY_NOT_EXIST);
}
} catch (Throwable e) {
log.error("渠道方查询支付订单异常", e);
throw new PayException(PAY_ORDER_CHANNEL_QUERY_NOT_EXIST);
throw new ServiceException(PAY_ORDER_CHANNEL_QUERY_NOT_EXIST);
}
}
@@ -381,7 +380,7 @@ public class PayOrderServiceImpl implements PayOrderService {
this.notifyOrder(payOrderRespDTO);
} catch (Throwable e) {
log.error("[parseOrderNotify][客户端({}) params({}) body({}) headers({}) 解析失败]", channelCode, params, body, headers, e);
throw new PayException(PAY_ORDER_NOTIFY_DATA_PARSE_ERROR);
throw new ServiceException(PAY_ORDER_NOTIFY_DATA_PARSE_ERROR);
}
}
@@ -1,7 +1,7 @@
package com.cf.imes.module.system.service.pay.factory;
import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.exception.PayException;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.module.system.service.pay.factory.impl.alipay.AlipayPcPayHandler;
import com.cf.imes.module.system.service.pay.factory.impl.AbstractPayHandler;
import com.cf.imes.module.system.service.pay.factory.impl.wechat.WechatNativePayHandler;
@@ -36,7 +36,7 @@ public class PayHandlerFactory {
public AbstractPayHandler getPayHandler(int channelCode) {
PayChannelCodeEnum payChannelCodeEnum = PayChannelCodeEnum.fromType(channelCode);
if (ObjectUtil.isNull(payChannelCodeEnum)) {
throw new PayException(PAY_CHANNEL_NOT_SUPPORT);
throw new ServiceException(PAY_CHANNEL_NOT_SUPPORT);
}
switch (payChannelCodeEnum) {
// 支付宝电脑支付
@@ -46,7 +46,7 @@ public class PayHandlerFactory {
case WECHAT_NATIVE:
return applicationContext.getBean(WechatNativePayHandler.class);
default:
throw new PayException(PAY_CHANNEL_NOT_SUPPORT);
throw new ServiceException(PAY_CHANNEL_NOT_SUPPORT);
}
}
}