From 13b484a071f33c620b28f2c5d08440123ebdaac3 Mon Sep 17 00:00:00 2001 From: ray Wang Date: Sun, 24 Jan 2021 10:47:59 +0800 Subject: [PATCH] =?UTF-8?q?:new:=20#1978=20=E3=80=90=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E3=80=91=E7=94=B5=E5=95=86=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E9=80=9A=E5=A2=9E=E5=8A=A0=E6=9F=A5=E8=AF=A2=E5=88=86=E8=B4=A6?= =?UTF-8?q?=E5=9B=9E=E9=80=80=E7=BB=93=E6=9E=9C=E7=9A=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ecommerce/ReturnOrdersQueryRequest.java | 76 +++++++++++++++++++ .../wxpay/service/EcommerceService.java | 12 +++ .../service/impl/EcommerceServiceImpl.java | 19 +++++ 3 files changed, 107 insertions(+) create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersQueryRequest.java diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersQueryRequest.java new file mode 100644 index 000000000..1b6aeee80 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersQueryRequest.java @@ -0,0 +1,76 @@ +package com.github.binarywang.wxpay.bean.ecommerce; + +import com.google.gson.annotations.SerializedName; +import lombok.*; + +import java.io.Serializable; + +/** + * 查询分账回退结果请求 + * *
+ *  *   文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/profitsharing/chapter3_3.shtml
+ *  * 
+ * @author: wangrui + * @date: 2021/02/20 + */ +@Data +@Builder +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class ReturnOrdersQueryRequest implements Serializable { + /** + *
+   * 字段名:二级商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  分账出资的电商平台二级商户,填写微信支付分配的商户号。
+   *  示例值:1900000109
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:微信分账单号
+   * 变量名:order_id
+   * 是否必填:与out_order_no二选一
+   * 类型:string(64)
+   * 描述:
+   *  微信分账单号,微信系统返回的唯一标识。微信分账单号和商户分账单号二选一填写。
+   *  示例值:3008450740201411110007820472
+   * 
+ */ + @SerializedName(value = "order_id") + private String orderId; + + /** + *
+   * 字段名:商户分账单号
+   * 变量名:out_order_no
+   * 是否必填:与order_id二选一
+   * 类型:string(64)
+   * 描述:
+   *   商户系统内部的分账单号,在商户系统内部唯一(单次分账、多次分账、完结分账应使用不同的商户分账单号),同一分账单号多次请求等同一次。
+   *  示例值:P20150806125346
+   * 
+ */ + @SerializedName(value = "out_order_no") + private String outOrderNo; + + /** + *
+   * 字段名:商户回退单号
+   * 变量名:out_return_no
+   * 是否必填:是
+   * 类型:string(64)
+   * 描述:
+   *   此回退单号是商户在自己后台生成的一个新的回退单号,在商户后台唯一。
+   *  示例值:P20150806125346
+   * 
+ */ + @SerializedName(value = "out_return_no") + private String outReturnNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java index 9df71e20d..cd81d60ae 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java @@ -287,6 +287,18 @@ public interface EcommerceService { */ ReturnOrdersResult returnOrders(ReturnOrdersRequest request) throws WxPayException; + /** + *
+   * 查询分账回退API
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/profitsharing/chapter3_3.shtml
+   * 
+ * + * @param request 查询分账回退请求 + * @return 返回数据 return orders result + * @throws WxPayException the wx pay exception + */ + ReturnOrdersResult queryReturnOrders(ReturnOrdersQueryRequest request) throws WxPayException; + /** *
    * 完结分账API
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java
index 5366fb08d..1192d609e 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java
@@ -12,6 +12,7 @@ import com.github.binarywang.wxpay.v3.util.RsaCryptoUtil;
 import com.google.common.base.CaseFormat;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
+import org.apache.commons.lang3.StringUtils;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.beanutils.BeanMap;
 
@@ -224,6 +225,24 @@ public class EcommerceServiceImpl implements EcommerceService {
     return GSON.fromJson(response, ReturnOrdersResult.class);
   }
 
+  @Override
+  public ReturnOrdersResult queryReturnOrders(ReturnOrdersQueryRequest request) throws WxPayException {
+    String subMchid = request.getSubMchid();
+    String orderId = request.getOrderId();
+    String outOrderNo = request.getOutOrderNo();
+    String outReturnNo = request.getOutReturnNo();
+    String url = null;
+    if (StringUtils.isBlank(orderId)) {
+      url = String.format("%s/v3/ecommerce/profitsharing/returnorders?sub_mchid=%s&out_order_no=%s&out_return_no=%s",
+        this.payService.getPayBaseUrl(), subMchid, outOrderNo, outReturnNo);
+    } else {
+      url = String.format("%s/v3/ecommerce/profitsharing/returnorders?sub_mchid=%s&order_id=%s&out_return_no=%s",
+        this.payService.getPayBaseUrl(), subMchid, orderId, outReturnNo);
+    }
+    String response = this.payService.getV3(URI.create(url));
+    return GSON.fromJson(response, ReturnOrdersResult.class);
+  }
+
   @Override
   public ProfitSharingResult finishOrder(FinishOrderRequest request) throws WxPayException {
     String url = String.format("%s/v3/ecommerce/profitsharing/finish-order", this.payService.getPayBaseUrl());