From 7ff4b9458c44e2d36c84472c77f0e64247cccf4e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 11:50:14 +0000 Subject: [PATCH 1/2] Initial plan From 9140bfd2ca0395815ddb4de43a0061757ec5dbf2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 11:57:53 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=95=86=E5=AE=B6?= =?UTF-8?q?=E8=BD=AC=E8=B4=A6=E5=85=8D=E7=A1=AE=E8=AE=A4=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E6=8E=A5=E5=8F=A3=E5=B9=B6=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MerchantTransferService.java | 88 +++++++++++++++++++ .../impl/MerchantTransferServiceImpl.java | 42 +++++++++ .../impl/MerchantTransferServiceImplTest.java | 50 +++++++++++ 3 files changed, 180 insertions(+) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MerchantTransferService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MerchantTransferService.java index 3b6c19cc9c..5919968618 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MerchantTransferService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MerchantTransferService.java @@ -1,6 +1,12 @@ package com.github.binarywang.wxpay.service; +import com.github.binarywang.wxpay.bean.notify.SignatureHeader; import com.github.binarywang.wxpay.bean.merchanttransfer.*; +import com.github.binarywang.wxpay.bean.transfer.ReservationTransferBatchGetResult; +import com.github.binarywang.wxpay.bean.transfer.ReservationTransferBatchRequest; +import com.github.binarywang.wxpay.bean.transfer.ReservationTransferBatchResult; +import com.github.binarywang.wxpay.bean.transfer.ReservationTransferNotifyResult; +import com.github.binarywang.wxpay.bean.transfer.UserAuthorizationStatusResult; import com.github.binarywang.wxpay.exception.WxPayException; /** @@ -147,4 +153,86 @@ public interface MerchantTransferService { * @throws WxPayException the wx pay exception */ DetailElectronicBillResult queryDetailElectronicBill(DetailElectronicBillRequest request) throws WxPayException; + + /** + * 商户查询用户授权信息接口. + * + * 文档详见: https://pay.weixin.qq.com/doc/v3/merchant/4014399293 + * 请求URL:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/authorization/openid/{openid} + * + * @param openid 用户在直连商户应用下的用户标识 + * @param transferSceneId 转账场景ID + * @return 用户授权信息 + * @throws WxPayException the wx pay exception + */ + UserAuthorizationStatusResult getUserAuthorizationStatus(String openid, String transferSceneId) throws WxPayException; + + /** + * 批量预约商家转账接口. + * + * 文档详见: https://pay.weixin.qq.com/doc/v3/merchant/4014399293 + * 请求URL:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/reservation/transfer-batches + * + * @param request 批量预约商家转账请求参数 + * @return 批量预约商家转账结果 + * @throws WxPayException the wx pay exception + */ + ReservationTransferBatchResult reservationTransferBatch(ReservationTransferBatchRequest request) throws WxPayException; + + /** + * 商户预约批次单号查询批次单接口. + * + * 文档详见: https://pay.weixin.qq.com/doc/v3/merchant/4014399293 + * 请求URL:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/reservation/transfer-batches/out-batch-no/{out_batch_no} + * + * @param outBatchNo 商户预约批次单号 + * @param needQueryDetail 是否需要查询明细 + * @param offset 分页偏移量 + * @param limit 分页大小 + * @param detailState 明细状态(PROCESSING/SUCCESS/FAIL) + * @return 批量预约商家转账批次查询结果 + * @throws WxPayException the wx pay exception + */ + ReservationTransferBatchGetResult getReservationTransferBatchByOutBatchNo(String outBatchNo, Boolean needQueryDetail, + Integer offset, Integer limit, String detailState) throws WxPayException; + + /** + * 微信预约批次单号查询批次单接口. + * + * 文档详见: https://pay.weixin.qq.com/doc/v3/merchant/4014399293 + * 请求URL:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/reservation/transfer-batches/reservation-batch-no/{reservation_batch_no} + * + * @param reservationBatchNo 微信预约批次单号 + * @param needQueryDetail 是否需要查询明细 + * @param offset 分页偏移量 + * @param limit 分页大小 + * @param detailState 明细状态(PROCESSING/SUCCESS/FAIL) + * @return 批量预约商家转账批次查询结果 + * @throws WxPayException the wx pay exception + */ + ReservationTransferBatchGetResult getReservationTransferBatchByReservationBatchNo(String reservationBatchNo, Boolean needQueryDetail, + Integer offset, Integer limit, String detailState) throws WxPayException; + + /** + * 解析预约商家转账通知回调结果. + * + * 文档详见: https://pay.weixin.qq.com/doc/v3/merchant/4014399293 + * + * @param notifyData 通知数据 + * @param header 通知头部数据,不传则表示不校验头 + * @return 预约商家转账通知结果 + * @throws WxPayException the wx pay exception + */ + ReservationTransferNotifyResult parseReservationTransferNotifyResult(String notifyData, SignatureHeader header) throws WxPayException; + + /** + * 关闭预约商家转账批次接口. + * + * 文档详见: https://pay.weixin.qq.com/doc/v3/merchant/4014399293 + * 请求URL:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/reservation/transfer-batches/out-batch-no/{out_batch_no}/close + * + * @param outBatchNo 商户预约批次单号 + * @throws WxPayException the wx pay exception + */ + void closeReservationTransferBatch(String outBatchNo) throws WxPayException; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImpl.java index df4b36fdb9..2d6becb479 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImpl.java @@ -1,6 +1,12 @@ package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.merchanttransfer.*; +import com.github.binarywang.wxpay.bean.notify.SignatureHeader; +import com.github.binarywang.wxpay.bean.transfer.ReservationTransferBatchGetResult; +import com.github.binarywang.wxpay.bean.transfer.ReservationTransferBatchRequest; +import com.github.binarywang.wxpay.bean.transfer.ReservationTransferBatchResult; +import com.github.binarywang.wxpay.bean.transfer.ReservationTransferNotifyResult; +import com.github.binarywang.wxpay.bean.transfer.UserAuthorizationStatusResult; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.MerchantTransferService; import com.github.binarywang.wxpay.service.WxPayService; @@ -125,4 +131,40 @@ public DetailElectronicBillResult queryDetailElectronicBill(DetailElectronicBill return GSON.fromJson(response, DetailElectronicBillResult.class); } + @Override + public UserAuthorizationStatusResult getUserAuthorizationStatus(String openid, String transferSceneId) throws WxPayException { + return this.wxPayService.getTransferService().getUserAuthorizationStatus(openid, transferSceneId); + } + + @Override + public ReservationTransferBatchResult reservationTransferBatch(ReservationTransferBatchRequest request) throws WxPayException { + return this.wxPayService.getTransferService().reservationTransferBatch(request); + } + + @Override + public ReservationTransferBatchGetResult getReservationTransferBatchByOutBatchNo(String outBatchNo, Boolean needQueryDetail, + Integer offset, Integer limit, String detailState) throws WxPayException { + return this.wxPayService.getTransferService() + .getReservationTransferBatchByOutBatchNo(outBatchNo, needQueryDetail, offset, limit, detailState); + } + + @Override + public ReservationTransferBatchGetResult getReservationTransferBatchByReservationBatchNo(String reservationBatchNo, + Boolean needQueryDetail, + Integer offset, Integer limit, + String detailState) throws WxPayException { + return this.wxPayService.getTransferService() + .getReservationTransferBatchByReservationBatchNo(reservationBatchNo, needQueryDetail, offset, limit, detailState); + } + + @Override + public ReservationTransferNotifyResult parseReservationTransferNotifyResult(String notifyData, SignatureHeader header) throws WxPayException { + return this.wxPayService.getTransferService().parseReservationTransferNotifyResult(notifyData, header); + } + + @Override + public void closeReservationTransferBatch(String outBatchNo) throws WxPayException { + this.wxPayService.getTransferService().closeReservationTransferBatch(outBatchNo); + } + } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImplTest.java index d578fcab93..838cd512aa 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImplTest.java @@ -1,6 +1,7 @@ package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.merchanttransfer.*; +import com.github.binarywang.wxpay.bean.transfer.ReservationTransferBatchRequest; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; @@ -107,4 +108,53 @@ public void queryDetailElectronicBill() throws WxPayException { log.info(result.toString()); } + @Test + public void getUserAuthorizationStatus() throws WxPayException { + log.info("查询用户授权信息:{}", + wxPayService.getMerchantTransferService().getUserAuthorizationStatus("or1b65DLMUir7F-_vLwKlutmm3qw", "1005")); + } + + @Test + public void reservationTransferBatch() throws WxPayException { + String requestParamStr = "{\n" + + " \"appid\": \"wxf636efh5xxxxx\",\n" + + " \"out_batch_no\": \"RESERVATION_1655447999520\",\n" + + " \"batch_name\": \"预约测试批次\",\n" + + " \"batch_remark\": \"预约测试批次备注\",\n" + + " \"total_amount\": 100,\n" + + " \"total_num\": 1,\n" + + " \"transfer_scene_id\": \"1005\",\n" + + " \"transfer_detail_list\": [\n" + + " {\n" + + " \"out_detail_no\": \"RESERVATION_DETAIL_1655447989156\",\n" + + " \"transfer_amount\": 100,\n" + + " \"transfer_remark\": \"预约测试转账\",\n" + + " \"openid\": \"or1b65DLMUir7F-_vLwKlutmm3qw\"\n" + + " }\n" + + " ]\n" + + "}"; + ReservationTransferBatchRequest request = GSON.fromJson(requestParamStr, ReservationTransferBatchRequest.class); + log.info("发起预约商家转账:{}", + wxPayService.getMerchantTransferService().reservationTransferBatch(request)); + } + + @Test + public void getReservationTransferBatchByOutBatchNo() throws WxPayException { + log.info("商户预约批次单号查询批次单:{}", + wxPayService.getMerchantTransferService().getReservationTransferBatchByOutBatchNo("RESERVATION_1655447999520", + true, 0, 20, "PROCESSING")); + } + + @Test + public void getReservationTransferBatchByReservationBatchNo() throws WxPayException { + log.info("微信预约批次单号查询批次单:{}", + wxPayService.getMerchantTransferService().getReservationTransferBatchByReservationBatchNo("12345678901234567890123456789012", + true, 0, 20, "PROCESSING")); + } + + @Test + public void closeReservationTransferBatch() throws WxPayException { + wxPayService.getMerchantTransferService().closeReservationTransferBatch("RESERVATION_1655447999520"); + } + }