Browse Source

:new: #2120 【微信支付】微信分账服务类增加v3接口

pg 3 years ago
parent
commit
577b756912

+ 144 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReceiver.java

@@ -0,0 +1,144 @@
+package com.github.binarywang.wxpay.bean.profitsharingV3;
+
+import com.github.binarywang.wxpay.v3.SpecEncrypt;
+import com.google.gson.annotations.SerializedName;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ *
+ * 微信V3接口 分账接收方实体
+ * @author pg
+ * @date 2021-6-25
+ *
+ */
+@Data
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
+public class ProfitSharingReceiver implements Serializable {
+  private static final long serialVersionUID = -4391888575149767840L;
+
+  /**
+   * <pre>
+   * 字段名:应用ID
+   * 是否必填:是
+   * 描述:微信分配的商户appid
+   * </pre>
+   */
+  @SerializedName("appid")
+  private String appid;
+
+  /**
+   * <pre>
+   * 字段名:分账接收方类型
+   * 是否必填:是
+   * 描述:
+   * 1、MERCHANT_ID:商户号
+   * 2、PERSONAL_OPENID:个人openid(由父商户APPID转换得到)
+   * </pre>
+   */
+  @SerializedName("type")
+  private String type;
+
+  /**
+   * <pre>
+   * 字段名:分账接收方帐号
+   * 是否必填:是
+   * 描述:
+   * 1、分账接收方类型为MERCHANT_ID时,分账接收方账号为商户号
+   * 2、分账接收方类型为PERSONAL_OPENID时,分账接收方账号为个人openid
+   * </pre>
+   */
+  @SerializedName("account")
+  private String account;
+
+  /**
+   * <pre>
+   * 字段名:分账个人接收方姓名
+   * 是否必填:否
+   * 描述:
+   * 可选项,在接收方类型为个人的时可选填,若有值,会检查与 name 是否实名匹配,不匹配会拒绝分账请求
+   * 1、分账接收方类型是PERSONAL_OPENID,是个人姓名的密文(选传,传则校验) 此字段的加密方法详见:敏感信息加密说明
+   * 2、使用微信支付平台证书中的公钥
+   * 3、使用RSAES-OAEP算法进行加密
+   * 4、将请求中HTTP头部的Wechatpay-Serial设置为证书序列号
+   * </pre>
+   */
+  @SerializedName("name")
+  @SpecEncrypt
+  private String name;
+
+  /**
+   * <pre>
+   * 字段名:与分账方的关系类型
+   * 是否必填:是
+   * 描述:子商户与接收方的关系。 本字段值为枚举:
+   * STORE:门店
+   * STAFF:员工
+   * STORE_OWNER:店主
+   * PARTNER:合作伙伴
+   * HEADQUARTER:总部
+   * BRAND:品牌方
+   * DISTRIBUTOR:分销商
+   * USER:用户
+   * SUPPLIER: 供应商
+   * CUSTOM:自定义
+   * </pre>
+   */
+  @SerializedName("relation_type")
+  private String relationType;
+
+  /**
+   * <pre>
+   * 字段名:自定义的分账关系
+   * 是否必填:是
+   * 描述:子商户与接收方具体的关系,本字段最多10个字。
+   * 当字段relationType的值为CUSTOM时,本字段必填;
+   * 当字段relationType的值不为CUSTOM时,本字段无需填写。
+   * </pre>
+   */
+  @SerializedName("custom_relation")
+  private String customRelation;
+
+  /**
+   * <pre>
+   * 字段名:分账描述
+   * 是否必填:是
+   * 描述: 分账的原因描述,分账账单中需要体现
+   * </pre>
+   */
+  private String description;
+  /**
+   * <pre>
+   * 字段名:分账金额
+   * 是否必填:是
+   * 描述: 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
+   * </pre>
+   */
+  private Long amount;
+
+  /**
+   * 此构造函数用于分账接口
+   *
+   * @param type        MERCHANT_ID:商户ID
+   *                    PERSONAL_WECHATID:个人微信号PERSONAL_OPENID:个人openid(由父商户APPID转换得到)PERSONAL_SUB_OPENID: 个人sub_openid(由子商户APPID转换得到)
+   * @param account     类型是MERCHANT_ID时,是商户ID
+   *                    类型是PERSONAL_WECHATID时,是个人微信号
+   *                    类型是PERSONAL_OPENID时,是个人openid
+   *                    类型是PERSONAL_SUB_OPENID时,是个人sub_openid
+   * @param amount      分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
+   * @param description 分账的原因描述,分账账单中需要体现
+   */
+  public ProfitSharingReceiver(String type, String account, Long amount, String description) {
+    this.type = type;
+    this.account = account;
+    this.amount = amount;
+    this.description = description;
+  }
+
+}

