|
@@ -0,0 +1,71 @@
|
|
|
|
|
+package com.xingxi.web.wxpay.controller;
|
|
|
|
|
+
|
|
|
|
|
+import com.github.binarywang.wxpay.bean.request.WxPayOrderQueryV3Request;
|
|
|
|
|
+import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryV3Result;
|
|
|
|
|
+import com.github.binarywang.wxpay.bean.result.WxPayRefundQueryV3Result;
|
|
|
|
|
+import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result;
|
|
|
|
|
+import com.xingxi.common.core.controller.BaseController;
|
|
|
|
|
+import com.xingxi.common.exception.BusinessException;
|
|
|
|
|
+import com.xingxi.web.wxpay.service.WechatPayService;
|
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * swagger 用户测试方法
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author ruoyi
|
|
|
|
|
+ */
|
|
|
|
|
+@Api("用户信息管理")
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/wechatPay")
|
|
|
|
|
+public class WechatPayController extends BaseController
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WechatPayService wechatPayService;
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("查询微信支付订单(商户订单编号或微信订单ID必须有一个)")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "OutTradeNo", value = "商户订单编号", dataType = "String", dataTypeClass = String.class),
|
|
|
|
|
+ @ApiImplicitParam(name = "TransactionId", value = "微信订单ID", dataType = "String", dataTypeClass = String.class)
|
|
|
|
|
+ })
|
|
|
|
|
+ @PostMapping("/orderQuery")
|
|
|
|
|
+ public WxPayOrderQueryV3Result orderQuery(WxPayOrderQueryV3Request request) {
|
|
|
|
|
+ if (StringUtils.isBlank(request.getTransactionId()) && StringUtils.isBlank(request.getOutTradeNo())) {
|
|
|
|
|
+ throw new BusinessException("请输入商户订单编号或微信订单ID!");
|
|
|
|
|
+ }
|
|
|
|
|
+ return wechatPayService.orderQuery(request);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("查询微信退款订单")
|
|
|
|
|
+ @ApiImplicitParam(name = "outTradeNo", value = "退款单号", dataType = "String", dataTypeClass = String.class)
|
|
|
|
|
+ @PostMapping("/refundQuery")
|
|
|
|
|
+ public WxPayRefundQueryV3Result orderQuery(String outTradeNo) {
|
|
|
|
|
+ if (StringUtils.isBlank(outTradeNo)) {
|
|
|
|
|
+ throw new BusinessException("请输入商户退款单号!");
|
|
|
|
|
+ }
|
|
|
|
|
+ return wechatPayService.refundQuery(outTradeNo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("退款")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "orderNo", value = "商户订单号", required = true, dataType = "String", dataTypeClass = String.class),
|
|
|
|
|
+ @ApiImplicitParam(name = "payAmount", value = "支付金额(分)", required = true, dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
|
|
|
|
|
+ @ApiImplicitParam(name = "refundAmount", value = "退款金额(分)", required = true, dataType = "BigDecimal", dataTypeClass = BigDecimal.class)
|
|
|
|
|
+ })
|
|
|
|
|
+ @PostMapping("/refund")
|
|
|
|
|
+ public WxPayRefundV3Result refund(String orderNo, BigDecimal payAmount, BigDecimal refundAmount) {
|
|
|
|
|
+ return wechatPayService.refund(orderNo, payAmount, refundAmount);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|