From 0d1320a48f20ab517ca9732603670660d394cdab Mon Sep 17 00:00:00 2001 From: NotePlus <76406840@qq.com> Date: Sun, 25 Dec 2022 14:38:26 +0000 Subject: [PATCH] =?UTF-8?q?:new:=E3=80=90=E5=BE=AE=E4=BF=A1=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E3=80=91=E5=A2=9E=E5=8A=A0=E6=9F=A5=E8=AF=A2=E7=BB=93?= =?UTF-8?q?=E7=AE=97=E8=B4=A6=E6=88=B7=E3=80=81=E6=9F=A5=E8=AF=A2=E5=88=86?= =?UTF-8?q?=E8=B4=A6=E7=BB=93=E6=9E=9C=E3=80=81=E6=9F=A5=E8=AF=A2=E5=88=86?= =?UTF-8?q?=E8=B4=A6=E5=9B=9E=E9=80=80=E7=BB=93=E6=9E=9C=E5=92=8C=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E5=88=86=E8=B4=A6=E8=B4=A6=E5=8D=95=E7=AD=89V3?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bean/applyment/SettlementInfoResult.java | 10 +++ .../ProfitSharingBillRequest.java | 55 ++++++++++++++++ .../ProfitSharingBillResult.java | 62 ++++++++++++++++++ .../WxPayOrderNotifyResultConverter.java | 2 +- .../wxpay/service/Applyment4SubService.java | 6 +- .../wxpay/service/ProfitSharingV3Service.java | 63 ++++++++++++++++++- .../impl/ProfitSharingV3ServiceImpl.java | 28 +++++++++ 7 files changed, 220 insertions(+), 6 deletions(-) create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingBillRequest.java create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingBillResult.java diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementInfoResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementInfoResult.java index ffa3bf73e..6c490a929 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementInfoResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/applyment/SettlementInfoResult.java @@ -11,6 +11,8 @@ import java.io.Serializable; /** * 查询结算账户返回对象信息 + * + * @see 查询结算账户 */ @Data @Builder @@ -51,4 +53,12 @@ public class SettlementInfoResult implements Serializable { */ @SerializedName("verify_result") private String verifyResult; + /** + * 汇款验证失败原因 + * + * @since 4.4.0 + * @date 2022.12.09 + */ + @SerializedName("verify_fail_reason") + private String verifyFailReason; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingBillRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingBillRequest.java new file mode 100644 index 000000000..143c55b69 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingBillRequest.java @@ -0,0 +1,55 @@ +package com.github.binarywang.wxpay.bean.profitsharingV3; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 微信V3接口-申请分账账单请求类 + * + * @author 狂龙骄子 + * @since 4.4.0 + * @date 2022-12-09 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class ProfitSharingBillRequest implements Serializable { + private static final long serialVersionUID = 5200819754873844593L; + + /** + *
+ * 字段名:子商户号 + * 是否必填:否 + * 描述:不填则默认返回服务商下的所有分账账单。如需下载某个子商户下的分账账单,则填指定的子商户号。 + *+ */ + @SerializedName("sub_mchid") + private String subMchId; + + /** + *
+ * 字段名:账单日期 + * 是否必填:是 + * 描述:格式yyyy-MM-DD,仅支持三个月内的账单下载申请。 + *+ */ + @SerializedName("bill_date") + private String billDate; + + /** + *
+ * 字段名:压缩类型 + * 是否必填:否 + * 描述:不填则默认是数据流。枚举值:GZIP:返回格式为.gzip的压缩包账单。 + *+ */ + @SerializedName("tar_type") + private String tarType; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingBillResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingBillResult.java new file mode 100644 index 000000000..7388868bd --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingBillResult.java @@ -0,0 +1,62 @@ +package com.github.binarywang.wxpay.bean.profitsharingV3; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 微信V3接口-申请分账账单结果类 + * + * @author 狂龙骄子 + * @since 4.4.0 + * @date 2022-12-09 + */ +@Data +@NoArgsConstructor +public class ProfitSharingBillResult implements Serializable { + private static final long serialVersionUID = -704896948531566657L; + + /** + *
+ * 字段名:账单下载地址 + * 变量名:download_url + * 是否必填:是 + * 类型:string[1,2048] + * 描述: + * 供下一步请求账单文件的下载地址,该地址30s内有效。 + * 示例值:https://api.mch.weixin.qq.com/v3/bill/downloadurl?token=xxx + *+ */ + @SerializedName(value = "download_url") + private String downloadUrl; + + /** + *
+ * 字段名:哈希类型 + * 变量名:hash_type + * 是否必填:是 + * 类型:string[1, 32] + * 描述: + * 原始账单(gzip需要解压缩)的摘要值,用于校验文件的完整性。 + * 示例值:SHA1 + *+ */ + @SerializedName(value = "hash_type") + private String hashType; + + /** + *
+ * 字段名:哈希值 + * 变量名:hash_value + * 是否必填:是 + * 类型:string[1,1024] + * 描述: + * 原始账单(gzip需要解压缩)的摘要值,用于校验文件的完整性。 + * 示例值:79bb0f45fc4c42234a918000b2668d689e2bde04 + *+ */ + @SerializedName(value = "hash_value") + private String hashValue; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java index 3fa2e5bf9..1f426122b 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java @@ -51,7 +51,7 @@ public class WxPayOrderNotifyResultConverter extends AbstractReflectionConverter super.marshal(original, writer, context); WxPayOrderNotifyResult obj = (WxPayOrderNotifyResult) original; List
- * 查询分账结果API + * 查询分账结果API(商户平台) * * 发起分账请求后,可调用此接口查询分账结果 * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_2.shtml @@ -69,6 +69,27 @@ public interface ProfitSharingV3Service { */ ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId) throws WxPayException; + /** + *+ * 查询分账结果API(服务商平台) + * + * 发起分账请求后,可调用此接口查询分账结果 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_2.shtml + * 接口链接:https://api.mch.weixin.qq.com/v3/profitsharing/orders/{out_order_no} + * + * 注意: + * • 发起解冻剩余资金请求后,可调用此接口查询解冻剩余资金的结果 + *+ * + * @param outOrderNo 商户系统内部的分账单号,在商户系统内部唯一,同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@ 。 + * @param transactionId 微信支付订单号 + * @param subMchId 微信支付分配的子商户号,即分账的出资商户号。 + * @return {@link ProfitSharingResult} 微信返回的分账结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId, String subMchId) throws WxPayException; + /** ** 请求分账回退API @@ -94,7 +115,7 @@ public interface ProfitSharingV3Service { /** *- * 查询分账回退结果API + * 查询分账回退结果API(商户平台) * * 商户需要核实回退结果,可调用此接口查询回退结果 * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_4.shtml @@ -112,6 +133,27 @@ public interface ProfitSharingV3Service { */ ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo) throws WxPayException; + /** + *+ * 查询分账回退结果API(服务商平台) + * + * 商户需要核实回退结果,可调用此接口查询回退结果 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_3.shtml + * 接口链接:https://api.mch.weixin.qq.com/v3/profitsharing/return-orders/{out_return_no} + * + * 注意: + * • 如果分账回退接口返回状态为处理中,可调用此接口查询回退结果 + *+ * + * @param outOrderNo 原发起分账请求时使用的商户系统内部的分账单号 + * @param outReturnNo 调用回退接口提供的商户系统内部的回退单号 + * @param subMchId 微信支付分配的子商户号,即分账的回退方商户号。 + * @return {@link ProfitSharingReturnResult} 微信返回的分账回退结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo, String subMchId) throws WxPayException; + /** ** 解冻剩余资金API @@ -198,4 +240,21 @@ public interface ProfitSharingV3Service { */ ProfitSharingNotifyData getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException; + /** + *+ * 申请分账账单 + * + * 微信支付按天提供分账账单文件,商户可以通过该接口获取账单文件的下载地址 + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_11.shtml + * 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/bills + *+ * + * @param request 申请分账账单请求实体({@link ProfitSharingBillRequest}) + * @return {@link ProfitSharingBillResult} 申请分账账单结果类 + * @throws WxPayException the wx pay exception + * @see 服务商平台>>API字典>>资金应用>>分账>>申请分账账单API + * @since 4.4.0 + * @date 2022-12-09 + */ + ProfitSharingBillResult getProfitSharingBill(ProfitSharingBillRequest request) throws WxPayException; } 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 index d43facd24..ce4e5770e 100644 --- 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 @@ -12,6 +12,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -52,6 +53,13 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service { return GSON.fromJson(result, ProfitSharingResult.class); } + @Override + public ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId, String subMchId) throws WxPayException { + String url = String.format("%s/v3/profitsharing/orders/%s?sub_mchid=%s&transaction_id=%s", this.payService.getPayBaseUrl(), outOrderNo, subMchId, 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()); @@ -67,6 +75,13 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service { return GSON.fromJson(result, ProfitSharingReturnResult.class); } + @Override + public ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo, String subMchId) throws WxPayException { + String url = String.format("%s/v3/profitsharing/return-orders/%s?sub_mchid=%s&out_order_no=%s", this.payService.getPayBaseUrl(), outReturnNo, subMchId, 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()); @@ -115,6 +130,19 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service { } } + @Override + public ProfitSharingBillResult getProfitSharingBill(ProfitSharingBillRequest request) throws WxPayException { + String url = String.format("%s/v3/profitsharing/bills?bill_date=%s", this.payService.getPayBaseUrl(), request.getBillDate()); + if (StringUtils.isNotBlank(request.getSubMchId())) { + url = String.format("%s&sub_mchid=%s", url, request.getSubMchId()); + } + if (StringUtils.isNotBlank(request.getTarType())) { + url = String.format("%s&tar_type=%s", url, request.getTarType()); + } + String result = this.payService.getV3(url); + return GSON.fromJson(result, ProfitSharingBillResult.class); + } + private ProfitSharingNotifyData parseNotifyData(String data, SignatureHeader header) throws WxPayException { if (Objects.nonNull(header) && !this.verifyNotifySign(header, data)) { throw new WxPayException("非法请求,头部信息验证失败");