+ 77 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingRequest.java

@@ -0,0 +1,77 @@
+package com.github.binarywang.wxpay.bean.profitsharingV3;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 微信V3接口
+ * 请求分账API请求实体
+ *
+ * @author pg
+ * @date 2021-6-24
+ */
+@Data
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
+public class ProfitSharingRequest implements Serializable {
+  private static final long serialVersionUID = 3644929701624280800L;
+
+  /**
+   * <pre>
+   * 字段名:应用ID
+   * 是否必填:是
+   * 描述:微信分配的商户appid
+   * </pre>
+   */
+  @SerializedName("appid")
+  private String appid;
+
+  /**
+   * <pre>
+   * 字段名:微信订单号
+   * 是否必填:是
+   * 描述:微信支付订单号
+   * </pre>
+   */
+  @SerializedName("transaction_id")
+  private String transactionId;
+
+  /**
+   * <pre>
+   * 字段名:商户分账单号
+   * 是否必填:是
+   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
+   * </pre>
+   */
+  @SerializedName("out_order_no")
+  private String outOrderNo;
+
+  /**
+   * <pre>
+   * 字段名:分账接收方列表
+   * 是否必填:是
+   * 描述:分账接收方列表,可以设置出资商户作为分账接受方,最多可有50个分账接收方
+   * </pre>
+   */
+  @SerializedName("receivers")
+  private List<ProfitSharingReceiver> receivers;
+
+  /**
+   * <pre>
+   * 字段名:是否解冻剩余未分资金
+   * 是否必填:是
+   * 描述:
+   * 1、如果为true,该笔订单剩余未分账的金额会解冻回分账方商户;
+   * 2、如果为false,该笔订单剩余未分账的金额不会解冻回分账方商户,可以对该笔订单再次进行分账。
+   * </pre>
+   */
+  @SerializedName("unfreeze_unsplit")
+  private boolean unfreezeUnsplit;
+}

+ 172 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingResult.java

