From 58671ad3f945a7f53f87b6041abe12fec5ef16c9 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sun, 25 Oct 2020 15:36:49 +0800 Subject: [PATCH 1/8] =?UTF-8?q?:art:=20=E9=87=8D=E6=9E=84=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=8C=85=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/common/{api => service}/WxImgProcService.java | 2 +- .../me/chanjar/weixin/common/service}/WxOAuth2Service.java | 2 +- .../chanjar/weixin/common/{api => service}/WxOcrService.java | 2 +- .../main/java/cn/binarywang/wx/miniapp/api/WxMaService.java | 4 ++-- .../binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java | 4 ++-- .../wx/miniapp/api/impl/WxMaImgProcServiceImpl.java | 2 +- .../binarywang/wx/miniapp/api/impl/WxMaOcrServiceImpl.java | 2 +- .../src/main/java/me/chanjar/weixin/mp/api/WxMpService.java | 5 +++-- .../me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java | 5 +++-- .../chanjar/weixin/mp/api/impl/WxMpImgProcServiceImpl.java | 2 +- .../me/chanjar/weixin/mp/api/impl/WxMpOAuth2ServiceImpl.java | 2 +- .../me/chanjar/weixin/mp/api/impl/WxMpOcrServiceImpl.java | 2 +- .../weixin/mp/api/impl/WxMpImgProcServiceImplTest.java | 2 +- 13 files changed, 19 insertions(+), 17 deletions(-) rename weixin-java-common/src/main/java/me/chanjar/weixin/common/{api => service}/WxImgProcService.java (99%) rename {weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api => weixin-java-common/src/main/java/me/chanjar/weixin/common/service}/WxOAuth2Service.java (98%) rename weixin-java-common/src/main/java/me/chanjar/weixin/common/{api => service}/WxOcrService.java (98%) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxImgProcService.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxImgProcService.java similarity index 99% rename from weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxImgProcService.java rename to weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxImgProcService.java index c7d1bcfc14..a9ef694ad5 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxImgProcService.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxImgProcService.java @@ -1,4 +1,4 @@ -package me.chanjar.weixin.common.api; +package me.chanjar.weixin.common.service; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.bean.imgproc.WxImgProcAiCropResult; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxOAuth2Service.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOAuth2Service.java similarity index 98% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxOAuth2Service.java rename to weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOAuth2Service.java index 0c7cc5764c..97a74d2c68 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxOAuth2Service.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOAuth2Service.java @@ -1,4 +1,4 @@ -package me.chanjar.weixin.mp.api; +package me.chanjar.weixin.common.service; import me.chanjar.weixin.common.bean.WxOAuth2UserInfo; import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken; diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxOcrService.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOcrService.java similarity index 98% rename from weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxOcrService.java rename to weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOcrService.java index 480ed3e95b..7b4fe337e5 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxOcrService.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOcrService.java @@ -1,4 +1,4 @@ -package me.chanjar.weixin.common.api; +package me.chanjar.weixin.common.service; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.bean.ocr.WxOcrBankCardResult; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java index 13862b12fd..e79e3cad36 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java @@ -2,8 +2,8 @@ import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.config.WxMaConfig; -import me.chanjar.weixin.common.api.WxImgProcService; -import me.chanjar.weixin.common.api.WxOcrService; +import me.chanjar.weixin.common.service.WxImgProcService; +import me.chanjar.weixin.common.service.WxOcrService; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.service.WxService; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java index 492f8a9e12..bb189ce471 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java @@ -11,8 +11,8 @@ import com.google.gson.JsonObject; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.api.WxImgProcService; -import me.chanjar.weixin.common.api.WxOcrService; +import me.chanjar.weixin.common.service.WxImgProcService; +import me.chanjar.weixin.common.service.WxOcrService; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.enums.WxType; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImgProcServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImgProcServiceImpl.java index 0499b7c7e0..4bdb061675 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImgProcServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImgProcServiceImpl.java @@ -2,7 +2,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import lombok.RequiredArgsConstructor; -import me.chanjar.weixin.common.api.WxImgProcService; +import me.chanjar.weixin.common.service.WxImgProcService; import me.chanjar.weixin.common.bean.imgproc.WxImgProcAiCropResult; import me.chanjar.weixin.common.bean.imgproc.WxImgProcQrCodeResult; import me.chanjar.weixin.common.bean.imgproc.WxImgProcSuperResolutionResult; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOcrServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOcrServiceImpl.java index edc5a363c1..3e7eb8c38a 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOcrServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaOcrServiceImpl.java @@ -2,7 +2,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import lombok.RequiredArgsConstructor; -import me.chanjar.weixin.common.api.WxOcrService; +import me.chanjar.weixin.common.service.WxOcrService; import me.chanjar.weixin.common.bean.ocr.*; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.requestexecuter.ocr.OcrDiscernRequestExecutor; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java index 50c6e48ba8..fe8d2abf38 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java @@ -1,12 +1,13 @@ package me.chanjar.weixin.mp.api; import com.google.gson.JsonObject; -import me.chanjar.weixin.common.api.WxImgProcService; -import me.chanjar.weixin.common.api.WxOcrService; +import me.chanjar.weixin.common.service.WxImgProcService; +import me.chanjar.weixin.common.service.WxOcrService; import me.chanjar.weixin.common.bean.WxJsapiSignature; import me.chanjar.weixin.common.bean.WxNetCheckResult; import me.chanjar.weixin.common.enums.TicketType; import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.service.WxOAuth2Service; import me.chanjar.weixin.common.service.WxService; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestExecutor; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java index c2ecc475f3..0047535517 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java @@ -8,8 +8,8 @@ import lombok.Setter; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.api.WxImgProcService; -import me.chanjar.weixin.common.api.WxOcrService; +import me.chanjar.weixin.common.service.WxImgProcService; +import me.chanjar.weixin.common.service.WxOcrService; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.bean.WxJsapiSignature; @@ -19,6 +19,7 @@ import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; +import me.chanjar.weixin.common.service.WxOAuth2Service; import me.chanjar.weixin.common.session.StandardSessionManager; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.common.util.DataUtils; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpImgProcServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpImgProcServiceImpl.java index 24c699657d..ea1785f233 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpImgProcServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpImgProcServiceImpl.java @@ -2,7 +2,7 @@ import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.common.api.WxImgProcService; +import me.chanjar.weixin.common.service.WxImgProcService; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.common.bean.imgproc.WxImgProcAiCropResult; import me.chanjar.weixin.common.bean.imgproc.WxImgProcQrCodeResult; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOAuth2ServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOAuth2ServiceImpl.java index 8d8187daa1..f77da7c855 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOAuth2ServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOAuth2ServiceImpl.java @@ -11,7 +11,7 @@ import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; import me.chanjar.weixin.common.util.http.URIUtil; import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.api.WxOAuth2Service; +import me.chanjar.weixin.common.service.WxOAuth2Service; import me.chanjar.weixin.mp.config.WxMpConfigStorage; import org.apache.commons.lang3.StringUtils; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOcrServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOcrServiceImpl.java index d4286b6177..7f6a2e3cff 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOcrServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpOcrServiceImpl.java @@ -1,7 +1,7 @@ package me.chanjar.weixin.mp.api.impl; import lombok.RequiredArgsConstructor; -import me.chanjar.weixin.common.api.WxOcrService; +import me.chanjar.weixin.common.service.WxOcrService; import me.chanjar.weixin.common.bean.ocr.*; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.requestexecuter.ocr.OcrDiscernRequestExecutor; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpImgProcServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpImgProcServiceImplTest.java index 4d2c21bce9..21ca3236f5 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpImgProcServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpImgProcServiceImplTest.java @@ -2,7 +2,7 @@ import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.fs.FileUtils; -import me.chanjar.weixin.common.api.WxImgProcService; +import me.chanjar.weixin.common.service.WxImgProcService; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.test.TestConstants; From d265065d36d88a06fcbf5ca7cfe0774e70fcae65 Mon Sep 17 00:00:00 2001 From: hrq Date: Tue, 27 Oct 2020 11:19:51 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=B6=E4=BB=98=E9=80=9A=E6=9F=A5=E8=AF=A2=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ecommerce/SpWithdrawStatusResult.java | 192 ++++++++++++++++++ .../ecommerce/SubWithdrawStatusResult.java | 190 +++++++++++++++++ .../wxpay/service/EcommerceService.java | 25 +++ .../service/impl/EcommerceServiceImpl.java | 14 ++ 4 files changed, 421 insertions(+) create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawStatusResult.java create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawStatusResult.java diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawStatusResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawStatusResult.java new file mode 100644 index 0000000000..b3daef3946 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawStatusResult.java @@ -0,0 +1,192 @@ +package com.github.binarywang.wxpay.bean.ecommerce; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 电商平台查询提现状态 + *
+ *   文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_6.shtml
+ * 
+ * @author: f00lish + * @date: 2020/10/27 + */ +@Data +@NoArgsConstructor +public class SpWithdrawStatusResult { + + + /** + *
+   * 字段名:提现单状态
+   * 变量名:status
+   * 是否必填:是
+   * 类型:string(16)
+   * 描述:
+   *  枚举值:
+   *  CREATE_SUCCESS:受理成功
+   *  SUCCESS:提现成功
+   *  FAIL:提现失败
+   *  REFUND:提现退票
+   *  CLOSE:关单
+   *  INIT:业务单已创建
+   * 示例值:CREATE_SUCCESS
+   * 
+ */ + @SerializedName(value = "status") + private String status; + + + /** + *
+   * 字段名:微信支付提现单号
+   * 变量名:withdraw_id
+   * 是否必填:是
+   * 类型:string(128)
+   * 描述:
+   *  电商平台提交二级商户提现申请后,由微信支付返回的申请单号,作为查询申请状态的唯一标识。
+   * 示例值: 12321937198237912739132791732912793127931279317929791239112123
+   * 
+ */ + @SerializedName(value = "withdraw_id") + private String withdrawId; + + /** + *
+   * 字段名:商户提现单号
+   * 变量名:out_request_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户提现单号,由商户自定义生成。
+   * 示例值: 20190611222222222200000000012122
+   * 
+ */ + @SerializedName(value = "out_request_no") + private String outRequestNo; + + /** + *
+   * 字段名:提现金额
+   * 变量名:amount
+   * 是否必填:是
+   * 类型:int)
+   * 描述:
+   *  单位:分
+   * 示例值:1
+   * 
+ */ + @SerializedName(value = "amount") + private Integer amount; + + + /** + *
+   * 字段名:发起提现时间
+   * 变量名:create_time
+   * 是否必填:是
+   * 类型:string(29)
+   * 描述:
+   *  遵循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+08:00表示,北京时间2015年5月20日13点29分35秒。
+   * 示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName(value = "create_time") + private String createTime; + + + /** + *
+   * 字段名:提现状态更新时间
+   * 变量名:update_time
+   * 是否必填:是
+   * 类型:string(29)
+   * 描述:
+   *  遵循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+08:00表示,北京时间2015年5月20日13点29分35秒。
+   * 示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName(value = "update_time") + private String updateTime; + + + /** + *
+   * 字段名:失败原因
+   * 变量名:reason
+   * 是否必填:是
+   * 类型:string(255)
+   * 描述:
+   *  仅在提现失败、退票、关单时有值
+   * 示例值:卡号错误
+   * 
+ */ + @SerializedName(value = "reason") + private String reason; + + /** + *
+   * 字段名:提现备注
+   * 变量名:remark
+   * 是否必填:是
+   * 类型:string(56)
+   * 描述:
+   *  商户对提现单的备注,若发起提现时未传入相应值或输入不合法,则该值为空
+   * 示例值:交易提现
+   * 
+ */ + @SerializedName(value = "remark") + private String remark; + + /** + *
+   * 字段名:银行附言
+   * 变量名:bank_memo
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  展示在收款银行系统中的附言,由数字、字母、汉字组成(能否成功展示依赖银行系统支持)。若发起提现时未传入相应值或输入不合法,则该值为空
+   * 示例值:微信提现
+   * 
+ */ + @SerializedName(value = "bank_memo") + private String bankMemo; + + /** + *
+   * 字段名:出款账户类型
+   * 变量名:account_type
+   * 是否必填:是
+   * 类型:string(16)
+   * 描述:
+   *  BASIC:基本户
+   *  OPERATION:运营账户
+   *  FEES:手续费账户
+   * 示例值:BASIC
+   * 
+ */ + @SerializedName(value = "account_type") + private String account_type; + + /** + *
+   * 字段名:提现失败解决方案
+   * 变量名:solution
+   * 是否必填:是
+   * 类型:string(255)
+   * 描述:
+   *  仅在提现失败、退票、关单时有值
+   * 示例值:请修改结算银行卡信息
+   * 
+ */ + @SerializedName(value = "solution") + private String solution; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawStatusResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawStatusResult.java new file mode 100644 index 0000000000..eead7475b9 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawStatusResult.java @@ -0,0 +1,190 @@ +package com.github.binarywang.wxpay.bean.ecommerce; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 二级商户查询提现状态 + *
+ *   文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_3.shtml
+ * 
+ * @author: f00lish + * @date: 2020/10/27 + */ +@Data +@NoArgsConstructor +public class SubWithdrawStatusResult { + + /** + *
+   * 字段名:二级商户号
+   * 变量名:sub_mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  电商平台二级商户号,由微信支付生成并下发。
+   * 示例值:1900000109
+   * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+   * 字段名:电商平台商户号
+   * 变量名:sp_mchid
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  电商平台商户号
+   * 示例值:1800000123
+   * 
+ */ + @SerializedName(value = "sp_mchid") + private String spMchid; + + + /** + *
+   * 字段名:提现单状态
+   * 变量名:status
+   * 是否必填:是
+   * 类型:string(16)
+   * 描述:
+   *  枚举值:
+   *  CREATE_SUCCESS:受理成功
+   *  SUCCESS:提现成功
+   *  FAIL:提现失败
+   *  REFUND:提现退票
+   *  CLOSE:关单
+   *  INIT:业务单已创建
+   * 示例值:CREATE_SUCCESS
+   * 
+ */ + @SerializedName(value = "status") + private String status; + + + /** + *
+   * 字段名:微信支付提现单号
+   * 变量名:withdraw_id
+   * 是否必填:是
+   * 类型:string(128)
+   * 描述:
+   *  电商平台提交二级商户提现申请后,由微信支付返回的申请单号,作为查询申请状态的唯一标识。
+   * 示例值: 12321937198237912739132791732912793127931279317929791239112123
+   * 
+ */ + @SerializedName(value = "withdraw_id") + private String withdrawId; + + /** + *
+   * 字段名:商户提现单号
+   * 变量名:out_request_no
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  商户提现单号,由商户自定义生成。
+   * 示例值: 20190611222222222200000000012122
+   * 
+ */ + @SerializedName(value = "out_request_no") + private String outRequestNo; + + /** + *
+   * 字段名:提现金额
+   * 变量名:amount
+   * 是否必填:是
+   * 类型:int)
+   * 描述:
+   *  单位:分
+   * 示例值:1
+   * 
+ */ + @SerializedName(value = "amount") + private Integer amount; + + + /** + *
+   * 字段名:发起提现时间
+   * 变量名:create_time
+   * 是否必填:是
+   * 类型:string(29)
+   * 描述:
+   *  遵循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+08:00表示,北京时间2015年5月20日13点29分35秒。
+   * 示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName(value = "create_time") + private String createTime; + + + /** + *
+   * 字段名:提现状态更新时间
+   * 变量名:update_time
+   * 是否必填:是
+   * 类型:string(29)
+   * 描述:
+   *  遵循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+08:00表示,北京时间2015年5月20日13点29分35秒。
+   * 示例值:2015-05-20T13:29:35.120+08:00
+   * 
+ */ + @SerializedName(value = "update_time") + private String updateTime; + + + /** + *
+   * 字段名:失败原因
+   * 变量名:reason
+   * 是否必填:是
+   * 类型:string(255)
+   * 描述:
+   *  仅在提现失败、退票、关单时有值
+   * 示例值:卡号错误
+   * 
+ */ + @SerializedName(value = "reason") + private String reason; + + /** + *
+   * 字段名:提现备注
+   * 变量名:remark
+   * 是否必填:是
+   * 类型:string(56)
+   * 描述:
+   *  商户对提现单的备注,若发起提现时未传入相应值或输入不合法,则该值为空
+   * 示例值:交易提现
+   * 
+ */ + @SerializedName(value = "remark") + private String remark; + + /** + *
+   * 字段名:银行附言
+   * 变量名:bank_memo
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  展示在收款银行系统中的附言,由数字、字母、汉字组成(能否成功展示依赖银行系统支持)。若发起提现时未传入相应值或输入不合法,则该值为空
+   * 示例值:微信提现
+   * 
+ */ + @SerializedName(value = "bank_memo") + private String bankMemo; + +} 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 6e536bb39c..367f2e8e1e 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 @@ -339,6 +339,31 @@ public interface EcommerceService { */ SpWithdrawResult spWithdraw(SpWithdrawRequest request) throws WxPayException; + /** + *
+   * 二级商户查询提现状态API
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_3.shtml
+   * 
+ * + * @param subMchid 二级商户号 + * @param outRequestNo 商户提现单号 + * @return 返回数据 return sub withdraw status result + * @throws WxPayException the wx pay exception + */ + SubWithdrawStatusResult querySubWithdrawByOutRequestNo(String subMchid, String outRequestNo) throws WxPayException; + + /** + *
+   * 电商平台查询提现状态API
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_6.shtml
+   * 
+ * + * @param outRequestNo 商户提现单号 + * @return 返回数据 return sp withdraw status result + * @throws WxPayException the wx pay exception + */ + SpWithdrawStatusResult querySpWithdrawByOutRequestNo(String outRequestNo) 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 193d6a20ec..5c2856fbbf 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
@@ -266,6 +266,20 @@ public SpWithdrawResult spWithdraw(SpWithdrawRequest request) throws WxPayExcept
     return GSON.fromJson(response, SpWithdrawResult.class);
   }
 
+  @Override
+  public SubWithdrawStatusResult querySubWithdrawByOutRequestNo(String subMchid, String outRequestNo) throws WxPayException {
+    String url = String.format("%s/v3/ecommerce/fund/withdraw/out-request-no/%s?sub_mcid=%s", this.payService.getPayBaseUrl(), subMchid, outRequestNo);
+    String response = this.payService.getV3(URI.create(url));
+    return GSON.fromJson(response, SubWithdrawStatusResult.class);
+  }
+
+  @Override
+  public SpWithdrawStatusResult querySpWithdrawByOutRequestNo(String outRequestNo) throws WxPayException {
+    String url = String.format("%s/v3/merchant/fund/withdraw/out-request-no%s", this.payService.getPayBaseUrl(), outRequestNo);
+    String response = this.payService.getV3(URI.create(url));
+    return GSON.fromJson(response, SpWithdrawStatusResult.class);
+  }
+
   @Override
   public void modifySettlement(String subMchid, SettlementRequest request) throws WxPayException {
     String url = String.format("%s/v3/apply4sub/sub_merchants/%s/modify-settlement", this.payService.getPayBaseUrl(), subMchid);

From 5fdb8eb783a94d457885349aab61fc357a1f275d Mon Sep 17 00:00:00 2001
From: hrq 
Date: Tue, 27 Oct 2020 14:33:55 +0800
Subject: [PATCH 3/8] =?UTF-8?q?fix=20=E6=9F=A5=E8=AF=A2=E6=8F=90=E7=8E=B0?=
 =?UTF-8?q?=E7=BB=93=E6=9E=9C=E7=B1=BB=E7=9A=84=E5=BA=8F=E5=88=97=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../wxpay/bean/ecommerce/SpWithdrawStatusResult.java         | 5 ++++-
 .../wxpay/bean/ecommerce/SubWithdrawStatusResult.java        | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawStatusResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawStatusResult.java
index b3daef3946..d4c02443aa 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawStatusResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawStatusResult.java
@@ -4,6 +4,8 @@
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.io.Serializable;
+
 /**
  * 电商平台查询提现状态
  * 
@@ -14,9 +16,10 @@
  */
 @Data
 @NoArgsConstructor
-public class SpWithdrawStatusResult {
+public class SpWithdrawStatusResult implements Serializable {
 
 
+  private static final long serialVersionUID = -6013827963506201478L;
   /**
    * 
    * 字段名:提现单状态
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawStatusResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawStatusResult.java
index eead7475b9..27d624872b 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawStatusResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawStatusResult.java
@@ -4,6 +4,8 @@
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.io.Serializable;
+
 /**
  * 二级商户查询提现状态
  * 
@@ -14,8 +16,9 @@
  */
 @Data
 @NoArgsConstructor
-public class SubWithdrawStatusResult {
+public class SubWithdrawStatusResult implements Serializable {
 
+  private static final long serialVersionUID = 4692602703819018325L;
   /**
    * 
    * 字段名:二级商户号

From ed1c7c4757058efd8927758cfa23878482b283ab Mon Sep 17 00:00:00 2001
From: hrq 
Date: Fri, 30 Oct 2020 15:15:57 +0800
Subject: [PATCH 4/8] =?UTF-8?q?fix=20=E6=94=B6=E4=BB=98=E9=80=9A=E6=8F=90?=
 =?UTF-8?q?=E7=8E=B0=E7=8A=B6=E6=80=81=E6=9F=A5=E8=AF=A2=E6=97=B6=E6=8E=A5?=
 =?UTF-8?q?=E5=8F=A3=E5=9C=B0=E5=9D=80=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../binarywang/wxpay/service/impl/EcommerceServiceImpl.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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 5c2856fbbf..a41ee81b06 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
@@ -268,14 +268,14 @@ public SpWithdrawResult spWithdraw(SpWithdrawRequest request) throws WxPayExcept
 
   @Override
   public SubWithdrawStatusResult querySubWithdrawByOutRequestNo(String subMchid, String outRequestNo) throws WxPayException {
-    String url = String.format("%s/v3/ecommerce/fund/withdraw/out-request-no/%s?sub_mcid=%s", this.payService.getPayBaseUrl(), subMchid, outRequestNo);
+    String url = String.format("%s/v3/ecommerce/fund/withdraw/out-request-no/%s?sub_mchid=%s", this.payService.getPayBaseUrl(), outRequestNo, subMchid);
     String response = this.payService.getV3(URI.create(url));
     return GSON.fromJson(response, SubWithdrawStatusResult.class);
   }
 
   @Override
   public SpWithdrawStatusResult querySpWithdrawByOutRequestNo(String outRequestNo) throws WxPayException {
-    String url = String.format("%s/v3/merchant/fund/withdraw/out-request-no%s", this.payService.getPayBaseUrl(), outRequestNo);
+    String url = String.format("%s/v3/merchant/fund/withdraw/out-request-no/%s", this.payService.getPayBaseUrl(), outRequestNo);
     String response = this.payService.getV3(URI.create(url));
     return GSON.fromJson(response, SpWithdrawStatusResult.class);
   }

From a2dd7f68936bcf1a2b223cacccf5ff7da82a71df Mon Sep 17 00:00:00 2001
From: hrq 
Date: Thu, 5 Nov 2020 18:32:44 +0800
Subject: [PATCH 5/8] =?UTF-8?q?fix=20=E5=BE=AE=E4=BF=A1=E6=94=B6=E4=BB=98?=
 =?UTF-8?q?=E9=80=9A=E6=9F=A5=E8=AF=A2=E9=80=80=E6=AC=BE=E7=8A=B6=E6=80=81?=
 =?UTF-8?q?=E5=9C=B0=E5=9D=80=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../binarywang/wxpay/service/impl/EcommerceServiceImpl.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 a41ee81b06..67976caf31 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
@@ -226,7 +226,7 @@ public RefundQueryResult queryRefundByRefundId(String subMchid, String refundId)
 
   @Override
   public RefundQueryResult queryRefundByOutRefundNo(String subMchid, String outRefundNo) throws WxPayException {
-    String url = String.format("%s/v3/ecommerce/applyments/out-request-no/%s?sub_mchid=%s", this.payService.getPayBaseUrl(), outRefundNo, subMchid);
+    String url = String.format("%s/v3/ecommerce/refunds/out-refund-no/%s?sub_mchid=%s", this.payService.getPayBaseUrl(), outRefundNo, subMchid);
     String response = this.payService.getV3(URI.create(url));
     return GSON.fromJson(response, RefundQueryResult.class);
   }

From 572c99419cd9a20819cda141d1a56ea273b020be Mon Sep 17 00:00:00 2001
From: hrq 
Date: Fri, 6 Nov 2020 14:22:11 +0800
Subject: [PATCH 6/8] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E9=80=9A=E7=94=A8?=
 =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87=E6=8E=A5=E5=8F=A3=20?=
 =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BD=BF=E7=94=A8=E6=B5=81=E5=8F=82=E6=95=B0?=
 =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../wxpay/service/MerchantMediaService.java   | 15 +++++++++++
 .../impl/MerchantMediaServiceImpl.java        | 25 ++++++++++++++++---
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MerchantMediaService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MerchantMediaService.java
index 429ece394d..0e35dbb68b 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MerchantMediaService.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MerchantMediaService.java
@@ -5,6 +5,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 
 /**
  * 
@@ -27,5 +28,19 @@ public interface MerchantMediaService {
    */
   ImageUploadResult imageUploadV3(File imageFile) throws WxPayException, IOException;
 
+  /**
+   * 
+   * 通用接口-图片上传API
+   * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/tool/chapter3_1.shtml
+   * 接口链接:https://api.mch.weixin.qq.com/v3/merchant/media/upload
+   * 
+ * + * @param inputStream 需要上传的图片文件流 + * @param fileName 需要上传的图片文件名 + * @return ImageUploadResult 微信返回的媒体文件标识Id。示例值:6uqyGjGrCf2GtyXP8bxrbuH9-aAoTjH-rKeSl3Lf4_So6kdkQu4w8BYVP3bzLtvR38lxt4PjtCDXsQpzqge_hQEovHzOhsLleGFQVRF-U_0 + * @throws WxPayException the wx pay exception + */ + ImageUploadResult imageUploadV3(InputStream inputStream, String fileName) throws WxPayException, IOException; + } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MerchantMediaServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MerchantMediaServiceImpl.java index 863b706a28..811d61f6b5 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MerchantMediaServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MerchantMediaServiceImpl.java @@ -9,10 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.net.URI; /** @@ -41,4 +38,24 @@ public ImageUploadResult imageUploadV3(File imageFile) throws WxPayException,IOE } } + @Override + public ImageUploadResult imageUploadV3(InputStream inputStream, String fileName) throws WxPayException, IOException { + String url = String.format("%s/v3/merchant/media/upload", this.payService.getPayBaseUrl()); + try(ByteArrayOutputStream bos = new ByteArrayOutputStream()) { + byte[] buffer = new byte[2048]; + int len; + while ((len = inputStream.read(buffer)) > -1) { + bos.write(buffer, 0, len); + } + bos.flush(); + byte[] data = bos.toByteArray(); + String sha256 = DigestUtils.sha256Hex(data); + WechatPayUploadHttpPost request = new WechatPayUploadHttpPost.Builder(URI.create(url)) + .withImage(fileName, sha256, new ByteArrayInputStream(data)) + .build(); + String result = this.payService.postV3(url, request); + return ImageUploadResult.fromJson(result); + } + } + } From 869ac95842aca22d1c6ee3a1b2711047e216d1a6 Mon Sep 17 00:00:00 2001 From: hrq Date: Mon, 23 Nov 2020 17:15:46 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=B6=E4=BB=98=E9=80=9A=E8=B5=84=E9=87=91=E8=B4=A6=E5=8D=95?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wxpay/bean/ecommerce/FundBillRequest.java | 79 ++++++++++ .../wxpay/bean/ecommerce/FundBillResult.java | 139 ++++++++++++++++++ ...BillRequest.java => TradeBillRequest.java} | 4 +- .../{BillResult.java => TradeBillResult.java} | 4 +- ...illTypeEnum.java => FundBillTypeEnum.java} | 11 +- .../wxpay/service/EcommerceService.java | 20 ++- .../service/impl/EcommerceServiceImpl.java | 13 +- .../binarywang/wxpay/v3/util/AesUtils.java | 35 ++++- ...java => WxPayTradeFundBillResultTest.java} | 2 +- 9 files changed, 284 insertions(+), 23 deletions(-) create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillRequest.java create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillResult.java rename weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/{BillRequest.java => TradeBillRequest.java} (97%) rename weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/{BillResult.java => TradeBillResult.java} (96%) rename weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/{BillTypeEnum.java => FundBillTypeEnum.java} (64%) rename weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/{WxPayBillResultTest.java => WxPayTradeFundBillResultTest.java} (99%) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillRequest.java new file mode 100644 index 0000000000..9f12bc3781 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillRequest.java @@ -0,0 +1,79 @@ +package com.github.binarywang.wxpay.bean.ecommerce; + +import com.google.gson.annotations.SerializedName; +import lombok.*; + +/** + * 资金账单请求 + * @author: f00lish + * @date: 2020/09/28 + */ +@Data +@Builder +@ToString +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class FundBillRequest { + + /** + *
+   * 字段名:账单日期
+   * 变量名:bill_date
+   * 是否必填:是
+   * 类型:string(10)
+   * 描述:
+   *  格式YYYY-MM-DD
+   *  仅支持三个月内的账单下载申请。
+   *  示例值:2019-06-11
+   * 
+ */ + @SerializedName(value = "bill_date") + private String billDate; + + + /** + *
+   * 字段名:资金账户类型
+   * 变量名:account_type
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  枚举值:
+   *  ALL:所有账户
+   *  示例值:ALL
+   * 
+ */ + @SerializedName(value = "account_type") + private String accountType; + + /** + *
+   * 字段名:压缩类型
+   * 变量名:tar_type
+   * 是否必填:否
+   * 类型:string(32)
+   * 描述:
+   *  不填则以不压缩的方式返回数据流
+   *  枚举值:
+   *  GZIP:返回格式为.gzip的压缩包账单
+   *  示例值:GZIP
+   * 
+ */ + @SerializedName(value = "tar_type") + private String tarType; + + /** + *
+   * 字段名:加密算法
+   * 变量名:algorithm
+   * 是否必填:是
+   * 类型:string(32)
+   * 描述:
+   *  枚举值:
+   *  AEAD_AES_256_GCM:AEAD_AES_256_GCM加密算法
+   *  示例值:AEAD_AES_256_GCM
+   * 
+ */ + @SerializedName(value = "algorithm") + private String algorithm; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillResult.java new file mode 100644 index 0000000000..de0dcdb890 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FundBillResult.java @@ -0,0 +1,139 @@ +package com.github.binarywang.wxpay.bean.ecommerce; + +import com.google.gson.annotations.SerializedName; +import lombok.*; + +/** + * 资金账单结果 + * @author: f00lish + * @date: 2020/09/28 + */ +@Data +@Builder +@ToString +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class FundBillResult { + + /** + *
+   * 字段名:下载信息总数
+   * 变量名:download_bill_count
+   * 是否必填:是
+   * 类型:int
+   * 描述:
+   *  下载信息总数
+   *  示例值:1
+   * 
+ */ + @SerializedName(value = "download_bill_count") + private int downloadBillCount; + + + + /** + *
+   * 字段名:下载信息明细
+   * 变量名:download_bill_list
+   * 是否必填:否
+   * 类型:array
+   * 描述:
+   *  下载信息明细
+   * 
+ */ + @SerializedName(value = "download_bill_list") + private FundBill[] downloadBillList; + + @Data + public static class FundBill { + + /** + *
+     * 字段名:账单文件序号
+     * 变量名:bill_sequence
+     * 是否必填:是
+     * 类型:int
+     * 描述:
+     *  商户将多个文件按账单文件序号的顺序合并为完整的资金账单文件,起始值为1
+     *  示例值:1
+     * 
+ */ + @SerializedName(value = "bill_sequence") + private String billSequence; + + /** + *
+     * 字段名:哈希类型
+     * 变量名:hash_type
+     * 是否必填:是
+     * 类型:string(32)
+     * 描述:
+     *  枚举值:
+     *  SHA1:SHA1值
+     *  示例值:SHA1
+     * 
+ */ + @SerializedName(value = "hash_type") + private String hashType; + + /** + *
+     * 字段名:哈希值
+     * 变量名:hash_value
+     * 是否必填:是
+     * 类型:string(1024)
+     * 描述:
+     *  原始账单(gzip需要解压缩)的摘要值,用于校验文件的完整性。
+     *  示例值:79bb0f45fc4c42234a918000b2668d689e2bde04
+     * 
+ */ + @SerializedName(value = "hash_value") + private String hashValue; + + /** + *
+     * 字段名:账单下载地址
+     * 变量名:download_url
+     * 是否必填:是
+     * 类型:string(2048)
+     * 描述:
+     *  供下一步请求账单文件的下载地址,该地址30s内有效。
+     *  示例值:https://api.mch.weixin.qq.com/v3/billdownload/file?token=xxx
+     * 
+ */ + @SerializedName(value = "download_url") + private String downloadUrl; + + + /** + *
+     * 字段名:加密密钥
+     * 变量名:encrypt_key
+     * 是否必填:是
+     * 类型:string(512)
+     * 描述:
+     *  加密账单文件使用的加密密钥。密钥用商户证书的公钥进行加密,然后进行Base64编码
+     *  示例值:YpkbxSne+mDwyXq//xYPmtr9eQ5LsH7zLMZSs+GSEcY4wjhlsfioS4n9X6q1ZBL0wM1v5qd7KhWuj0rFJ4N1FidP7Q8KDy25QDTt46wiKnsPKSCAXWRFNw1D2JmJBqZsc9y5g0DupONWKYB2GfRigRDEBVszj67uOIILPdxOKX1w3N4jvu0U9IFanJa7ldm70KVvYrMWVgQFDPbgjh1gVDbuTAjmPN88AobLdkiegnBUS2woDZW+PfhPo13kweOiR3h1gXIKRlnKnN3Jkkwpna/AFFijXrFphO3voSuiV0CfptfzTtcae4X3DYG3RSroKqmpa+5tuy2aU2VJUSIuFQ==
+     * 
+ */ + @SerializedName(value = "encrypt_key") + private String encryptKey; + + /** + *
+     * 字段名:随机字符串
+     * 变量名:nonce
+     * 是否必填:是
+     * 类型:string(16)
+     * 描述:
+     *  加密账单文件使用的随机字符串
+     *  示例值:a8607ef79034c49c
+     * 
+ */ + @SerializedName(value = "nonce") + private String nonce; + + + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/BillRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillRequest.java similarity index 97% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/BillRequest.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillRequest.java index 247b2a7d01..ad623edf56 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/BillRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillRequest.java @@ -4,7 +4,7 @@ import lombok.*; /** - * 账单请求 + * 交易账单请求 * @author: f00lish * @date: 2020/09/28 */ @@ -13,7 +13,7 @@ @ToString @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class BillRequest { +public class TradeBillRequest { /** *
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/BillResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillResult.java
similarity index 96%
rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/BillResult.java
rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillResult.java
index 4a5bdb9524..2fb7b60564 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/BillResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/TradeBillResult.java
@@ -4,7 +4,7 @@
 import lombok.*;
 
 /**
- * 账单结果
+ * 交易账单结果
  * @author: f00lish
  * @date: 2020/09/28
  */
@@ -13,7 +13,7 @@
 @ToString
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 @AllArgsConstructor(access = AccessLevel.PRIVATE)
-public class BillResult {
+public class TradeBillResult {
 
   /**
    * 
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/BillTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/FundBillTypeEnum.java
similarity index 64%
rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/BillTypeEnum.java
rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/FundBillTypeEnum.java
index 598ee4be4b..72aff3a02b 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/BillTypeEnum.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/enums/FundBillTypeEnum.java
@@ -10,17 +10,16 @@
  */
 @Getter
 @AllArgsConstructor
-public enum BillTypeEnum {
+public enum FundBillTypeEnum {
 
   /**
-   * 交易账单
+   * 资金账单
    */
-  TRADE_BILL("%s/v3/bill/tradebill?%s"),
+  FUND_FLOW_BILL("%s/v3/bill/fundflowbill?%s"),
   /**
-   * 资金账单
+   * 二级商户资金账单
    */
-  FUND_FLOW_BILL("%s/v3/bill/fundflowbill?%s");
-
+  SUB_FUND_FLOW_BILL("%s/v3/ecommerce/bill/fundflowbill?%s");
 
   /**
    * url
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 367f2e8e1e..91c58e7ac3 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
@@ -1,7 +1,7 @@
 package com.github.binarywang.wxpay.service;
 
 import com.github.binarywang.wxpay.bean.ecommerce.*;
-import com.github.binarywang.wxpay.bean.ecommerce.enums.BillTypeEnum;
+import com.github.binarywang.wxpay.bean.ecommerce.enums.FundBillTypeEnum;
 import com.github.binarywang.wxpay.bean.ecommerce.enums.SpAccountTypeEnum;
 import com.github.binarywang.wxpay.bean.ecommerce.enums.TradeTypeEnum;
 import com.github.binarywang.wxpay.exception.WxPayException;
@@ -394,12 +394,24 @@ public interface EcommerceService {
    * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/bill.shtml
    * 
* + * @param request 请求信息。 + * @return 返回数据 return trade bill result + * @throws WxPayException the wx pay exception + */ + TradeBillResult applyBill(TradeBillRequest request) throws WxPayException; + + /** + *
+   * 申请资金账单API
+   * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/bill/chapter3_2.shtml
+   * 
+ * * @param billType 账单类型。 - * @param request 二级商户号。 - * @return 返回数据 return bill result + * @param request 请求信息。 + * @return 返回数据 return fund bill result * @throws WxPayException the wx pay exception */ - BillResult applyBill(BillTypeEnum billType, BillRequest request) throws WxPayException; + FundBillResult applyFundBill(FundBillTypeEnum billType, FundBillRequest request) throws WxPayException; /** *
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 67976caf31..58a02d8ff8 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
@@ -1,7 +1,7 @@
 package com.github.binarywang.wxpay.service.impl;
 
 import com.github.binarywang.wxpay.bean.ecommerce.*;
-import com.github.binarywang.wxpay.bean.ecommerce.enums.BillTypeEnum;
+import com.github.binarywang.wxpay.bean.ecommerce.enums.FundBillTypeEnum;
 import com.github.binarywang.wxpay.bean.ecommerce.enums.SpAccountTypeEnum;
 import com.github.binarywang.wxpay.bean.ecommerce.enums.TradeTypeEnum;
 import com.github.binarywang.wxpay.exception.WxPayException;
@@ -295,10 +295,17 @@ public SettlementResult querySettlement(String subMchid) throws WxPayException {
   }
 
   @Override
-  public BillResult applyBill(BillTypeEnum billType, BillRequest request) throws WxPayException {
+  public TradeBillResult applyBill(TradeBillRequest request) throws WxPayException {
+    String url = String.format("%s/v3/bill/tradebill?%s", this.payService.getPayBaseUrl(), this.parseURLPair(request));
+    String response = this.payService.getV3(URI.create(url));
+    return GSON.fromJson(response, TradeBillResult.class);
+  }
+
+  @Override
+  public FundBillResult applyFundBill(FundBillTypeEnum billType, FundBillRequest request) throws WxPayException {
     String url = String.format(billType.getUrl(), this.payService.getPayBaseUrl(), this.parseURLPair(request));
     String response = this.payService.getV3(URI.create(url));
-    return GSON.fromJson(response, BillResult.class);
+    return GSON.fromJson(response, FundBillResult.class);
   }
 
   @Override
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/AesUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/AesUtils.java
index 4030965ebe..2c8c40252f 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/AesUtils.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/AesUtils.java
@@ -4,6 +4,11 @@
 import com.google.common.io.BaseEncoding;
 import org.apache.commons.lang3.StringUtils;
 
+import javax.crypto.Cipher;
+import javax.crypto.Mac;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.GCMParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
 import java.io.IOException;
 import java.security.GeneralSecurityException;
 import java.security.InvalidAlgorithmParameterException;
@@ -13,11 +18,6 @@
 import java.util.Map;
 import java.util.SortedMap;
 import java.util.TreeMap;
-import javax.crypto.Cipher;
-import javax.crypto.Mac;
-import javax.crypto.NoSuchPaddingException;
-import javax.crypto.spec.GCMParameterSpec;
-import javax.crypto.spec.SecretKeySpec;
 
 public class AesUtils {
 
@@ -32,6 +32,31 @@ public AesUtils(byte[] key) {
     this.aesKey = key;
   }
 
+  public static byte[] decryptToByte(byte[] nonce, byte[] cipherData, byte[] key)
+    throws GeneralSecurityException {
+    return decryptToByte(null, nonce, cipherData, key);
+  }
+
+  public static byte[] decryptToByte(byte[] associatedData, byte[] nonce, byte[] cipherData, byte[] key)
+    throws GeneralSecurityException {
+    try {
+      Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
+
+      SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES");
+      GCMParameterSpec spec = new GCMParameterSpec(TAG_LENGTH_BIT, nonce);
+
+      cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, spec);
+      if (associatedData != null) {
+        cipher.updateAAD(associatedData);
+      }
+      return cipher.doFinal(cipherData);
+    } catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
+      throw new IllegalStateException(e);
+    } catch (InvalidKeyException | InvalidAlgorithmParameterException e) {
+      throw new IllegalArgumentException(e);
+    }
+  }
+
   public String decryptToString(byte[] associatedData, byte[] nonce, String ciphertext)
       throws GeneralSecurityException, IOException {
     try {
diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxPayBillResultTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxPayTradeFundBillResultTest.java
similarity index 99%
rename from weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxPayBillResultTest.java
rename to weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxPayTradeFundBillResultTest.java
index 6d5d322602..f6d8271b3d 100644
--- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxPayBillResultTest.java
+++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxPayTradeFundBillResultTest.java
@@ -9,7 +9,7 @@
 /**
  * @author m8cool
  */
-public class WxPayBillResultTest {
+public class WxPayTradeFundBillResultTest {
   private static final String PAY_BILL_RESULT_ALL_CONTENT = "交易时间,公众账号ID,商户号,特约商户号,设备号,微信订单号,商户订单号,用户标识,交易类型,交易状态,付款银行,货币种类,应结订单金额,代金券金额,微信退款单号,商户退款单号,退款金额,充值券退款金额,退款类型,退款状态,商品名称,商户数据包,手续费,费率,订单金额,申请退款金额,费率备注\n" +
     "`2019-07-25 08:35:41,`WWWW,`XXXXXXXX,`0,`,`XXXXXXXXXXXXX,`XXXXXXXXXX,`XXXXXXXXXXX,`JSAPI,`SUCCESS,`PSBC_DEBIT,`CNY,`6.00,`0.00,`0,`0,`0.00,`0.00,`,`,`XXXXXX,`XXXXXXX,`0.04000,`0.60%,`6.00,`0.00,`\n" +
     "总交易单数,应结订单总金额,退款总金额,充值券退款总金额,手续费总金额,订单总金额,申请退款总金额\n" +

From d0c46680f8ebca17096ddc99ae503293e6f4fb6f Mon Sep 17 00:00:00 2001
From: hrq 
Date: Mon, 23 Nov 2020 18:02:37 +0800
Subject: [PATCH 8/8] =?UTF-8?q?fix=20=E6=9B=B4=E6=96=B0=E5=BE=AE=E4=BF=A1?=
 =?UTF-8?q?=E6=94=B6=E4=BB=98=E9=80=9A=E8=B4=A6=E5=8D=95=E6=8E=A5=E5=8F=A3?=
 =?UTF-8?q?=E6=97=B6=20=E8=AF=AF=E6=93=8D=E4=BD=9C=E6=94=B9=E5=90=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../wxpay/bean/result/WxPayTradeFundBillResultTest.java         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxPayTradeFundBillResultTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxPayTradeFundBillResultTest.java
index f6d8271b3d..6d5d322602 100644
--- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxPayTradeFundBillResultTest.java
+++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxPayTradeFundBillResultTest.java
@@ -9,7 +9,7 @@
 /**
  * @author m8cool
  */
-public class WxPayTradeFundBillResultTest {
+public class WxPayBillResultTest {
   private static final String PAY_BILL_RESULT_ALL_CONTENT = "交易时间,公众账号ID,商户号,特约商户号,设备号,微信订单号,商户订单号,用户标识,交易类型,交易状态,付款银行,货币种类,应结订单金额,代金券金额,微信退款单号,商户退款单号,退款金额,充值券退款金额,退款类型,退款状态,商品名称,商户数据包,手续费,费率,订单金额,申请退款金额,费率备注\n" +
     "`2019-07-25 08:35:41,`WWWW,`XXXXXXXX,`0,`,`XXXXXXXXXXXXX,`XXXXXXXXXX,`XXXXXXXXXXX,`JSAPI,`SUCCESS,`PSBC_DEBIT,`CNY,`6.00,`0.00,`0,`0,`0.00,`0.00,`,`,`XXXXXX,`XXXXXXX,`0.04000,`0.60%,`6.00,`0.00,`\n" +
     "总交易单数,应结订单总金额,退款总金额,充值券退款总金额,手续费总金额,订单总金额,申请退款总金额\n" +