From 59b1f0e9967902aa10f5e017d5a0bdfd1b60c9ea Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期三, 29 四月 2026 09:42:45 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
server/services/src/main/java/com/doumee/config/wx/WxPayV3Service.java | 37 +++++++++++++++++++++++++++++--------
1 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/server/services/src/main/java/com/doumee/config/wx/WxPayV3Service.java b/server/services/src/main/java/com/doumee/config/wx/WxPayV3Service.java
index 6a5ace2..2224ae4 100644
--- a/server/services/src/main/java/com/doumee/config/wx/WxPayV3Service.java
+++ b/server/services/src/main/java/com/doumee/config/wx/WxPayV3Service.java
@@ -2,12 +2,12 @@
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
-import com.doumee.core.utils.ID;
import com.wechat.pay.java.core.notification.RequestParam;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
import com.wechat.pay.java.service.refund.model.AmountReq;
import com.wechat.pay.java.service.refund.model.CreateRequest;
+import com.wechat.pay.java.service.refund.model.QueryByOutRefundNoRequest;
import com.wechat.pay.java.service.refund.model.Refund;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -59,7 +59,7 @@
com.wechat.pay.java.service.payments.jsapi.model.Amount amount =
new com.wechat.pay.java.service.payments.jsapi.model.Amount();
- amount.setTotal(1);//totalCents.intValue());
+ amount.setTotal(totalCents.intValue());
amount.setCurrency("CNY");
request.setAmount(amount);
@@ -88,6 +88,7 @@
/**
* V3閫�娆�
*
+ * @param outRefundNo 鍟嗘埛閫�娆惧崟鍙凤紙鐢辫皟鐢ㄦ柟鐢熸垚锛�
* @param outTradeNo 鍟嗘埛璁㈠崟鍙�
* @param totalCents 鍘熻鍗曢噾棰濓紙鍒嗭級
* @param refundCents 閫�娆鹃噾棰濓紙鍒嗭級
@@ -95,14 +96,12 @@
* @param notifyUrl 閫�娆惧洖璋冨湴鍧�
* @return Refund 閫�娆剧粨鏋滐紙鍖呭惈 outRefundNo銆乻tatus 绛夛級
*/
- public Refund refund(String outTradeNo, Long totalCents, Long refundCents,
+ public Refund refund(String outRefundNo, String outTradeNo, Long totalCents, Long refundCents,
String reason, String notifyUrl) {
if (WxMiniConfig.v3RefundService == null) {
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "寰俊鏀粯V3鏈垵濮嬪寲");
}
try {
- String outRefundNo = ID.nextGUID();
-
CreateRequest request = new CreateRequest();
request.setOutTradeNo(outTradeNo);
request.setOutRefundNo(outRefundNo);
@@ -110,8 +109,8 @@
request.setNotifyUrl(notifyUrl);
AmountReq amount = new AmountReq();
- amount.setRefund(1L);//refundCents);
- amount.setTotal(1L);//totalCents);
+ amount.setRefund(refundCents);
+ amount.setTotal(totalCents);
amount.setCurrency("CNY");
request.setAmount(amount);
@@ -121,7 +120,7 @@
return result;
} catch (Exception e) {
log.error("寰俊鏀粯V3閫�娆惧け璐�: {}", e.getMessage(), e);
- throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "閫�娆惧け璐ワ細" + e.getMessage());
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "閫�娆惧け璐ワ細璇疯仈绯荤鐞嗗憳");
}
}
@@ -183,4 +182,26 @@
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "閫�娆惧洖璋冮獙绛惧け璐�");
}
}
+
+ /**
+ * 鏌ヨ鍗曠瑪閫�娆�
+ *
+ * @param outRefundNo 鍟嗘埛閫�娆惧崟鍙�
+ * @return Refund 閫�娆剧粨鏋�
+ */
+ public Refund queryRefund(String outRefundNo) {
+ if (WxMiniConfig.v3RefundService == null) {
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "寰俊鏀粯V3鏈垵濮嬪寲");
+ }
+ try {
+ QueryByOutRefundNoRequest request = new QueryByOutRefundNoRequest();
+ request.setOutRefundNo(outRefundNo);
+ Refund result = WxMiniConfig.v3RefundService.queryByOutRefundNo(request);
+ log.info("寰俊鏀粯V3鏌ヨ鍗曠瑪閫�娆�, outRefundNo={}, status={}", outRefundNo, result.getStatus());
+ return result;
+ } catch (Exception e) {
+ log.error("寰俊鏀粯V3鏌ヨ閫�娆惧け璐�: {}", e.getMessage(), e);
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鏌ヨ閫�娆惧け璐ワ細" + e.getMessage());
+ }
+ }
}
--
Gitblit v1.9.3