@@ -0,0 +1,172 @@
+package com.github.binarywang.wxpay.bean.profitsharingV3;
+
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 微信V3接口
+ * 请求分账API返回的分账结果实体
+ *
+ * @author pg
+ * @date 2021-6-24
+ */
+@Data
+public class ProfitSharingResult implements Serializable {
+  private static final long serialVersionUID = -6201692412535987502L;
+
+  /**
+   * <pre>
+   * 字段名:微信订单号
+   * 是否必填:是
+   * 描述:微信支付订单号
+   * </pre>
+   */
+  @SerializedName("transaction_id")
+  private String transactionId;
+
+  /**
+   * <pre>
+   * 字段名:商户分账单号
+   * 是否必填:是
+   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
+   * </pre>
+   */
+  @SerializedName("out_order_no")
+  private String outOrderNo;
+
+  /**
+   * <pre>
+   * 字段名:微信分账单号,
+   * 是否必填:是
+   * 描述:微信系统返回的唯一标识.
+   * </pre>
+   */
+  @SerializedName("order_id")
+  private String orderId;
+
+  /**
+   * <pre>
+   * 字段名:分账单状态
+   * 是否必填:是
+   * 描述:分账单状态(每个接收方的分账结果请查看receivers中的result字段):
+   * 1、PROCESSING:处理中
+   * 2、FINISHED:分账完成.
+   * </pre>
+   */
+  @SerializedName("state")
+  private String state;
+
+  /**
+   * 分账接收方列表
+   */
+  @SerializedName("receivers")
+  private List<Receiver> receivers;
+
+  @Data
+  public static class Receiver implements Serializable {
+    private static final long serialVersionUID = 4240983048700956806L;
+
+    /**
+     * <pre>
+     * 字段名:分账接收方类型
+     * 是否必填:是
+     * 描述:
+     * 1、MERCHANT_ID:商户号
+     * 2、PERSONAL_OPENID:个人openid(由父商户APPID转换得到)
+     * </pre>
+     */
+    @SerializedName("type")
+    private String type;
+
+    /**
+     * <pre>
+     * 字段名:分账接收方帐号
+     * 是否必填:是
+     * 描述:
+     * 1、分账接收方类型为MERCHANT_ID时,分账接收方账号为商户号
+     * 2、分账接收方类型为PERSONAL_OPENID时,分账接收方账号为个人openid
+     * </pre>
+     */
+    @SerializedName("account")
+    private String account;
+
+    /**
+     * <pre>
+     * 字段名:分账金额
+     * 是否必填:是
+     * 描述: 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
+     * </pre>
+     */
+    @SerializedName("amount")
+    private Long amount;
+
+    /**
+     * <pre>
+     * 字段名:分账描述
+     * 是否必填:是
+     * 描述: 分账的原因描述,分账账单中需要体现
+     * </pre>
+     */
+    @SerializedName("description")
+    private String description;
+
+    /**
+     * <pre>
+     * 字段名:分账结果
+     * 是否必填:是
+     * 描述:
+     * 1、PENDING:待分账
+     * 2、SUCCESS:分账成功
+     * 3、CLOSED:已关闭
+     * </pre>
+     */
+    @SerializedName("result")
+    private String result;
+
+    /**
+     * <pre>
+     * 字段名:分账失败原因
+     * 是否必填:是
+     * 描述:包含以下枚举值:
+     * 1、ACCOUNT_ABNORMAL : 分账接收账户异常
+     * 2、NO_RELATION : 分账关系已解除
+     * 3、RECEIVER_HIGH_RISK : 高风险接收方
+     * 4、RECEIVER_REAL_NAME_NOT_VERIFIED : 接收方未实名
+     * 5、NO_AUTH : 分账权限已解除
+     * </pre>
+     */
+    @SerializedName("fail_reason")
+    private String failReason;
+
+    /**
+     * <pre>
+     * 字段名:分账创建时间
+     * 是否必填:是
+     * 描述:遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,
+     * YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,
+     * HH:mm:ss.sss表示时分秒毫秒,
+     * TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+     * 例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
+     * </pre>
+     */
+    @SerializedName("create_time")
+    private String createTime;
+    /**
+     * <pre>
+     * 字段名:分账完成时间
+     * 是否必填:是
+     * 描述:遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,
+     * YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,
+     * HH:mm:ss.sss表示时分秒毫秒,
+     * TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+     * 例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
+     * </pre>
+     */
+    @SerializedName("finish_time")
+    private String finishTime;
+  }
+}

+ 82 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReturnRequest.java

@@ -0,0 +1,82 @@
+package com.github.binarywang.wxpay.bean.profitsharingV3;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 微信V3接口
+ * 请求分账回退API请求实体
+ *
+ * @author pg
+ * @date 2021-6-25
+ */
+@Data
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
+public class ProfitSharingReturnRequest implements Serializable {
+  private static final long serialVersionUID = -2175582517588397426L;
+
+  /**
+   * <pre>
+   * 字段名:微信分账单号
+   * 是否必填:是
+   * 描述:微信分账单号,微信系统返回的唯一标识。
+   * </pre>
+   */
+  @SerializedName("order_id")
+  private String orderId;
+
+  /**
+   * <pre>
+   * 字段名:商户分账单号
+   * 是否必填:是
+   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
+   * </pre>
+   */
+  @SerializedName("out_order_no")
+  private String outOrderNo;
+
+  /**
+   * <pre>
+   * 字段名:商户回退单号
+   * 是否必填:是
+   * 描述:此回退单号是商户在自己后台生成的一个新的回退单号,在商户后台唯一
+   * </pre>
+   */
+  @SerializedName("out_return_no")
+  private String outReturnNo;
+
+  /**
+   * <pre>
+   * 字段名:回退商户号
+   * 是否必填:是
+   * 描述:分账回退的出资商户,只能对原分账请求中成功分给商户接收方进行回退
+   * </pre>
+   */
+  @SerializedName("return_mchid")
+  private String returnMchid;
+
+  /**
+   * <pre>
+   * 字段名:回退金额
+   * 是否必填:是
+   * 描述:需要从分账接收方回退的金额,单位为分,只能为整数,不能超过原始分账单分出给该接收方的金额
+   * </pre>
+   */
+  private Long amount;
+
+  /**
+   * <pre>
+   * 字段名:回退描述
+   * 是否必填:是
+   * 描述: 分账回退的原因描述
+   * </pre>
+   */
+  private String description;
+}

+ 141 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReturnResult.java

