1
0
mirror of synced 2026-10-12 18:23:06 +08:00

🎨 #4018 【微信支付】为直连商户补齐“用户授权免确认模式”转账接口能力

This commit is contained in:
Copilot
2026-05-27 20:50:32 +08:00
committed by GitHub
parent 3f517d10e8
commit da27a75950
3 changed files with 180 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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 class MerchantTransferServiceImpl implements MerchantTransferService {
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);
}
}

View File

@@ -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 class MerchantTransferServiceImplTest {
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");
}
}