feat(支付): 添加旧业务ID支持并增强退款错误处理

添加old_biz_id常量以支持旧支付系统
根据订单创建时间选择支付业务ID
在退款异常时添加详细错误日志并尝试新系统
改进异常信息包含请求参数和响应结果
This commit is contained in:
dzq 2025-06-11 10:03:08 +08:00
parent 7f45b1cf79
commit 40e062933d
3 changed files with 30 additions and 5 deletions

View File

@ -2,6 +2,7 @@ package com.agileboot.common.constant;
public class PayApiConstants {
public static final String biz_id = "wxshop";
public static final String old_biz_id = "wxshop_old";
public static final String appkey = "wxshop202503081132";
public static final String pay_url = "http://222.218.10.217:7890/open/trade/wx/jsapi/precreate";
public static final String pay_callback_url = "http://wxshop.ab98.cn/shop-api/api/payment/callback";

View File

@ -159,10 +159,34 @@ public class ReturnApprovalApplicationService {
// 微信退款
RefundVO refundVO = null;
try {
refundVO = paymentApplicationService.refund(
PayApiConstants.biz_id, PayApiConstants.appkey,
orderModel.getBizOrderId(), orderModel.getUcid(),
"退还", returnAmount.intValue());
// 检查订单创建时间是否在2025年6月10日11:05之前
Date cutoffDate = DateUtil.parse("2025-06-10 11:05:00", "yyyy-MM-dd HH:mm:ss");
if (orderModel.getCreateTime().after(cutoffDate)) {
refundVO = paymentApplicationService.refund(
PayApiConstants.biz_id, PayApiConstants.appkey,
orderModel.getBizOrderId(), orderModel.getUcid(),
"退还", returnAmount.intValue());
} else {
try {
refundVO = paymentApplicationService.refund(
PayApiConstants.old_biz_id, PayApiConstants.appkey,
orderModel.getBizOrderId(), orderModel.getUcid(),
"退还", returnAmount.intValue());
} catch (Exception e) {
AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
paymentOperationLogCommand.setParams(JSONUtil.toJsonStr(command));
paymentOperationLogCommand.setOperationType("refund");
paymentOperationLogCommand.setStatus(3);
paymentOperationLogCommand.setRemark(ExceptionUtils.getStackTrace(e));
paymentOperationLogCommand.initBaseEntity();
paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand);
refundVO = paymentApplicationService.refund(
PayApiConstants.biz_id, PayApiConstants.appkey,
orderModel.getBizOrderId(), orderModel.getUcid(),
"退还", returnAmount.intValue());
}
}
AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
paymentOperationLogCommand.setParams(JSONUtil.toJsonStr(command));

View File

@ -156,7 +156,7 @@ public class PaymentApplicationService {
String result = HttpUtil.post(url, sb.toString());
CommonResponse<RefundVO> res = JSONUtil.toBean(result, new TypeReference<CommonResponse<RefundVO>>(){}, true);
if (res.getCode() != CommonErrorCode.OK.getErrorCode()) {
throw new Exception(res.getMsg());
throw new Exception(res.getMsg() + ",请求参数:" + JSONUtil.toJsonStr(params) + ",响应结果:" + result);
}
return res.getData();
}