@@ -0,0 +1,141 @@
+package com.github.binarywang.wxpay.bean.profitsharingV3;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 微信V3接口
+ * 请求分账回退API返回实体
+ *
+ * @author pg
+ * @date 2021-6-25
+ */
+@Data
+public class ProfitSharingReturnResult implements Serializable {
+  private static final long serialVersionUID = -2175582517588397426L;
+
+  /**
+   * <pre>
+   * 字段名:微信分账单号
+   * 是否必填:是
+   * 描述:微信分账单号,微信系统返回的唯一标识。
+   * </pre>
+   */
+  @SerializedName("order_id")
+  private String orderId;
+
+  /**
+   * <pre>
+   * 字段名:商户分账单号
+   * 是否必填:是
+   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
+   * </pre>
+   */
+  @SerializedName("out_order_no")
+  private String outOrderNo;
+
+  /**
+   * <pre>
+   * 字段名:商户回退单号
+   * 是否必填:是
+   * 描述:此回退单号是商户在自己后台生成的一个新的回退单号,在商户后台唯一
+   * </pre>
+   */
+  @SerializedName("out_return_no")
+  private String outReturnNo;
+
+  /**
+   * <pre>
+   * 字段名:微信回退单号
+   * 是否必填:是
+   * 描述:微信分账回退单号,微信系统返回的唯一标识
+   * </pre>
+   */
+  @SerializedName("return_id")
+  private String returnId;
+
+  /**
+   * <pre>
+   * 字段名:回退商户号
+   * 是否必填:是
+   * 描述:分账回退的出资商户,只能对原分账请求中成功分给商户接收方进行回退
+   * </pre>
+   */
+  @SerializedName("return_mchid")
+  private String returnMchid;
+
+  /**
+   * <pre>
+   * 字段名:回退金额
+   * 是否必填:是
+   * 描述:需要从分账接收方回退的金额,单位为分,只能为整数,不能超过原始分账单分出给该接收方的金额
+   * </pre>
+   */
+  private Long amount;
+
+  /**
+   * <pre>
+   * 字段名:回退描述
+   * 是否必填:是
+   * 描述: 分账回退的原因描述
+   * </pre>
+   */
+  private String description;
+
+  /**
+   * <pre>
+   * 字段名:分账结果
+   * 是否必填:是
+   * 描述:
+   * 如果请求返回为处理中,则商户可以通过调用回退结果查询接口获取请求的最终处理结果。
+   * 如果查询到回退结果在处理中,请勿变更商户回退单号,使用相同的参数再次发起分账回退,否则会出现资金风险。
+   * 在处理中状态的回退单如果5天没有成功,会因为超时被设置为已失败。
+   * PROCESSING:处理中
+   * SUCCESS:已成功
+   * FAILED:已失败
+   * </pre>
+   */
+  @SerializedName("result")
+  private String result;
+
+  /**
+   * <pre>
+   * 字段名:失败原因
+   * 是否必填:是
+   * 描述:失败原因。包含以下枚举值:
+   * ACCOUNT_ABNORMAL : 分账接收方账户异常
+   * TIME_OUT_CLOSED : 超时关单
+   * </pre>
+   */
+  @SerializedName("fail_reason")
+  private String failReason;
+
+  /**
+   * <pre>
+   * 字段名:分账回退创建时间
+   * 是否必填:是
+   * 描述:遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,
+   * YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,
+   * HH:mm:ss.sss表示时分秒毫秒,
+   * TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+   * 例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
+   * </pre>
+   */
+  @SerializedName("create_time")
+  private String createTime;
+  /**
+   * <pre>
+   * 字段名:分账回退完成时间
+   * 是否必填:是
+   * 描述:遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,
+   * YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,
+   * HH:mm:ss.sss表示时分秒毫秒,
+   * TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+   * 例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
+   * </pre>
+   */
+  @SerializedName("finish_time")
+  private String finishTime;
+}

+ 54 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnfreezeRequest.java

