Commit e7ef83db7ae13b95332576d829839820813ed522
Committed by
Gitee
!1113 【新增功能】微信转账到零钱:主动查询转账状态
Merge pull request !1113 from 杨宇庆/N/A
Showing
1 changed file
with
24 additions
and
3 deletions
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java
| @@ -24,6 +24,8 @@ import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; | @@ -24,6 +24,8 @@ import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; | ||
| 24 | import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyV3Result; | 24 | import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyV3Result; |
| 25 | import com.github.binarywang.wxpay.bean.request.*; | 25 | import com.github.binarywang.wxpay.bean.request.*; |
| 26 | import com.github.binarywang.wxpay.bean.result.*; | 26 | import com.github.binarywang.wxpay.bean.result.*; |
| 27 | +import com.github.binarywang.wxpay.bean.transfer.QueryTransferBatchesRequest; | ||
| 28 | +import com.github.binarywang.wxpay.bean.transfer.QueryTransferBatchesResult; | ||
| 27 | import com.github.binarywang.wxpay.bean.transfer.TransferBatchesRequest; | 29 | import com.github.binarywang.wxpay.bean.transfer.TransferBatchesRequest; |
| 28 | import com.github.binarywang.wxpay.bean.transfer.TransferBatchesResult; | 30 | import com.github.binarywang.wxpay.bean.transfer.TransferBatchesResult; |
| 29 | import com.github.binarywang.wxpay.config.WxPayConfig; | 31 | import com.github.binarywang.wxpay.config.WxPayConfig; |
| @@ -484,9 +486,28 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC | @@ -484,9 +486,28 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC | ||
| 484 | } | 486 | } |
| 485 | 487 | ||
| 486 | @Override | 488 | @Override |
| 487 | - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) { | ||
| 488 | - // TODO luchi:这个最好实现下。因为可能要主动轮询转账结果 | ||
| 489 | - throw new UnsupportedOperationException("待实现"); | 489 | + protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) throws WxPayException { |
| 490 | + QueryTransferBatchesRequest request = QueryTransferBatchesRequest.newBuilder() | ||
| 491 | + .outBatchNo(outTradeNo).needQueryDetail(true).offset(0).limit(20).detailStatus("ALL") | ||
| 492 | + .build(); | ||
| 493 | + QueryTransferBatchesResult response = client.getTransferService().transferBatchesOutBatchNo(request); | ||
| 494 | + QueryTransferBatchesResult.TransferBatch transferBatch = response.getTransferBatch(); | ||
| 495 | + if (Objects.equals("FINISHED", transferBatch.getBatchStatus())) { | ||
| 496 | + // 明细中全部成功则成功,任一失败则失败 | ||
| 497 | + if (response.getTransferDetailList().stream().allMatch(detail -> Objects.equals("SUCCESS", detail.getDetailStatus()))) { | ||
| 498 | + return PayTransferRespDTO.successOf(transferBatch.getBatchId(), parseDateV3(transferBatch.getUpdateTime()), | ||
| 499 | + transferBatch.getOutBatchNo(), response); | ||
| 500 | + } | ||
| 501 | + if (response.getTransferDetailList().stream().anyMatch(detail -> Objects.equals("FAIL", detail.getDetailStatus()))) { | ||
| 502 | + return PayTransferRespDTO.closedOf(transferBatch.getBatchStatus(), transferBatch.getCloseReason(), | ||
| 503 | + transferBatch.getOutBatchNo(), response); | ||
| 504 | + } | ||
| 505 | + } | ||
| 506 | + if (Objects.equals("CLOSED", transferBatch.getBatchStatus())) { | ||
| 507 | + return PayTransferRespDTO.closedOf(transferBatch.getBatchStatus(), transferBatch.getCloseReason(), | ||
| 508 | + transferBatch.getOutBatchNo(), response); | ||
| 509 | + } | ||
| 510 | + return PayTransferRespDTO.dealingOf(transferBatch.getBatchId(), transferBatch.getOutBatchNo(), response); | ||
| 490 | } | 511 | } |
| 491 | 512 | ||
| 492 | // ========== 各种工具方法 ========== | 513 | // ========== 各种工具方法 ========== |