diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReceiver.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReceiver.java new file mode 100644 index 000000000..cbdeeba28 --- /dev/null +++ b/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; + + /** + *
+   * 字段名:应用ID
+   * 是否必填:是
+   * 描述:微信分配的商户appid
+   * 
+ */ + @SerializedName("appid") + private String appid; + + /** + *
+   * 字段名:分账接收方类型
+   * 是否必填:是
+   * 描述:
+   * 1、MERCHANT_ID:商户号
+   * 2、PERSONAL_OPENID:个人openid(由父商户APPID转换得到)
+   * 
+ */ + @SerializedName("type") + private String type; + + /** + *
+   * 字段名:分账接收方帐号
+   * 是否必填:是
+   * 描述:
+   * 1、分账接收方类型为MERCHANT_ID时,分账接收方账号为商户号
+   * 2、分账接收方类型为PERSONAL_OPENID时,分账接收方账号为个人openid
+   * 
+ */ + @SerializedName("account") + private String account; + + /** + *
+   * 字段名:分账个人接收方姓名
+   * 是否必填:否
+   * 描述:
+   * 可选项,在接收方类型为个人的时可选填,若有值,会检查与 name 是否实名匹配,不匹配会拒绝分账请求
+   * 1、分账接收方类型是PERSONAL_OPENID,是个人姓名的密文(选传,传则校验) 此字段的加密方法详见:敏感信息加密说明
+   * 2、使用微信支付平台证书中的公钥
+   * 3、使用RSAES-OAEP算法进行加密
+   * 4、将请求中HTTP头部的Wechatpay-Serial设置为证书序列号
+   * 
+ */ + @SerializedName("name") + @SpecEncrypt + private String name; + + /** + *
+   * 字段名:与分账方的关系类型
+   * 是否必填:是
+   * 描述:子商户与接收方的关系。 本字段值为枚举:
+   * STORE:门店
+   * STAFF:员工
+   * STORE_OWNER:店主
+   * PARTNER:合作伙伴
+   * HEADQUARTER:总部
+   * BRAND:品牌方
+   * DISTRIBUTOR:分销商
+   * USER:用户
+   * SUPPLIER: 供应商
+   * CUSTOM:自定义
+   * 
+ */ + @SerializedName("relation_type") + private String relationType; + + /** + *
+   * 字段名:自定义的分账关系
+   * 是否必填:是
+   * 描述:子商户与接收方具体的关系,本字段最多10个字。
+   * 当字段relationType的值为CUSTOM时,本字段必填;
+   * 当字段relationType的值不为CUSTOM时,本字段无需填写。
+   * 
+ */ + @SerializedName("custom_relation") + private String customRelation; + + /** + *
+   * 字段名:分账描述
+   * 是否必填:是
+   * 描述: 分账的原因描述,分账账单中需要体现
+   * 
+ */ + private String description; + /** + *
+   * 字段名:分账金额
+   * 是否必填:是
+   * 描述: 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
+   * 
+ */ + 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; + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingRequest.java new file mode 100644 index 000000000..78122bfbf --- /dev/null +++ b/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; + + /** + *
+   * 字段名:应用ID
+   * 是否必填:是
+   * 描述:微信分配的商户appid
+   * 
+ */ + @SerializedName("appid") + private String appid; + + /** + *
+   * 字段名:微信订单号
+   * 是否必填:是
+   * 描述:微信支付订单号
+   * 
+ */ + @SerializedName("transaction_id") + private String transactionId; + + /** + *
+   * 字段名:商户分账单号
+   * 是否必填:是
+   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
+   * 
+ */ + @SerializedName("out_order_no") + private String outOrderNo; + + /** + *
+   * 字段名:分账接收方列表
+   * 是否必填:是
+   * 描述:分账接收方列表,可以设置出资商户作为分账接受方,最多可有50个分账接收方
+   * 
+ */ + @SerializedName("receivers") + private List receivers; + + /** + *
+   * 字段名:是否解冻剩余未分资金
+   * 是否必填:是
+   * 描述:
+   * 1、如果为true,该笔订单剩余未分账的金额会解冻回分账方商户;
+   * 2、如果为false,该笔订单剩余未分账的金额不会解冻回分账方商户,可以对该笔订单再次进行分账。
+   * 
+ */ + @SerializedName("unfreeze_unsplit") + private boolean unfreezeUnsplit; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingResult.java new file mode 100644 index 000000000..6e0626f65 --- /dev/null +++ b/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; + + /** + *
+   * 字段名:微信订单号
+   * 是否必填:是
+   * 描述:微信支付订单号
+   * 
+ */ + @SerializedName("transaction_id") + private String transactionId; + + /** + *
+   * 字段名:商户分账单号
+   * 是否必填:是
+   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
+   * 
+ */ + @SerializedName("out_order_no") + private String outOrderNo; + + /** + *
+   * 字段名:微信分账单号,
+   * 是否必填:是
+   * 描述:微信系统返回的唯一标识.
+   * 
+ */ + @SerializedName("order_id") + private String orderId; + + /** + *
+   * 字段名:分账单状态
+   * 是否必填:是
+   * 描述:分账单状态(每个接收方的分账结果请查看receivers中的result字段):
+   * 1、PROCESSING:处理中
+   * 2、FINISHED:分账完成.
+   * 
+ */ + @SerializedName("state") + private String state; + + /** + * 分账接收方列表 + */ + @SerializedName("receivers") + private List receivers; + + @Data + public static class Receiver implements Serializable { + private static final long serialVersionUID = 4240983048700956806L; + + /** + *
+     * 字段名:分账接收方类型
+     * 是否必填:是
+     * 描述:
+     * 1、MERCHANT_ID:商户号
+     * 2、PERSONAL_OPENID:个人openid(由父商户APPID转换得到)
+     * 
+ */ + @SerializedName("type") + private String type; + + /** + *
+     * 字段名:分账接收方帐号
+     * 是否必填:是
+     * 描述:
+     * 1、分账接收方类型为MERCHANT_ID时,分账接收方账号为商户号
+     * 2、分账接收方类型为PERSONAL_OPENID时,分账接收方账号为个人openid
+     * 
+ */ + @SerializedName("account") + private String account; + + /** + *
+     * 字段名:分账金额
+     * 是否必填:是
+     * 描述: 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
+     * 
+ */ + @SerializedName("amount") + private Long amount; + + /** + *
+     * 字段名:分账描述
+     * 是否必填:是
+     * 描述: 分账的原因描述,分账账单中需要体现
+     * 
+ */ + @SerializedName("description") + private String description; + + /** + *
+     * 字段名:分账结果
+     * 是否必填:是
+     * 描述:
+     * 1、PENDING:待分账
+     * 2、SUCCESS:分账成功
+     * 3、CLOSED:已关闭
+     * 
+ */ + @SerializedName("result") + private String result; + + /** + *
+     * 字段名:分账失败原因
+     * 是否必填:是
+     * 描述:包含以下枚举值:
+     * 1、ACCOUNT_ABNORMAL : 分账接收账户异常
+     * 2、NO_RELATION : 分账关系已解除
+     * 3、RECEIVER_HIGH_RISK : 高风险接收方
+     * 4、RECEIVER_REAL_NAME_NOT_VERIFIED : 接收方未实名
+     * 5、NO_AUTH : 分账权限已解除
+     * 
+ */ + @SerializedName("fail_reason") + private String failReason; + + /** + *
+     * 字段名:分账创建时间
+     * 是否必填:是
+     * 描述:遵循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秒。
+     * 
+ */ + @SerializedName("create_time") + private String createTime; + /** + *
+     * 字段名:分账完成时间
+     * 是否必填:是
+     * 描述:遵循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秒。
+     * 
+ */ + @SerializedName("finish_time") + private String finishTime; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReturnRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReturnRequest.java new file mode 100644 index 000000000..31e26775f --- /dev/null +++ b/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; + + /** + *
+   * 字段名:微信分账单号
+   * 是否必填:是
+   * 描述:微信分账单号,微信系统返回的唯一标识。
+   * 
+ */ + @SerializedName("order_id") + private String orderId; + + /** + *
+   * 字段名:商户分账单号
+   * 是否必填:是
+   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
+   * 
+ */ + @SerializedName("out_order_no") + private String outOrderNo; + + /** + *
+   * 字段名:商户回退单号
+   * 是否必填:是
+   * 描述:此回退单号是商户在自己后台生成的一个新的回退单号,在商户后台唯一
+   * 
+ */ + @SerializedName("out_return_no") + private String outReturnNo; + + /** + *
+   * 字段名:回退商户号
+   * 是否必填:是
+   * 描述:分账回退的出资商户,只能对原分账请求中成功分给商户接收方进行回退
+   * 
+ */ + @SerializedName("return_mchid") + private String returnMchid; + + /** + *
+   * 字段名:回退金额
+   * 是否必填:是
+   * 描述:需要从分账接收方回退的金额,单位为分,只能为整数,不能超过原始分账单分出给该接收方的金额
+   * 
+ */ + private Long amount; + + /** + *
+   * 字段名:回退描述
+   * 是否必填:是
+   * 描述: 分账回退的原因描述
+   * 
+ */ + private String description; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReturnResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingReturnResult.java new file mode 100644 index 000000000..6e08a9a41 --- /dev/null +++ b/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; + + /** + *
+   * 字段名:微信分账单号
+   * 是否必填:是
+   * 描述:微信分账单号,微信系统返回的唯一标识。
+   * 
+ */ + @SerializedName("order_id") + private String orderId; + + /** + *
+   * 字段名:商户分账单号
+   * 是否必填:是
+   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
+   * 
+ */ + @SerializedName("out_order_no") + private String outOrderNo; + + /** + *
+   * 字段名:商户回退单号
+   * 是否必填:是
+   * 描述:此回退单号是商户在自己后台生成的一个新的回退单号,在商户后台唯一
+   * 
+ */ + @SerializedName("out_return_no") + private String outReturnNo; + + /** + *
+   * 字段名:微信回退单号
+   * 是否必填:是
+   * 描述:微信分账回退单号,微信系统返回的唯一标识
+   * 
+ */ + @SerializedName("return_id") + private String returnId; + + /** + *
+   * 字段名:回退商户号
+   * 是否必填:是
+   * 描述:分账回退的出资商户,只能对原分账请求中成功分给商户接收方进行回退
+   * 
+ */ + @SerializedName("return_mchid") + private String returnMchid; + + /** + *
+   * 字段名:回退金额
+   * 是否必填:是
+   * 描述:需要从分账接收方回退的金额,单位为分,只能为整数,不能超过原始分账单分出给该接收方的金额
+   * 
+ */ + private Long amount; + + /** + *
+   * 字段名:回退描述
+   * 是否必填:是
+   * 描述: 分账回退的原因描述
+   * 
+ */ + private String description; + + /** + *
+   * 字段名:分账结果
+   * 是否必填:是
+   * 描述:
+   * 如果请求返回为处理中,则商户可以通过调用回退结果查询接口获取请求的最终处理结果。
+   * 如果查询到回退结果在处理中,请勿变更商户回退单号,使用相同的参数再次发起分账回退,否则会出现资金风险。
+   * 在处理中状态的回退单如果5天没有成功,会因为超时被设置为已失败。
+   * PROCESSING:处理中
+   * SUCCESS:已成功
+   * FAILED:已失败
+   * 
+ */ + @SerializedName("result") + private String result; + + /** + *
+   * 字段名:失败原因
+   * 是否必填:是
+   * 描述:失败原因。包含以下枚举值:
+   * ACCOUNT_ABNORMAL : 分账接收方账户异常
+   * TIME_OUT_CLOSED : 超时关单
+   * 
+ */ + @SerializedName("fail_reason") + private String failReason; + + /** + *
+   * 字段名:分账回退创建时间
+   * 是否必填:是
+   * 描述:遵循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秒。
+   * 
+ */ + @SerializedName("create_time") + private String createTime; + /** + *
+   * 字段名:分账回退完成时间
+   * 是否必填:是
+   * 描述:遵循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秒。
+   * 
+ */ + @SerializedName("finish_time") + private String finishTime; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnfreezeRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnfreezeRequest.java new file mode 100644 index 000000000..c79b9b638 --- /dev/null +++ b/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; + + /** + *
+   * 字段名:微信订单号
+   * 是否必填:是
+   * 描述:微信支付订单号
+   * 
+ */ + @SerializedName("transaction_id") + private String transactionId; + + /** + *
+   * 字段名:商户分账单号
+   * 是否必填:是
+   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
+   * 
+ */ + @SerializedName("out_order_no") + private String outOrderNo; + + /** + *
+   * 字段名:分账描述
+   * 是否必填:是
+   * 描述: 分账的原因描述,分账账单中需要体现
+   * 
+ */ + @SerializedName("description") + private String description; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnfreezeResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnfreezeResult.java new file mode 100644 index 000000000..0e67eee4c --- /dev/null +++ b/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; + + /** + *
+   * 字段名:微信订单号
+   * 是否必填:是
+   * 描述:微信支付订单号
+   * 
+ */ + @SerializedName("transaction_id") + private String transactionId; + + /** + *
+   * 字段名:商户分账单号
+   * 是否必填:是
+   * 描述:商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
+   * 
+ */ + @SerializedName("out_order_no") + private String outOrderNo; + + /** + *
+   * 字段名:微信分账单号
+   * 是否必填:是
+   * 描述:微信分账单号,微信系统返回的唯一标识。
+   * 
+ */ + @SerializedName("order_id") + private String orderId; + + + /** + *
+   * 字段名:分账单状态
+   * 是否必填:是
+   * 描述:分账单状态(每个接收方的分账结果请查看receivers中的result字段),枚举值:
+   * 1、PROCESSING:处理中
+   * 2、FINISHED:分账完成
+   * 
+ */ + @SerializedName("state") + private String state; + + @Data + public static class Receiver implements Serializable { + private static final long serialVersionUID = 4240983048700956806L; + /** + *
+     * 字段名:分账接收方类型
+     * 是否必填:是
+     * 描述:
+     * 1、MERCHANT_ID:商户号
+     * 2、PERSONAL_OPENID:个人openid(由父商户APPID转换得到)
+     * 
+ */ + @SerializedName("type") + private String type; + + /** + *
+     * 字段名:分账接收方帐号
+     * 是否必填:是
+     * 描述:
+     * 1、分账接收方类型为MERCHANT_ID时,分账接收方账号为商户号
+     * 2、分账接收方类型为PERSONAL_OPENID时,分账接收方账号为个人openid
+     * 
+ */ + @SerializedName("account") + private String account; + + /** + *
+     * 字段名:分账金额
+     * 是否必填:是
+     * 描述: 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
+     * 
+ */ + @SerializedName("amount") + private Long amount; + + /** + *
+     * 字段名:分账描述
+     * 是否必填:是
+     * 描述: 分账的原因描述,分账账单中需要体现
+     * 
+ */ + @SerializedName("description") + private String description; + + /** + *
+     * 字段名:分账结果
+     * 是否必填:是
+     * 描述:
+     * 1、PENDING:待分账
+     * 2、SUCCESS:分账成功
+     * 3、CLOSED:已关闭
+     * 
+ */ + @SerializedName("result") + private String result; + + /** + *
+     * 字段名:分账失败原因
+     * 是否必填:是
+     * 描述:枚举值:
+     * 1、PENDING:待分账
+     * 2、SUCCESS:分账成功
+     * 3、CLOSED:已关闭
+     * 
+ */ + @SerializedName("fail_reason") + private String failReason; + + /** + *
+     * 字段名:分账创建时间
+     * 是否必填:是
+     * 描述:遵循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秒。
+     * 
+ */ + @SerializedName("create_time") + private String createTime; + /** + *
+     * 字段名:分账完成时间
+     * 是否必填:是
+     * 描述:遵循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秒。
+     * 
+ */ + @SerializedName("finish_time") + private String finishTime; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnsplitResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingUnsplitResult.java new file mode 100644 index 000000000..2cec40d2b --- /dev/null +++ b/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; + /** + *
+   * 字段名:微信订单号
+   * 是否必填:是
+   * 描述:微信支付订单号
+   * 
+ */ + @SerializedName("transaction_id") + private String transactionId; + + /** + *
+   * 字段名:订单剩余待分金额
+   * 是否必填:是
+   * 描述:订单剩余待分金额,整数,单元为分
+   * 
+ */ + @SerializedName("unsplit_amount") + private String unsplitAmount; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingV3Service.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingV3Service.java new file mode 100644 index 000000000..fcb87063a --- /dev/null +++ b/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 { + /** + *
+   * 请求分账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个接收方
+   * 此接口采用异步处理模式,即在接收到商户请求后,优先受理请求再异步处理,最终的分账结果可以通过查询分账接口获取
+   * 
+ * + * @param request {@link ProfitSharingRequest} 针对某一笔支付订单的分账方法 + * @return {@link ProfitSharingResult} 微信返回的分账结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException; + + /** + *
+   * 查询分账结果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}
+   *
+   * 注意:
+   * • 发起解冻剩余资金请求后,可调用此接口查询解冻剩余资金的结果
+   * 
+ * + * @param outOrderNo 商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@ 。 + * @param transactionId 微信支付订单号 + * @return {@link ProfitSharingResult} 微信返回的分账结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId) throws WxPayException; + + /** + *
+   * 请求分账回退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次分账回退请求
+   * • 退款和分账回退没有耦合,分账回退可以先于退款请求,也可以后于退款请求
+   * • 此功能需要接收方在商户平台-交易中心-分账-分账接收设置下,开启同意分账回退后,才能使用
+   * 
+ * + * @param request {@link ProfitSharingReturnRequest} 针对某一笔支付订单的分账方法 + * @return {@link ProfitSharingReturnResult} 微信返回的分账回退结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest request) throws WxPayException; + + /** + *
+   * 查询分账回退结果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}
+   *
+   * 注意:
+   * • 如果分账回退接口返回状态为处理中,可调用此接口查询回退结果
+   * 
+ * + * @param outOrderNo 原发起分账请求时使用的商户系统内部的分账单号 + * @param outReturnNo 调用回退接口提供的商户系统内部的回退单号 + * @return {@link ProfitSharingReturnResult} 微信返回的分账回退结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo) throws WxPayException; + + /** + *
+   * 解冻剩余资金API
+   *
+   * 不需要进行分账的订单,可直接调用本接口将订单的金额全部解冻给特约商户
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_5.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/orders/unfreeze
+   *
+   * 注意:
+   * • 调用分账接口后,需要解冻剩余资金时,调用本接口将剩余的分账金额全部解冻给特约商户
+   * • 此接口采用异步处理模式,即在接收到商户请求后,优先受理请求再异步处理,最终的分账结果可以通过查询分账接口获取
+   * 
+ * + * @param request 解冻剩余资金请求实体 {@link ProfitSharingUnfreezeRequest} + * @return {@link ProfitSharingReturnResult} 微信返回的解冻剩余资金结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingUnfreezeResult profitSharingUnfreeze(ProfitSharingUnfreezeRequest request) throws WxPayException; + + /** + *
+   * 查询剩余待分金额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
+   * 
+ * + * @param transactionId 微信订单号,微信支付订单号 + * @return {@link ProfitSharingUnsplitResult} 微信返回的订单剩余待分金额结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingUnsplitResult getProfitSharingUnsplitAmount(String transactionId) throws WxPayException; + + /** + *
+   * 添加分账接收方API
+   *
+   * 商户发起添加分账接收方请求,建立分账接收方列表。后续可通过发起分账请求,将分账方商户结算后的资金,分到该分账接收方
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_8.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/receivers/add
+   * 
+ * + * @param receiver 分账接收方实体 {@link ProfitSharingReceiver} + * @return {@link ProfitSharingReceiver} 微信返回的分账接收方结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingReceiver addProfitSharingReceiver(ProfitSharingReceiver receiver) throws WxPayException; + + /** + *
+   * 删除分账接收方API
+   *
+   * 商户发起删除分账接收方请求。删除后,不支持将分账方商户结算后的资金,分到该分账接收方
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_9.shtml
+   * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/receivers/delete
+   * 
+ * + * @param receiver 分账接收方实体 {@link ProfitSharingReceiver} + * @return {@link ProfitSharingReceiver} 微信返回的删除的分账接收方结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingReceiver deleteProfitSharingReceiver(ProfitSharingReceiver receiver) throws WxPayException; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java index 563cf1c52..9b418bcea 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java @@ -189,11 +189,20 @@ public interface WxPayService { /** * 获取分账服务类. + *

+ * V3接口 {@link WxPayService#getProfitSharingV3Service()} + *

* * @return the ent pay service */ ProfitSharingService getProfitSharingService(); + /** + * 获取V3分账服务类. + * + * @return the ent pay service + */ + ProfitSharingV3Service getProfitSharingV3Service(); /** * 获取支付分服务类. diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java index a369369f1..d39e22e7d 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java +++ b/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); @@ -85,6 +86,11 @@ public abstract class BaseWxPayServiceImpl implements WxPayService { return profitSharingService; } + @Override + public ProfitSharingV3Service getProfitSharingV3Service() { + return profitSharingV3Service; + } + @Override public PayScoreService getPayScoreService() { return payScoreService; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingV3ServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingV3ServiceImpl.java new file mode 100644 index 000000000..539836de1 --- /dev/null +++ b/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); + } +}