From 4f64a1b1b3301b86f0bcf67fe81bf7026e024836 Mon Sep 17 00:00:00 2001 From: 306932545 <306932545@qq.com> Date: Thu, 21 Nov 2024 17:03:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E6=94=B6=E4=BB=98=E9=80=9A?= =?UTF-8?q?=EF=BC=88=E9=80=80=E6=AC=BE=EF=BC=89=20=E4=BF=AE=E6=94=B9:=201?= =?UTF-8?q?=E3=80=81=E7=94=B3=E8=AF=B7=E9=80=80=E6=AC=BEAPI,=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E9=80=80=E6=AC=BEAPI,=E9=80=80=E6=AC=BE=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E9=80=9A=E7=9F=A5API=EF=BC=8C=E4=B8=89=E4=B8=AA?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0=E6=96=B0=E7=9A=84=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=20=E6=B7=BB=E5=8A=A0:=201=E3=80=81=E5=9E=AB=E4=BB=98?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E5=9B=9E=E8=A1=A5API=E6=8E=A5=E5=8F=A3=202?= =?UTF-8?q?=E3=80=81=E6=9F=A5=E8=AF=A2=E5=9E=AB=E4=BB=98=E5=9B=9E=E8=A1=A5?= =?UTF-8?q?=E7=BB=93=E6=9E=9CAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bean/ecommerce/RefundNotifyResult.java | 19 +++ .../bean/ecommerce/RefundQueryResult.java | 38 +++++ .../wxpay/bean/ecommerce/RefundsRequest.java | 35 ++++ .../wxpay/bean/ecommerce/RefundsResult.java | 18 ++ .../bean/ecommerce/ReturnAdvanceResult.java | 159 ++++++++++++++++++ .../wxpay/service/EcommerceService.java | 27 +++ .../service/impl/EcommerceServiceImpl.java | 19 +++ 7 files changed, 315 insertions(+) create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnAdvanceResult.java diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundNotifyResult.java index 89ef5d0cb..c8c6c1058 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundNotifyResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundNotifyResult.java @@ -170,6 +170,25 @@ public class RefundNotifyResult implements Serializable { @SerializedName(value = "amount") private Amount amount; + /** + *
+   * 字段名:退款出资商户
+   * 变量名:refund_account
+   * 是否必填:否
+   * 类型:string(32)
+   * 描述:
+   *   电商平台垫资退款专用参数。需先确认已开通此功能后,才能使用。若需要开通,请联系微信支付客服。
+   *   枚举值:
+   *   REFUND_SOURCE_PARTNER_ADVANCE : 电商平台垫付,需要向微信支付申请开通
+   *   REFUND_SOURCE_SUB_MERCHANT : 二级商户,默认值
+   *   注意:
+   *   若传入REFUND_SOURCE_PARTNER_ADVANCE,仅代表可以使用垫付退款,实际出款账户需以退款申请受理结果或查单结果为准。
+   *   示例值:REFUND_SOURCE_SUB_MERCHANT
+   * 
+ */ + @SerializedName(value = "refund_account") + private String refundAccount; + @Data @NoArgsConstructor public static class Amount implements Serializable { diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundQueryResult.java index bbb30ea89..bfcd499e2 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundQueryResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundQueryResult.java @@ -183,6 +183,44 @@ public class RefundQueryResult implements Serializable { */ public List promotionDetails; + + /** + *
+   * 字段名:退款出资商户
+   * 变量名:refund_account
+   * 是否必填:否
+   * 类型:string(32)
+   * 描述:
+   *   电商平台垫资退款专用参数。需先确认已开通此功能后,才能使用。若需要开通,请联系微信支付客服。
+   *   枚举值:
+   *   REFUND_SOURCE_PARTNER_ADVANCE : 电商平台垫付,需要向微信支付申请开通
+   *   REFUND_SOURCE_SUB_MERCHANT : 二级商户,默认值
+   *   注意:
+   *   若传入REFUND_SOURCE_PARTNER_ADVANCE,仅代表可以使用垫付退款,实际出款账户需以退款申请受理结果或查单结果为准。
+   *   示例值:REFUND_SOURCE_SUB_MERCHANT
+   * 
+ */ + @SerializedName(value = "refund_account") + private String refundAccount; + + /** + *
+   * 字段名:资金账户
+   * 变量名:funds_account
+   * 是否必填:否
+   * 类型:string(32)
+   * 描述:
+   *   若订单处于待分账状态,且未指定垫资退款(即refund_account未指定为REFUND_SOURCE_PARTNER_ADVANCE),
+   *   可以传入此参数,指定退款资金来源账户。当该字段不存在时,默认使用订单交易资金所在账户出款,
+   *   即待分账时使用不可用余额的资金进行退款,已分账或无分账时使用可用余额的资金进行退款。 AVAILABLE:可用余额
+   * 示例值:AVAILABLE
+   * 
+ */ + @SerializedName(value = "funds_account") + private String fundsAccount; + + + @Data @NoArgsConstructor public static class Amount implements Serializable { diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsRequest.java index 96e6c22fa..b453a994f 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsRequest.java @@ -147,6 +147,41 @@ public class RefundsRequest implements Serializable { @SerializedName(value = "notify_url") private String notifyUrl; + /** + *
+   * 字段名:退款出资商户
+   * 变量名:refund_account
+   * 是否必填:否
+   * 类型:string(32)
+   * 描述:
+   *   电商平台垫资退款专用参数。需先确认已开通此功能后,才能使用。若需要开通,请联系微信支付客服。
+   *   枚举值:
+   *   REFUND_SOURCE_PARTNER_ADVANCE : 电商平台垫付,需要向微信支付申请开通
+   *   REFUND_SOURCE_SUB_MERCHANT : 二级商户,默认值
+   *   注意:
+   *   若传入REFUND_SOURCE_PARTNER_ADVANCE,仅代表可以使用垫付退款,实际出款账户需以退款申请受理结果或查单结果为准。
+   *   示例值:REFUND_SOURCE_SUB_MERCHANT
+   * 
+ */ + @SerializedName(value = "refund_account") + private String refundAccount; + + /** + *
+   * 字段名:资金账户
+   * 变量名:funds_account
+   * 是否必填:否
+   * 类型:string(32)
+   * 描述:
+   *   若订单处于待分账状态,且未指定垫资退款(即refund_account未指定为REFUND_SOURCE_PARTNER_ADVANCE),
+   *   可以传入此参数,指定退款资金来源账户。当该字段不存在时,默认使用订单交易资金所在账户出款,
+   *   即待分账时使用不可用余额的资金进行退款,已分账或无分账时使用可用余额的资金进行退款。 AVAILABLE:可用余额
+   * 示例值:AVAILABLE
+   * 
+ */ + @SerializedName(value = "funds_account") + private String fundsAccount; + @Data @Builder @NoArgsConstructor(access = AccessLevel.PRIVATE) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java index 963758740..9d66ce8c3 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java @@ -240,4 +240,22 @@ public class RefundsResult implements Serializable { } + + /** + *
+   * 字段名:退款资金来源
+   * 变量名:refund_account
+   * 是否必填:否
+   * 类型:string(32)
+   * 描述:
+   *   枚举值:
+   * REFUND_SOURCE_PARTNER_ADVANCE : 电商平台垫付
+   * REFUND_SOURCE_SUB_MERCHANT : 二级商户,默认值
+   * 示例值:REFUND_SOURCE_SUB_MERCHANT
+   * 
+ */ + @SerializedName(value = "refund_account") + private String refundAccount; + + } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnAdvanceResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnAdvanceResult.java new file mode 100644 index 000000000..e47bd5ca3 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnAdvanceResult.java @@ -0,0 +1,159 @@ +package com.github.binarywang.wxpay.bean.ecommerce; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + + +/** + * 垫付退款回补API结果 + * *
+ *  *   文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_6_4.shtml
+ *  * 
+ * + * @author yantao + * created on 2024/11/20 + */ +@Data +@NoArgsConstructor +public class ReturnAdvanceResult implements Serializable { + + private static final long serialVersionUID = -186851559004865784L; + + /** + *
+   * 字段名:微信退款单号
+   * 变量名:refund_id
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   * 微信支付退款单的主键,唯一定义此资源的标识。 必须是垫付退款的微信支付退款单
+   * 示例值:50000000382019052709732678859
+   * 
+ */ + @SerializedName(value = "refund_id") + private String refundId; + + /** + *
+   * 字段名:微信回补单号
+   * 变量名:advance_return_id
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:微信支付生成的垫付回补操作单号
+   * 示例值:1215562501201407033233368018
+   * 
+ */ + @SerializedName(value = "advance_return_id") + private String advanceReturnId ; + + /** + *
+   * 字段名:垫付回补金额
+   * 变量名:return_amount
+   * 是否必填:是
+   * 类型:int
+   * 描述:退款单对应的垫付退款的金额
+   * 示例值:888
+   * 
+ */ + @SerializedName(value = "return_amount") + private Integer returnAmount ; + + /** + *
+   * 字段名:出款方商户号
+   * 变量名:payer_mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:微信支付分配给出款方的商户号
+   * 示例值:1900000109
+   * 
+ */ + @SerializedName(value = "payer_mchid") + private String payerMchid ; + + /** + *
+   * 字段名:出款方账户
+   * 变量名:payer_account
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   * 枚举值:
+   * BASIC:基本账户
+   * OPERATION:运营账户
+   * 示例值:BASIC
+   * 
+ */ + @SerializedName(value = "payer_account") + private String payerAccount; + + /** + *
+   * 字段名:入账方商户号
+   * 变量名:payee_mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   * 微信支付分配给入账方的商户号
+   * 示例值:1900000108
+   * 
+ */ + @SerializedName(value = "payee_mchid") + private String payeeMchid; + + /** + *
+   * 字段名:入账方账户
+   * 变量名:payee_account
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:枚举值:
+   * BASIC:基本账户
+   * OPERATION:运营账户
+   * 示例值:BASIC
+   * 
+ */ + @SerializedName(value = "payee_account") + private String payeeAccount; + + /** + *
+   * 字段名:垫付回补结果
+   * 变量名:result
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:枚举值:
+   * SUCCESS:回补成功
+   * FAILED:回补失败,出款方账户余额不足时发生
+   * PROCESSING:处理中
+   * 示例值:SUCCESS
+   * 
+ */ + @SerializedName(value = "result") + private String result ; + + /** + *
+   * 字段名:垫付回补完成时间
+   * 变量名:success_time
+   * 是否必填:否
+   * 类型:string(64)
+   * 描述:垫付回补完成的时间,遵循rfc3339标准格式,
+   * 格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,
+   * T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,
+   * TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+   * 例如:2015-05-20T13:29:35+08:00表示北京时间2015年05月20日13点29分35秒。
+   * 示例值:2018-06-08T10:34:56+08:00
+   * 
+ */ + @SerializedName(value = "success_time") + private String successTime; + + + +} 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 99d17e073..2dbb2906c 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 @@ -364,6 +364,33 @@ public interface EcommerceService { */ RefundQueryResult queryRefundByRefundId(String subMchid, String refundId) throws WxPayException; + + /** + *
+   * 垫付退款回补API
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_6_4.shtml
+   * 
+ * + * @param subMchid 二级商户号 + * @param refundId 微信退款单号 + * @return 返回数据 return refunds result + * @throws WxPayException the wx pay exception + */ + ReturnAdvanceResult refundsReturnAdvance(String subMchid, String refundId) throws WxPayException; + + + /** + *
+   * 查询垫付回补结果API
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_6_5.shtml
+   * 
+ * + * @param subMchid 二级商户号 + * @param refundId 微信退款单号 + * @return 返回数据 return refunds result + * @throws WxPayException the wx pay exception + */ + ReturnAdvanceResult queryRefundsReturnAdvance(String subMchid, String refundId) 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 3671ab72b..36dc08d6f 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
@@ -290,6 +290,25 @@ public class EcommerceServiceImpl implements EcommerceService {
     return GSON.fromJson(response, RefundQueryResult.class);
   }
 
+
+  @Override
+  public ReturnAdvanceResult refundsReturnAdvance(String subMchid, String refundId) throws WxPayException {
+    String url = String.format("%s/v3/ecommerce/refunds/%s/return-advance", this.payService.getPayBaseUrl(), refundId);
+    Map request = new HashMap();
+    request.put("sub_mchid",subMchid);
+    String response = this.payService.postV3(url, GSON.toJson(request));
+    return GSON.fromJson(response, ReturnAdvanceResult.class);
+  }
+
+
+  @Override
+  public ReturnAdvanceResult queryRefundsReturnAdvance(String subMchid, String refundId) throws WxPayException {
+    String url = String.format("%s/v3/ecommerce/refunds/%s/return-advance?sub_mchid=%s", this.payService.getPayBaseUrl(), refundId,subMchid);
+    String response = this.payService.getV3(url);
+    return GSON.fromJson(response, ReturnAdvanceResult.class);
+  }
+
+
   @Override
   public RefundQueryResult queryRefundByOutRefundNo(String subMchid, String outRefundNo) throws WxPayException {
     String url = String.format("%s/v3/ecommerce/refunds/out-refund-no/%s?sub_mchid=%s", this.payService.getPayBaseUrl(), outRefundNo, subMchid);
-- 
Gitee