|
@@ -6,6 +6,7 @@ import com.alipay.api.AlipayClient;
|
|
|
import com.alipay.api.request.AlipayTradeWapPayRequest;
|
|
import com.alipay.api.request.AlipayTradeWapPayRequest;
|
|
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
|
|
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
|
|
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
|
|
|
|
|
+import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
|
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
|
import com.github.binarywang.wxpay.constant.WxPayConstants;
|
|
import com.github.binarywang.wxpay.constant.WxPayConstants;
|
|
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
@@ -411,4 +412,17 @@ public class OrderService {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public void refund(Long id) throws WxPayException {
|
|
|
|
|
+ Order order = orderRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
|
|
+ if (order.getStatus() != OrderStatus.FINISH) {
|
|
|
|
|
+ throw new BusinessException("订单未付款");
|
|
|
|
|
+ }
|
|
|
|
|
+ WxPayRefundRequest request = new WxPayRefundRequest();
|
|
|
|
|
+ request.setTransactionId(order.getTransactionId());
|
|
|
|
|
+ request.setTotalFee(order.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue());
|
|
|
|
|
+ request.setRefundFee(order.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue());
|
|
|
|
|
+ request.setOutRefundNo(String.valueOf(new SnowflakeIdWorker(0, 0).nextId()));
|
|
|
|
|
+ wxPayService.refund(request);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|