@@ -0,0 +1,54 @@
+package com.github.binarywang.wxpay.bean.profitsharingV3;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 微信V3接口
+ * 解冻剩余资金API请求实体
+ *
+ * @author pg
+ * @date 2021-6-25
+ */
+@Data
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
+public class ProfitSharingUnfreezeRequest implements Serializable {
+  private static final long serialVersionUID = 6835471990040104843L;
+
+  /**
+   * <pre>
+   * 字段名:微信订单号
+   * 是否必填:是
+   * 描述:微信支付订单号
+   * </pre>
+   */
+  @SerializedName("transaction_id")
+  private String transactionId;
+
+  /**
+   * <pre>
+   * 字段名:商户分账单号
+   * 是否必填:是
+   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
+   * </pre>
+   */
+  @SerializedName("out_order_no")
+  private String outOrderNo;
+
+  /**
+   * <pre>
+   * 字段名:分账描述
+   * 是否必填:是
+   * 描述: 分账的原因描述,分账账单中需要体现
+   * </pre>
+   */
+  @SerializedName("description")
+  private String description;
+}

+ 162 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnfreezeResult.java

@@ -0,0 +1,162 @@
+package com.github.binarywang.wxpay.bean.profitsharingV3;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 微信V3接口
+ * 解冻剩余资金API返回实体
+ *
+ * @author pg
+ * @date 2021-6-25
+ */
+@Data
+public class ProfitSharingUnfreezeResult implements Serializable {
+  private static final long serialVersionUID = 5053171678880645337L;
+
+  /**
+   * <pre>
+   * 字段名:微信订单号
+   * 是否必填:是
+   * 描述:微信支付订单号
+   * </pre>
+   */
+  @SerializedName("transaction_id")
+  private String transactionId;
+
+  /**
+   * <pre>
+   * 字段名:商户分账单号
+   * 是否必填:是
+   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
+   * </pre>
+   */
+  @SerializedName("out_order_no")
+  private String outOrderNo;
+
+  /**
+   * <pre>
+   * 字段名:微信分账单号
+   * 是否必填:是
+   * 描述:微信分账单号,微信系统返回的唯一标识。
+   * </pre>
+   */
+  @SerializedName("order_id")
+  private String orderId;
+
+
+  /**
+   * <pre>
+   * 字段名:分账单状态
+   * 是否必填:是
+   * 描述:分账单状态(每个接收方的分账结果请查看receivers中的result字段),枚举值:
+   * 1、PROCESSING:处理中
+   * 2、FINISHED:分账完成
+   * </pre>
+   */
+  @SerializedName("state")
+  private String state;
+
+  @Data
+  public static class Receiver implements Serializable {
+    private static final long serialVersionUID = 4240983048700956806L;
+    /**
+     * <pre>
+     * 字段名:分账接收方类型
+     * 是否必填:是
+     * 描述:
+     * 1、MERCHANT_ID:商户号
+     * 2、PERSONAL_OPENID:个人openid(由父商户APPID转换得到)
+     * </pre>
+     */
+    @SerializedName("type")
+    private String type;
+
+    /**
+     * <pre>
+     * 字段名:分账接收方帐号
+     * 是否必填:是
+     * 描述:
+     * 1、分账接收方类型为MERCHANT_ID时,分账接收方账号为商户号
+     * 2、分账接收方类型为PERSONAL_OPENID时,分账接收方账号为个人openid
+     * </pre>
+     */
+    @SerializedName("account")
+    private String account;
+
+    /**
+     * <pre>
+     * 字段名:分账金额
+     * 是否必填:是
+     * 描述: 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
+     * </pre>
+     */
+    @SerializedName("amount")
+    private Long amount;
+
+    /**
+     * <pre>
+     * 字段名:分账描述
+     * 是否必填:是
+     * 描述: 分账的原因描述,分账账单中需要体现
+     * </pre>
+     */
+    @SerializedName("description")
+    private String description;
+
+    /**
+     * <pre>
+     * 字段名:分账结果
+     * 是否必填:是
+     * 描述:
+     * 1、PENDING:待分账
+     * 2、SUCCESS:分账成功
+     * 3、CLOSED:已关闭
+     * </pre>
+     */
+    @SerializedName("result")
+    private String result;
+
+    /**
+     * <pre>
+     * 字段名:分账失败原因
+     * 是否必填:是
+     * 描述:枚举值:
+     * 1、PENDING:待分账
+     * 2、SUCCESS:分账成功
+     * 3、CLOSED:已关闭
+     * </pre>
+     */
+    @SerializedName("fail_reason")
+    private String failReason;
+
+    /**
+     * <pre>
+     * 字段名:分账创建时间
+     * 是否必填:是
+     * 描述:遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,
+     * YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,
+     * HH:mm:ss.sss表示时分秒毫秒,
+     * TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+     * 例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
+     * </pre>
+     */
+    @SerializedName("create_time")
+    private String createTime;
+    /**
+     * <pre>
+     * 字段名:分账完成时间
+     * 是否必填:是
+     * 描述:遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,
+     * YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,
+     * HH:mm:ss.sss表示时分秒毫秒,
+     * TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+     * 例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
+     * </pre>
+     */
+    @SerializedName("finish_time")
+    private String finishTime;
+  }
+}

