jiangping
2025-02-18 b33f2e78ffd4fd401698b84a33dc3c293793c62f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.doumee.core.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.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.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 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(BaseWxPayRequest.yuanToFen(totalPrice.toString()));
//            request.setRefundFee(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(),"退款发生异常请联系管理员");
//    }
}