| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.wx; |
| | | |
| | | import cn.binarywang.wx.miniapp.api.WxMaQrcodeService; |
| | | 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 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.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 微信å°ç¨åº-å
Œ
±æ¹æ³ |
| | | */ |
| | | @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(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(),"鿬¾åçå¼å¸¸è¯·è系管çå"); |
| | | } |
| | | } |