mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 05:42:06 +08:00
禅道bug#1599修复
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
|||||||
|
package com.cf.imes.framework.common.exception;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异常错误数据:用于CommonResult.data
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2026/6/4 10:40
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ErrorData {
|
||||||
|
private String errorData;
|
||||||
|
}
|
||||||
+12
@@ -31,12 +31,24 @@ public final class ServiceException extends RuntimeException {
|
|||||||
*/
|
*/
|
||||||
private transient Object[] args;
|
private transient Object[] args;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异常需要的回调数据
|
||||||
|
*/
|
||||||
|
private ErrorData errorData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 空构造方法,避免反序列化问题
|
* 空构造方法,避免反序列化问题
|
||||||
*/
|
*/
|
||||||
public ServiceException() {
|
public ServiceException() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ServiceException(ErrorCode errorCode, ErrorData errorData, Object... args) {
|
||||||
|
this.code = errorCode.getCode();
|
||||||
|
this.message = errorCode.getMsg();
|
||||||
|
this.errorData = errorData;
|
||||||
|
this.args = args;
|
||||||
|
}
|
||||||
|
|
||||||
public ServiceException(ErrorCode errorCode, Object... args) {
|
public ServiceException(ErrorCode errorCode, Object... args) {
|
||||||
this.code = errorCode.getCode();
|
this.code = errorCode.getCode();
|
||||||
this.message = errorCode.getMsg();
|
this.message = errorCode.getMsg();
|
||||||
|
|||||||
+9
-2
@@ -3,6 +3,8 @@ package com.cf.imes.framework.web.core.handler;
|
|||||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.text.CharSequenceUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.cf.imes.framework.common.exception.ErrorData;
|
||||||
import com.cf.imes.framework.common.exception.ServiceException;
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
import com.cf.imes.framework.common.util.monitor.TracerUtils;
|
import com.cf.imes.framework.common.util.monitor.TracerUtils;
|
||||||
@@ -238,12 +240,17 @@ public class GlobalExceptionHandler {
|
|||||||
@ExceptionHandler(value = ServiceException.class)
|
@ExceptionHandler(value = ServiceException.class)
|
||||||
public CommonResult serviceExceptionHandler(ServiceException ex) {
|
public CommonResult serviceExceptionHandler(ServiceException ex) {
|
||||||
// 系统异常输出堆栈
|
// 系统异常输出堆栈
|
||||||
if(INTERNAL_SERVER_ERROR.getCode().equals(ex.getCode())) {
|
if (INTERNAL_SERVER_ERROR.getCode().equals(ex.getCode())) {
|
||||||
log.error("[serviceExceptionHandler]", ex);
|
log.error("[serviceExceptionHandler]", ex);
|
||||||
} else {
|
} else {
|
||||||
log.error(String.format("==========[serviceExceptionHandler]==========,%s:%s", ex.getCode(), ex.getMessage()));
|
log.error(String.format("==========[serviceExceptionHandler]==========,%s:%s", ex.getCode(), ex.getMessage()));
|
||||||
}
|
}
|
||||||
return CommonResult.error(ex.getCode(), ex.getMessage(), ex.getArgs());
|
CommonResult<Object> error = CommonResult.error(ex.getCode(), ex.getMessage(), ex.getArgs());
|
||||||
|
ErrorData errorData = ex.getErrorData();
|
||||||
|
if (ObjectUtil.isNotNull(errorData)) {
|
||||||
|
error.setData(errorData.getErrorData());
|
||||||
|
}
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+5
@@ -154,4 +154,9 @@ public class PurchaseRecordDO extends BaseDO {
|
|||||||
* 状态
|
* 状态
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第三方支付链接
|
||||||
|
*/
|
||||||
|
private String displayContent;
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-5
@@ -8,10 +8,12 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||||
|
import com.cf.imes.framework.common.exception.ErrorData;
|
||||||
import com.cf.imes.framework.common.exception.ServiceException;
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||||
import com.cf.imes.framework.common.util.validation.ValidationUtils;
|
import com.cf.imes.framework.common.util.validation.ValidationUtils;
|
||||||
import com.cf.imes.framework.id.core.util.SnowflakeSerialNoWorker3rd;
|
import com.cf.imes.framework.id.core.util.SnowflakeSerialNoWorker3rd;
|
||||||
|
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import com.cf.imes.framework.pay.config.ChenfengAlipayConfig;
|
import com.cf.imes.framework.pay.config.ChenfengAlipayConfig;
|
||||||
import com.cf.imes.framework.pay.config.ChenfengPayConfig;
|
import com.cf.imes.framework.pay.config.ChenfengPayConfig;
|
||||||
import com.cf.imes.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import com.cf.imes.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
@@ -56,6 +58,7 @@ import jakarta.validation.Validator;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -166,7 +169,11 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|||||||
// 检查机构产品是否有待支付的购买记录
|
// 检查机构产品是否有待支付的购买记录
|
||||||
List<PurchaseRecordDO> pendingPurchaseList = purchaseService.getOrgProductPendingPurchaseList(organId, productId);
|
List<PurchaseRecordDO> pendingPurchaseList = purchaseService.getOrgProductPendingPurchaseList(organId, productId);
|
||||||
if (CollUtil.isNotEmpty(pendingPurchaseList)) {
|
if (CollUtil.isNotEmpty(pendingPurchaseList)) {
|
||||||
throw new ServiceException(ORG_PRODUCT_PURCHASE_WAIT_PAY_ERROR);
|
// 取更新时间最新的那一条展示支付链接
|
||||||
|
PurchaseRecordDO latestPendingPurchase = pendingPurchaseList.stream()
|
||||||
|
.max(Comparator.comparing(BaseDO::getUpdateTime))
|
||||||
|
.orElse(null);
|
||||||
|
throw new ServiceException(ORG_PRODUCT_PURCHASE_WAIT_PAY_ERROR, new ErrorData().setErrorData(latestPendingPurchase.getDisplayContent()), payConfig.getPayExpireTime().toMinutes());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询组织产品的首次购买记录
|
// 查询组织产品的首次购买记录
|
||||||
@@ -188,15 +195,20 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|||||||
processPreviosPurchaseRecord(previouProductDelayRespVO, payOrder);
|
processPreviosPurchaseRecord(previouProductDelayRespVO, payOrder);
|
||||||
|
|
||||||
// 记录入库,如果有外部支付发起请求二维码
|
// 记录入库,如果有外部支付发起请求二维码
|
||||||
// 购买记录入库
|
PurchaseRecordDO purchaseRecordDO = productProcessorRespVO.getPurchaseRecordDO();
|
||||||
purchaseService.createRecord(productProcessorRespVO.getPurchaseRecordDO());
|
|
||||||
|
|
||||||
// 发起渠道方支付
|
// 发起渠道方支付
|
||||||
createPayOrder(payOrder);
|
createPayOrder(payOrder);
|
||||||
AbstractPayHandler payHandler = payHandlerFactory.getPayHandler(channelCode);
|
AbstractPayHandler payHandler = payHandlerFactory.getPayHandler(channelCode);
|
||||||
|
|
||||||
payOrderUnifiedReqDTO = createPayOrderUnifiedReqDTO(payOrder);
|
payOrderUnifiedReqDTO = createPayOrderUnifiedReqDTO(payOrder);
|
||||||
return payHandler.unifiedOrder(payOrderUnifiedReqDTO);
|
PayOrderRespDTO payOrderRespDTO = payHandler.unifiedOrder(payOrderUnifiedReqDTO);
|
||||||
|
|
||||||
|
// 购买记录入库,记录外部支付请求
|
||||||
|
purchaseRecordDO.setDisplayContent(payOrderRespDTO.getDisplayContent());
|
||||||
|
purchaseService.createRecord(purchaseRecordDO);
|
||||||
|
return payOrderRespDTO;
|
||||||
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
// 系统异常,则包装成 PayException 异常抛出
|
// 系统异常,则包装成 PayException 异常抛出
|
||||||
@@ -231,7 +243,11 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|||||||
// 检查机构产品是否有待支付的购买记录
|
// 检查机构产品是否有待支付的购买记录
|
||||||
List<PurchaseRecordDO> pendingPurchaseList = purchaseService.getOrgProductPendingPurchaseList(organId, productId);
|
List<PurchaseRecordDO> pendingPurchaseList = purchaseService.getOrgProductPendingPurchaseList(organId, productId);
|
||||||
if (CollUtil.isNotEmpty(pendingPurchaseList)) {
|
if (CollUtil.isNotEmpty(pendingPurchaseList)) {
|
||||||
throw new ServiceException(ORG_PRODUCT_PURCHASE_WAIT_PAY_ERROR);
|
// 取更新时间最新的那一条展示支付链接
|
||||||
|
PurchaseRecordDO latestPendingPurchase = pendingPurchaseList.stream()
|
||||||
|
.max(Comparator.comparing(BaseDO::getUpdateTime))
|
||||||
|
.orElse(null);
|
||||||
|
throw new ServiceException(ORG_PRODUCT_PURCHASE_WAIT_PAY_ERROR, new ErrorData().setErrorData(latestPendingPurchase.getDisplayContent()), payConfig.getPayExpireTime().toMinutes());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询组织产品的首次购买记录
|
// 查询组织产品的首次购买记录
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user