From f5ac3b181e2aff2b21bf5a06bb23aa8256ed1355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9B=9B=E5=8F=B6=E8=8D=89?= <362692680@qq.com> Date: Mon, 21 Aug 2023 09:08:35 +0000 Subject: [PATCH] =?UTF-8?q?:new:=20=E3=80=90=E5=BE=AE=E4=BF=A1=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E3=80=91=E6=96=B0=E5=A2=9Ev3=E5=88=86=E8=B4=A6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E8=B4=A6=E6=9F=A5=E8=AF=A2=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0=E5=88=86=E8=B4=A6?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E5=8D=95=E5=8F=B7=E5=AD=97=E6=AE=B5detail=5F?= =?UTF-8?q?id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProfitSharingQueryResult.java | 5 ++ .../v3/ProfitSharingQueryRequest.java | 62 +++++++++++++++++++ .../profitsharing/v3/ProfitSharingResult.java | 2 +- .../wxpay/service/ProfitSharingV3Service.java | 18 ++++++ .../impl/ProfitSharingV3ServiceImpl.java | 28 +++++++++ 5 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/v3/ProfitSharingQueryRequest.java diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryResult.java index 4eb7a4e23..09e83d9d9 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingQueryResult.java @@ -121,6 +121,10 @@ public class ProfitSharingQueryResult extends BaseWxPayResult implements Seriali * 分账失败原因 */ private String failReason; + /** + * 分账明细单号 + */ + private String detailId; @Override public String toString() { @@ -132,6 +136,7 @@ public class ProfitSharingQueryResult extends BaseWxPayResult implements Seriali ", result='" + result + '\'' + ", finishTime='" + finishTime + '\'' + ", failReason='" + failReason + '\'' + + ", detailId='" + detailId + '\'' + '}'; } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/v3/ProfitSharingQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/v3/ProfitSharingQueryRequest.java new file mode 100644 index 000000000..ae50d5e52 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/v3/ProfitSharingQueryRequest.java @@ -0,0 +1,62 @@ +package com.github.binarywang.wxpay.bean.profitsharing.v3; + +import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest; +import com.github.binarywang.wxpay.constant.WxPayConstants; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.google.gson.annotations.SerializedName; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.*; +import lombok.experimental.Accessors; +import me.chanjar.weixin.common.annotation.Required; + +import java.io.Serializable; +import java.util.Map; + +/** + * @author lyt 2023/08/21 15:44 + * @version 1.0 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class ProfitSharingQueryRequest implements Serializable { + private static final long serialVersionUID = 1L; + /** + *
+ * 字段名:子商户号 + * 是否必填:是 + * 描述:微信支付分配的子商户号,即分账的出资商户号。 + *+ */ + @SerializedName("sub_mchid") + private String subMchId; + /** + *
+ * 字段名:微信支付订单号. + * 变量名:transaction_id + * 是否必填:是 + * String(32) + * 示例值:4208450740201411110007820472 + * 描述:微信支付订单号 + *+ */ + @XStreamAlias("transaction_id") + @Required + private String transactionId; + + /** + *
+ * 字段名:商户分账单号. + * 变量名:out_order_no + * 是否必填:是 + * String(64) + * 示例值:P20150806125346 + * 描述:查询分账结果,输入申请分账时的商户分账单号; 查询分账完结的执行结果,输入发起分账完结时的商户分账单号 + *+ */ + @XStreamAlias("out_order_no") + @Required + private String outOrderNo; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/v3/ProfitSharingResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/v3/ProfitSharingResult.java index 1891e692f..6fd84afdd 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/v3/ProfitSharingResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/v3/ProfitSharingResult.java @@ -112,7 +112,7 @@ public class ProfitSharingResult implements Serializable { * */ @SerializedName("amount") - private Long amount; + private Integer amount; /** *
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 index edca327db..27d66e4e7 100644 --- 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 @@ -274,4 +274,22 @@ public interface ProfitSharingV3Service { * @date 2022-12-09 */ ProfitSharingBillResult getProfitSharingBill(ProfitSharingBillRequest 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 request {@link ProfitSharingQueryRequest} 针对某一笔分账订单的分账方法 + * @return {@link ProfitSharingResult} 微信返回的分账查询结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + ProfitSharingResult profitSharingQuery(ProfitSharingQueryRequest 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 cd0d0255c..f2a1cf597 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 @@ -166,6 +166,34 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service { return GSON.fromJson(result, ProfitSharingBillResult.class); } + /** + *+ * 请求分账查询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 request {@link ProfitSharingQueryRequest} 针对某一笔分账订单的分账方法 + * @return {@link ProfitSharingResult} 微信返回的分账查询结果 + * @throws WxPayException the wx pay exception + * @see 微信文档 + */ + @Override + public ProfitSharingResult profitSharingQuery(ProfitSharingQueryRequest request) throws WxPayException { + String url = String.format("%s/v3/profitsharing/orders/%s?transaction_id=%s", this.payService.getPayBaseUrl(), + request.getOutOrderNo(), request.getOutOrderNo()); + if(StringUtils.isNotEmpty(request.getSubMchId())){ + url += "&sub_mchid=" + request.getSubMchId(); + } + String result = this.payService.getV3(url); + return GSON.fromJson(result, ProfitSharingResult.class); + } + private ProfitSharingNotifyData parseNotifyData(String data, SignatureHeader header) throws WxPayException { if (Objects.nonNull(header) && !this.verifyNotifySign(header, data)) { throw new WxPayException("非法请求,头部信息验证失败");