From 3aef471b170a703b501ddb4d9d2a12791d07ff28 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期三, 15 四月 2026 20:06:56 +0800
Subject: [PATCH] 代码生成
---
server/services/src/main/java/com/doumee/config/wx/WxMiniUtilService.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/server/services/src/main/java/com/doumee/config/wx/WxMiniUtilService.java b/server/services/src/main/java/com/doumee/config/wx/WxMiniUtilService.java
new file mode 100644
index 0000000..1b650b8
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/config/wx/WxMiniUtilService.java
@@ -0,0 +1,50 @@
+package com.doumee.config.wx;
+
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
+import com.doumee.core.utils.ID;
+import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
+import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+
+/**
+ * 寰俊灏忕▼搴�-鍏叡鏂规硶
+ */
+@Service
+@Slf4j
+public class WxMiniUtilService {
+
+
+ /**
+ * 璁㈠崟寰俊閫�娆�
+ * orderNo:鍟嗘埛璁㈠崟鍙�
+ * totalPrice锛氳鍗曟�婚噾棰�
+ * refundPrice锛涢��娆鹃噾棰�
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public String wxRefund(String orderNo, Long totalPrice, Long refundPrice) {
+ try {
+ // 鍙戦�侀��娆捐姹�
+ String refNum = ID.nextGUID();
+ WxPayRefundRequest request = new WxPayRefundRequest();
+ request.setOutTradeNo(orderNo);
+ request.setOutRefundNo(refNum);
+ request.setTotalFee(totalPrice.intValue());
+ request.setRefundFee(refundPrice.intValue());
+ WxPayRefundResult response = WxMiniConfig.wxPayService.refund(request);
+ if ("SUCCESS".equals(response.getReturnCode()) && "SUCCESS".equals(response.getResultCode())) {
+ return refNum;
+ } else {
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),response.getErrCode() + response.getErrCodeDes());
+ }
+ } catch (WxPayException e) {
+ e.printStackTrace();
+ }
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"閫�娆惧彂鐢熷紓甯歌鑱旂郴绠$悊鍛�");
+ }
+}
--
Gitblit v1.9.3