+ 39 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnsplitResult.java

@@ -0,0 +1,39 @@
+package com.github.binarywang.wxpay.bean.profitsharingV3;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 微信V3接口
+ * 查询剩余待分金额API返回实体
+ *
+ * @author pg
+ * @date 2021-6-25
+ */
+@Data
+public class ProfitSharingUnsplitResult implements Serializable {
+
+  private static final long serialVersionUID = -7025255772409082288L;
+  /**
+   * <pre>
+   * 字段名:微信订单号
+   * 是否必填:是
+   * 描述:微信支付订单号
+   * </pre>
+   */
+  @SerializedName("transaction_id")
+  private String transactionId;
+
+  /**
+   * <pre>
+   * 字段名:订单剩余待分金额
+   * 是否必填:是
+   * 描述:订单剩余待分金额,整数,单元为分
+   * </pre>
+   */
+  @SerializedName("unsplit_amount")
+  private String unsplitAmount;
+
+}

+ 164 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingV3Service.java

@@ -0,0 +1,164 @@
+package com.github.binarywang.wxpay.service;
+
+import com.github.binarywang.wxpay.bean.profitsharingV3.*;
+import com.github.binarywang.wxpay.exception.WxPayException;
+
+/**
+ * 微信支付V3-资金应用-分账
+ *
+ * @author pg 2021-6-23
+ * @date 2021-6-23
+ */
+public interface ProfitSharingV3Service {
+  /**
+   * <pre>
+   * 请求分账API
+   *
+   * 微信订单支付成功后,商户发起分账请求,将结算后的资金分到分账接收方
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_1.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/orders
+   *
+   * 注意:
+   * 对同一笔订单最多能发起20次分账请求,每次请求最多分给50个接收方
+   * 此接口采用异步处理模式,即在接收到商户请求后,优先受理请求再异步处理,最终的分账结果可以通过查询分账接口获取
+   * </pre>
+   *
+   * @param request {@link ProfitSharingRequest} 针对某一笔支付订单的分账方法
+   * @return {@link ProfitSharingResult} 微信返回的分账结果
+   * @throws WxPayException the wx pay exception
+   * @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_1.shtml">微信文档</a>
+   */
+  ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException;
+
+  /**
+   * <pre>
+   * 查询分账结果API
+   *
+   * 发起分账请求后,可调用此接口查询分账结果
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_2.shtml
+   * 接口链接:https://api.mch.weixin.qq.com/v3/profitsharing/orders/{out_order_no}
+   *
+   * 注意:
+   * • 发起解冻剩余资金请求后,可调用此接口查询解冻剩余资金的结果
+   * </pre>
+   *
+   * @param outOrderNo    商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@ 。
+   * @param transactionId 微信支付订单号
+   * @return {@link ProfitSharingResult} 微信返回的分账结果
+   * @throws WxPayException the wx pay exception
+   * @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_2.shtml">微信文档</a>
+   */
+  ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId) throws WxPayException;
+
+  /**
+   * <pre>
+   * 请求分账回退API
+   *
+   * 如果订单已经分账,在退款时,可以先调此接口,将已分账的资金从分账接收方的账户回退给分账方,再发起退款
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_3.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/return-orders
+   *
+   * 注意:
+   * • 分账回退以原分账单为依据,支持多次回退,申请回退总金额不能超过原分账单分给该接收方的金额
+   * • 此接口采用同步处理模式,即在接收到商户请求后,会实时返回处理结果
+   * • 对同一笔分账单最多能发起20次分账回退请求
+   * • 退款和分账回退没有耦合,分账回退可以先于退款请求,也可以后于退款请求
+   * • 此功能需要接收方在商户平台-交易中心-分账-分账接收设置下,开启同意分账回退后,才能使用
+   * </pre>
+   *
+   * @param request {@link ProfitSharingReturnRequest} 针对某一笔支付订单的分账方法
+   * @return {@link ProfitSharingReturnResult} 微信返回的分账回退结果
+   * @throws WxPayException the wx pay exception
+   * @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_3.shtml">微信文档</a>
+   */
+  ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest request) throws WxPayException;
+
+  /**
+   * <pre>
+   * 查询分账回退结果API
+   *
+   * 商户需要核实回退结果,可调用此接口查询回退结果
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_4.shtml
+   * 接口链接:https://api.mch.weixin.qq.com/v3/profitsharing/return-orders/{out_return_no}
+   *
+   * 注意:
+   * • 如果分账回退接口返回状态为处理中,可调用此接口查询回退结果
+   * </pre>
+   *
+   * @param outOrderNo  原发起分账请求时使用的商户系统内部的分账单号
+   * @param outReturnNo 调用回退接口提供的商户系统内部的回退单号
+   * @return {@link ProfitSharingReturnResult} 微信返回的分账回退结果
+   * @throws WxPayException the wx pay exception
+   * @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_4.shtml">微信文档</a>
+   */
+  ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo) throws WxPayException;
+
+  /**
+   * <pre>
+   * 解冻剩余资金API
+   *
+   * 不需要进行分账的订单,可直接调用本接口将订单的金额全部解冻给特约商户
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_5.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/orders/unfreeze
+   *
+   * 注意:
+   * • 调用分账接口后,需要解冻剩余资金时,调用本接口将剩余的分账金额全部解冻给特约商户
+   * • 此接口采用异步处理模式,即在接收到商户请求后,优先受理请求再异步处理,最终的分账结果可以通过查询分账接口获取
+   * </pre>
+   *
+   * @param request 解冻剩余资金请求实体 {@link ProfitSharingUnfreezeRequest}
+   * @return {@link ProfitSharingReturnResult} 微信返回的解冻剩余资金结果
+   * @throws WxPayException the wx pay exception
+   * @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_5.shtml">微信文档</a>
+   */
+  ProfitSharingUnfreezeResult profitSharingUnfreeze(ProfitSharingUnfreezeRequest request) throws WxPayException;
+
+  /**
+   * <pre>
+   * 查询剩余待分金额API
+   *
+   * 可调用此接口查询订单剩余待分金额
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_6.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/transactions/{transaction_id}/amounts
+   * </pre>
+   *
+   * @param transactionId 微信订单号,微信支付订单号
+   * @return {@link ProfitSharingUnsplitResult} 微信返回的订单剩余待分金额结果
+   * @throws WxPayException the wx pay exception
+   * @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_6.shtml">微信文档</a>
+   */
+  ProfitSharingUnsplitResult getProfitSharingUnsplitAmount(String transactionId) throws WxPayException;
+
+  /**
+   * <pre>
+   * 添加分账接收方API
+   *
+   * 商户发起添加分账接收方请求,建立分账接收方列表。后续可通过发起分账请求,将分账方商户结算后的资金,分到该分账接收方
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_8.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/receivers/add
+   * </pre>
+   *
+   * @param receiver 分账接收方实体 {@link ProfitSharingReceiver}
+   * @return {@link ProfitSharingReceiver} 微信返回的分账接收方结果
+   * @throws WxPayException the wx pay exception
+   * @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_8.shtml">微信文档</a>
+   */
+  ProfitSharingReceiver addProfitSharingReceiver(ProfitSharingReceiver receiver) throws WxPayException;
+
+  /**
+   * <pre>
+   * 删除分账接收方API
+   *
+   * 商户发起删除分账接收方请求。删除后,不支持将分账方商户结算后的资金,分到该分账接收方
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_9.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/receivers/delete
+   * </pre>
+   *
+   * @param receiver 分账接收方实体 {@link ProfitSharingReceiver}
+   * @return {@link ProfitSharingReceiver} 微信返回的删除的分账接收方结果
+   * @throws WxPayException the wx pay exception
+   * @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_9.shtml">微信文档</a>
+   */
+  ProfitSharingReceiver deleteProfitSharingReceiver(ProfitSharingReceiver receiver) throws WxPayException;
+
+}

