From fcd0f63ea0a86d5756cf3950f08144e1552a3d4e Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期三, 15 四月 2026 20:04:50 +0800
Subject: [PATCH] 代码提交
---
server/services/src/main/java/com/doumee/config/wx/WxMiniUtilService.java | 100 +++++++++++++++++++------------------------------
1 files changed, 39 insertions(+), 61 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
index 736d9f3..5deb08a 100644
--- a/server/services/src/main/java/com/doumee/config/wx/WxMiniUtilService.java
+++ b/server/services/src/main/java/com/doumee/config/wx/WxMiniUtilService.java
@@ -1,35 +1,26 @@
-package com.doumee.config.wx;
+package com.doumee.core.wx;
-import com.alibaba.fastjson.JSONObject;
-import com.doumee.biz.system.SystemDictDataBiz;
-import com.doumee.core.constants.Constants;
+import cn.binarywang.wx.miniapp.api.WxMaQrcodeService;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
-import com.doumee.core.utils.DateUtil;
-import com.doumee.core.utils.HttpsUtil;
-import com.doumee.dao.business.WithdrawalOrdersMapper;
-import com.doumee.dao.business.model.Orders;
-import com.doumee.dao.business.model.WithdrawalOrders;
-import com.doumee.dao.system.model.SystemDictData;
-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.doumee.core.utils.ID;
+import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
+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.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.StringUtils;
+import me.chanjar.weixin.common.error.WxErrorException;
+import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
-import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.math.BigDecimal;
-import java.util.Date;
-import java.util.HashMap;
import java.util.Map;
-import java.util.Objects;
/**
* 寰俊灏忕▼搴�-鍏叡鏂规硶
@@ -38,47 +29,34 @@
@Slf4j
public class WxMiniUtilService {
- @Autowired
- private WithdrawalOrdersMapper withdrawalOrdersMapper;
- @Autowired
- private SystemDictDataBiz systemDictDataBiz;
-
- @Autowired
- private WxPayProperties wxPayProperties;
-
- @Transactional(rollbackFor = {BusinessException.class,Exception.class})
- public boolean wxRefund(WithdrawalOrders withdrawalOrders,Orders orders) {
-// // 鍙戦�侀��娆捐姹�
-// withdrawalOrders.setCreateTime(new Date());
-// withdrawalOrdersMapper.insert(withdrawalOrders);
-// CreateRequest request = new CreateRequest();
-// request.setOutTradeNo(orders.getOutTradeNo());
-// request.setOutRefundNo(withdrawalOrders.getId().toString());
-// request.setSubMchid(WxMiniConfig.wxProperties.getSubMchId());
-// request.setNotifyUrl(WxMiniConfig.wxProperties.getRefundNotifyUrl());
-// AmountReq amountReq = new AmountReq();
-// amountReq.setTotal(1L);//withdrawalOrders.getAmount());
-// amountReq.setRefund(1L);//withdrawalOrders.getAmount());
-// amountReq.setCurrency("CNY");
-// request.setAmount(amountReq);
-// try {
-// log.error("=============="+JSONObject.toJSONString(request));
-// com.wechat.pay.java.service.refund.model.Refund response = WxMiniConfig.wxPayService.refund(request);
-// log.error("=============="+JSONObject.toJSONString(response));
-// if ("SUCCESS".equals(response.getStatus().name())
-// || "PROCESSING".equals(response.getStatus().name()) ) {
-// return true;
-// }else{
-// throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝閫�娆剧敵璇峰け璐ュ摝锛�");
-// }
-// }catch (Exception e){
-// e.printStackTrace();
-// throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝閫�娆剧敵璇峰け璐ワ紒");
-// }
- return false;
+ /**
+ * 璁㈠崟寰俊閫�娆�
+ * orderNo:鍟嗘埛璁㈠崟鍙�
+ * totalPrice锛氳鍗曟�婚噾棰�
+ * refundPrice锛涢��娆鹃噾棰�
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public static String wxRefund(String orderNo, BigDecimal totalPrice, BigDecimal refundPrice) {
+ try {
+ // 鍙戦�侀��娆捐姹�
+ String refNum = ID.nextGUID();
+ WxPayRefundRequest request = new WxPayRefundRequest();
+ request.setOutTradeNo(orderNo);
+ request.setOutRefundNo(refNum);
+ // request.setTotalFee(2);
+ // request.setRefundFee(1);
+ request.setTotalFee(1);//BaseWxPayRequest.yuanToFen(totalPrice.toString()));
+ request.setRefundFee(1);//BaseWxPayRequest.yuanToFen(refundPrice.toString()));
+ 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