wangming 1 hete
szülő
commit
269d756086

+ 7 - 2
yami-shop-api/src/main/java/com/yami/shop/api/controller/PayController.java

@@ -21,6 +21,7 @@ import com.yami.shop.service.PayService;
 import com.yami.shop.service.RefundDeliveryService;
 import com.yami.shop.wx.config.WechatPayServiceConfig;
 import com.yami.shop.wx.po.JsapiPayInfoPo;
+import com.yami.shop.wx.po.RefundInfoPo;
 import com.yami.shop.wx.service.WxProviderService;
 import com.yami.shop.wx.utils.CullenUtils;
 import com.yami.shop.wx.utils.OrderUtils;
@@ -43,14 +44,18 @@ public class PayController {
     private final OrderService orderService;
     private final RefundDeliveryService refundDeliveryService;
     private final WxProviderService wxProviderService;
-    private final String baseNotifyUrl ="http://he56cd66.natappfree.cc";
+    private final String baseNotifyUrl ="https://bus.qlapp.cn";
 
 
     @SneakyThrows
     @PostMapping("/refund")
     @ApiOperation(value = "测试退款")
     public ResponseEntity<?> refund() {
-        return ResponseEntity.ok(wxProviderService.refundOrder("1971409316510568448",1,1));
+        RefundInfoPo po = new RefundInfoPo();
+        po.setOutTradeNo("");
+        po.setTotal(0);
+        po.setRefundMoney(0);
+        return ResponseEntity.ok(wxProviderService.refundOrder(po));
     }
 
 

+ 31 - 0
yami-shop-wx/src/main/java/com/yami/shop/wx/po/RefundInfoPo.java

@@ -0,0 +1,31 @@
+package com.yami.shop.wx.po;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author kaur
+ */
+@Data
+@ApiModel(value = "小程序退款")
+@AllArgsConstructor
+@NoArgsConstructor
+public class RefundInfoPo {
+
+    @ApiModelProperty(value = "订单号")
+    @NotNull(message = "订单号不能为空...")
+    private String outTradeNo;
+
+    @ApiModelProperty(value = "总金额")
+    @NotNull(message = "总金额不能为空...")
+    private Integer total;
+
+    @ApiModelProperty(value = "退款金额")
+    @NotNull(message = "退款金额不能为空...")
+    private Integer refundMoney;
+}

+ 2 - 1
yami-shop-wx/src/main/java/com/yami/shop/wx/service/WxProviderService.java

@@ -3,6 +3,7 @@ package com.yami.shop.wx.service;
 import com.yami.shop.bean.bo.PayInfoBo;
 import com.yami.shop.wx.config.WechatPayServiceConfig;
 import com.yami.shop.wx.po.JsapiPayInfoPo;
+import com.yami.shop.wx.po.RefundInfoPo;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -12,7 +13,7 @@ public interface WxProviderService {
 
     Map<String, Object> subJsapi(JsapiPayInfoPo po);
 
-    String refundOrder(String orderNo, Integer refundMoney, Integer total);
+    String refundOrder(RefundInfoPo po);
 
     PayInfoBo notifyParse(HttpServletRequest request, HttpServletResponse response);
 

+ 11 - 9
yami-shop-wx/src/main/java/com/yami/shop/wx/service/impl/WxProviderServiceImpl.java

@@ -14,6 +14,7 @@ import com.yami.shop.bean.bo.PayInfoBo;
 import com.yami.shop.wx.config.CombinePayUrlEnum;
 import com.yami.shop.wx.config.WechatPayServiceConfig;
 import com.yami.shop.wx.po.JsapiPayInfoPo;
+import com.yami.shop.wx.po.RefundInfoPo;
 import com.yami.shop.wx.service.WxProviderService;
 import com.yami.shop.wx.utils.CullenUtils;
 import com.yami.shop.wx.utils.OrderUtils;
@@ -52,6 +53,8 @@ public class WxProviderServiceImpl implements WxProviderService {
 
     private static final String WX_SUCCESS_XML = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
 
+    private static final String REFUND_URL = "https://bus.qlapp.cn/notice/pay/order/refundNotify";
+
     @Override
     public Map<String, Object> subJsapi(JsapiPayInfoPo po) {
         System.out.println("微信支付传入参数===========" + po);
@@ -169,26 +172,26 @@ public class WxProviderServiceImpl implements WxProviderService {
     /**
      * 申请退款
      *
-     * @param orderNo orderNo
-     * @return orderNo
+     * @param po 请求参数
+     * @return 退款结果
      */
     @Override
-    public String refundOrder(String orderNo, Integer refundMoney, Integer total) {
-        log.info("根据订单号申请退款,订单号: {}", orderNo);
+    public String refundOrder(RefundInfoPo po) {
+        log.info("根据订单号申请退款,订单号: {}", po.getOutTradeNo());
         String url = wechatPayServiceConfig.getBaseUrl().concat(CombinePayUrlEnum.DOMESTIC_REFUNDS.getType());
         Map<String, Object> params = new HashMap<>(2);
-        params.put("out_trade_no", orderNo);
+        params.put("out_trade_no", po.getOutTradeNo());
         params.put("sub_mchid", wechatPayServiceConfig.getSubMchId());
         String outRefundNo = OrderUtils.getOrderNo("TK");
         log.info("退款申请号:{}", outRefundNo);
         params.put("out_refund_no", outRefundNo);
         params.put("reason", "申请退款");
-        params.put("notify_url", "http://he56cd66.natappfree.cc/notice/pay/order/refundNotify");
+        params.put("notify_url", REFUND_URL);
         Map<String, Object> amountMap = new HashMap<>();
         //退款金额,单位:分
-        amountMap.put("refund", refundMoney);
+        amountMap.put("refund", po.getRefundMoney());
         //原订单金额,单位:分
-        amountMap.put("total", total);
+        amountMap.put("total", po.getTotal());
         amountMap.put("currency", "CNY");
         params.put("amount", amountMap);
         String paramsStr = JSON.toJSONString(params);
@@ -401,7 +404,6 @@ public class WxProviderServiceImpl implements WxProviderService {
                     resourceJson.get("out_refund_no");
                     resourceJson.get("refund_id");
                 }
-
             } finally {
                 lock.unlock();
             }