From c4664502dfdaffff555b532e65b51a57ac8b29c2 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期三, 16 十月 2024 17:51:32 +0800
Subject: [PATCH] 合并代码

---
 ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/wx/utils/WxV3Pay.java |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/wx/utils/WxV3Pay.java b/ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/wx/utils/WxV3Pay.java
index b76bbfd..e322861 100644
--- a/ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/wx/utils/WxV3Pay.java
+++ b/ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/wx/utils/WxV3Pay.java
@@ -5,8 +5,9 @@
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.ruoyi.payment.wx.model.WeixinProperties;
+import com.ruoyi.payment.wx.model.WxCloseOrderModel;
 import com.ruoyi.payment.wx.model.WxPaymentInfoModel;
-import com.ruoyi.payment.wx.model.WxPaymentRefundModel;
+import com.ruoyi.payment.api.model.WxPaymentRefundModel;
 import com.ruoyi.payment.wx.resp.NotifyV3PayDecodeRespBody;
 import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
 import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
@@ -120,17 +121,18 @@
      * @author xiaochen
      * @date 2022-03-22 12:47
      */
-    public Map<String, Object> jsApi(String tradeNo, Integer amount, String openid, String description) {
+    public Map<String, Object> jsApi(String tradeNo, Integer amount, String openid, String notify_url, String description) {
         WxPaymentInfoModel requestBody = WxPaymentInfoModel.builder()
                 .mchid(this.config.getMchId())
                 .appid(this.config.getAppId())
                 .description(description)
                 .out_trade_no(tradeNo)
+                .notify_url(notify_url)
 //                .attach("")
                 .amount(WxPaymentInfoModel.Amount.builder().total(amount).build())
                 .payer(WxPaymentInfoModel.Payer.builder().openid(openid).build())
                 // 分不分账
-                //.settle_info(WxPaymentInfoModel.SettleInfo.builder().profit_sharing(true).build())
+//                .settle_info(WxPaymentInfoModel.SettleInfo.builder().profit_sharing(true).build())
                 .build();
         // 封装基础数据
         String reqBody = buildBaseParam(requestBody
@@ -169,15 +171,14 @@
      * 订单查询
      *
      * @param out_trade_no
-     * @param mchid
      * @return com.abl.biz.center.payment.wx.v3.NotifyV3PayDecodeRespBody
      * @author xiaochen
      * @date 2021-12-20 16:47
      */
     @Override
-    public NotifyV3PayDecodeRespBody query(String out_trade_no, String mchid) {
+    public NotifyV3PayDecodeRespBody query(String out_trade_no) {
         String url =
-                String.format("/v3/pay/transactions/out-trade-no/%s", out_trade_no) + String.format("?mchid=%s", mchid);
+                String.format("/v3/pay/transactions/out-trade-no/%s", out_trade_no) + String.format("?mchid=%s", this.getConfig().getMchId());
         return query(this.httpClient, this.config.getHttpReadTimeoutMs(), this.config.getHttpConnectTimeoutMs(), url);
     }
 
@@ -190,8 +191,21 @@
      */
     @Override
     public Map<String, Object> refund(WxPaymentRefundModel refundModel) {
-//        refundModel.setNotify_url(this.config.getV3().getNotifyRefundUrl());
+        refundModel.setNotify_url(this.config.getV3().getNotifyRefundUrl() + refundModel.getNotify_url());
         return refund(this.httpClient, "/v3/refund/domestic/refunds", this.config.getHttpReadTimeoutMs(), this.config.getHttpConnectTimeoutMs(), refundModel);
     }
-
+    
+    
+    /**
+     * 关闭订单
+     * @param out_trade_no
+     * @return
+     */
+    @Override
+    public String close(String out_trade_no) {
+        String uri = String.format("/v3/pay/transactions/out-trade-no/%s/close", out_trade_no);
+        WxCloseOrderModel wxCloseOrderModel = new WxCloseOrderModel();
+        wxCloseOrderModel.setMchid(this.config.getMchId());
+        return close(this.httpClient, uri, this.config.getHttpReadTimeoutMs(), this.config.getHttpConnectTimeoutMs(), wxCloseOrderModel);
+    }
 }

--
Gitblit v1.7.1