From 40e062933dc259b417a9f39fa65295b8894139de Mon Sep 17 00:00:00 2001 From: dzq Date: Wed, 11 Jun 2025 10:03:08 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=94=AF=E4=BB=98):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=97=A7=E4=B8=9A=E5=8A=A1ID=E6=94=AF=E6=8C=81=E5=B9=B6?= =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E9=80=80=E6=AC=BE=E9=94=99=E8=AF=AF=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加old_biz_id常量以支持旧支付系统 根据订单创建时间选择支付业务ID 在退款异常时添加详细错误日志并尝试新系统 改进异常信息包含请求参数和响应结果 --- .../common/constant/PayApiConstants.java | 1 + .../ReturnApprovalApplicationService.java | 32 ++++++++++++++++--- .../payment/PaymentApplicationService.java | 2 +- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/agileboot-common/src/main/java/com/agileboot/common/constant/PayApiConstants.java b/agileboot-common/src/main/java/com/agileboot/common/constant/PayApiConstants.java index 0cde211..5b052c0 100644 --- a/agileboot-common/src/main/java/com/agileboot/common/constant/PayApiConstants.java +++ b/agileboot-common/src/main/java/com/agileboot/common/constant/PayApiConstants.java @@ -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"; diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/ReturnApprovalApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/ReturnApprovalApplicationService.java index 5f3ff37..f45b48a 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/ReturnApprovalApplicationService.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/ReturnApprovalApplicationService.java @@ -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)); diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/payment/PaymentApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/payment/PaymentApplicationService.java index 21013e1..49f9d86 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/payment/PaymentApplicationService.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/payment/PaymentApplicationService.java @@ -156,7 +156,7 @@ public class PaymentApplicationService { String result = HttpUtil.post(url, sb.toString()); CommonResponse res = JSONUtil.toBean(result, new TypeReference>(){}, true); if (res.getCode() != CommonErrorCode.OK.getErrorCode()) { - throw new Exception(res.getMsg()); + throw new Exception(res.getMsg() + ",请求参数:" + JSONUtil.toJsonStr(params) + ",响应结果:" + result); } return res.getData(); }