+ 9 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java

@@ -189,11 +189,20 @@ public interface WxPayService {
 
   /**
    * 获取分账服务类.
+   * <p>
+   *   V3接口 {@link WxPayService#getProfitSharingV3Service()}
+   * </p>
    *
    * @return the ent pay service
    */
   ProfitSharingService getProfitSharingService();
 
+  /**
+   * 获取V3分账服务类.
+   *
+   * @return the ent pay service
+   */
+  ProfitSharingV3Service getProfitSharingV3Service();
 
   /**
    * 获取支付分服务类.

+ 6 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java

@@ -64,6 +64,7 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
 
   private EntPayService entPayService = new EntPayServiceImpl(this);
   private final ProfitSharingService profitSharingService = new ProfitSharingServiceImpl(this);
+  private final ProfitSharingV3Service profitSharingV3Service = new ProfitSharingV3ServiceImpl(this);
   private final RedpackService redpackService = new RedpackServiceImpl(this);
   private final PayScoreService payScoreService = new PayScoreServiceImpl(this);
   private final EcommerceService ecommerceService = new EcommerceServiceImpl(this);
@@ -86,6 +87,11 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
   }
 
   @Override
+  public ProfitSharingV3Service getProfitSharingV3Service() {
+    return profitSharingV3Service;
+  }
+
+  @Override
   public PayScoreService getPayScoreService() {
     return payScoreService;
   }

+ 85 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingV3ServiceImpl.java

@@ -0,0 +1,85 @@
+package com.github.binarywang.wxpay.service.impl;
+
+import com.github.binarywang.wxpay.bean.profitsharingV3.*;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import com.github.binarywang.wxpay.service.ProfitSharingV3Service;
+import com.github.binarywang.wxpay.service.WxPayService;
+import com.github.binarywang.wxpay.v3.util.RsaCryptoUtil;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 微信支付V3-资金应用-分账Service
+ *
+ * @author pg 2021-6-23
+ * @version 1.0
+ */
+@Slf4j
+@RequiredArgsConstructor
+public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service {
+  private static final Gson GSON = new GsonBuilder().create();
+  private final WxPayService payService;
+
+  @Override
+  public ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException {
+    String url = String.format("%s/v3/profitsharing/orders", this.payService.getPayBaseUrl());
+    RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate());
+    String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
+    return GSON.fromJson(result, ProfitSharingResult.class);
+  }
+
+  @Override
+  public ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId) throws WxPayException {
+    String url = String.format("%s/v3/profitsharing/orders/%s?transaction_id=%s", this.payService.getPayBaseUrl(), outOrderNo, transactionId);
+    String result = this.payService.getV3(url);
+    return GSON.fromJson(result, ProfitSharingResult.class);
+  }
+
+  @Override
+  public ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest request) throws WxPayException {
+    String url = String.format("%s/v3/profitsharing/return-orders", this.payService.getPayBaseUrl());
+    RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate());
+    String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
+    return GSON.fromJson(result, ProfitSharingReturnResult.class);
+  }
+
+  @Override
+  public ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo) throws WxPayException {
+    String url = String.format("%s/v3/profitsharing/return-orders/%s?out_order_no=%s", this.payService.getPayBaseUrl(), outReturnNo, outOrderNo);
+    String result = this.payService.getV3(url);
+    return GSON.fromJson(result, ProfitSharingReturnResult.class);
+  }
+
+  @Override
+  public ProfitSharingUnfreezeResult profitSharingUnfreeze(ProfitSharingUnfreezeRequest request) throws WxPayException {
+    String url = String.format("%s/v3/profitsharing/orders/unfreeze", this.payService.getPayBaseUrl());
+    RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate());
+    String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
+    return GSON.fromJson(result, ProfitSharingUnfreezeResult.class);
+  }
+
+  @Override
+  public ProfitSharingUnsplitResult getProfitSharingUnsplitAmount(String transactionId) throws WxPayException {
+    String url = String.format("%s/v3/profitsharing/transactions/%s/amounts", this.payService.getPayBaseUrl(), transactionId);
+    String result = this.payService.getV3(url);
+    return GSON.fromJson(result, ProfitSharingUnsplitResult.class);
+  }
+
+  @Override
+  public ProfitSharingReceiver addProfitSharingReceiver(ProfitSharingReceiver request) throws WxPayException {
+    String url = String.format("%s/v3/profitsharing/receivers/add", this.payService.getPayBaseUrl());
+    RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate());
+    String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
+    return GSON.fromJson(result, ProfitSharingReceiver.class);
+  }
+
+  @Override
+  public ProfitSharingReceiver deleteProfitSharingReceiver(ProfitSharingReceiver request) throws WxPayException {
+    String url = String.format("%s/v3/profitsharing/receivers/delete", this.payService.getPayBaseUrl());
+    RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate());
+    String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
+    return GSON.fromJson(result, ProfitSharingReceiver.class);
+  }
+}