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());