:new:【微信支付】增加品牌红包商家转账到零钱发放、查询批次、查询明细等接口

This commit is contained in:
墨染
2023-02-21 08:15:52 +00:00
committed by binarywang
parent 26057b0844
commit 87322e6d78
13 changed files with 1453 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
package com.github.binarywang.wxpay.service;
import com.github.binarywang.wxpay.bean.brandmerchanttransfer.request.*;
import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandBatchesQueryResult;
import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandDetailsQueryResult;
import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandTransferBatchesResult;
import com.github.binarywang.wxpay.exception.WxPayException;
/**
* 品牌商户发放红包商家转账到零钱(直联商户)
*
* @author moran
*/
public interface BrandMerchantTransferService {
/**
* 品牌商户发放红包API
* <p>
* 适用对象:直连商户
* 文档详见:
* 请求URLhttps://api.mch.weixin.qq.com/v3/fund-app/brand-redpacket/brand-merchant-batches
* 请求方式POST
* 接口限频: 单个商户 50QPS如果超过频率限制会报错FREQUENCY_LIMITED请降低频率请求。
* 是否需要证书:是
*
* @param request the request
* @return transfer create result
* @throws WxPayException the wx pay exception
*/
BrandTransferBatchesResult createBrandTransfer(BrandTransferBatchesRequest request) throws WxPayException;
/**
* 品牌红包微信批次单号查询批次单API
* <p>
* 适用对象:直连商户
* 文档详见:
* 请求URLhttps://api.mch.weixin.qq.com/v3/fund-app/brand-redpacket/brand-merchant-batches/{batch_no}
* 请求方式GET
* 接口限频: 单个商户 50QPS如果超过频率限制会报错FREQUENCY_LIMITED请降低频率请求。
*
* @param request the request
* @return batches query result
* @throws WxPayException the wx pay exception
*/
BrandBatchesQueryResult queryBrandWxBatches(BrandWxBatchesQueryRequest request) throws WxPayException;
/**
* 品牌红包微信支付明细单号查询明细单API
* <p>
* 适用对象:直连商户
* 文档详见:
* 请求URLhttps://api.mch.weixin.qq.com/v3/fund-app/brand-redpacket/brand-merchant-batches/{batch_no}/details/{detail_no}
* 请求方式GET
* 接口限频: 单个商户 50QPS如果超过频率限制会报错FREQUENCY_LIMITED请降低频率请求。
*
* @param request the request
* @return details query result
* @throws WxPayException the wx pay exception
*/
BrandDetailsQueryResult queryBrandWxDetails(BrandWxDetailsQueryRequest request) throws WxPayException;
/**
* 品牌红包商家批次单号查询批次单API
* <p>
* 适用对象:直连商户
* 文档详见:
* 请求URLhttps://api.mch.weixin.qq.com/v3/fund-app/brand-redpacket/brand-merchant-out-batches/{out_batch_no}
* 请求方式GET
* 接口限频: 单个商户 50QPS如果超过频率限制会报错FREQUENCY_LIMITED请降低频率请求。
*
* @param request the request
* @return batches query result
* @throws WxPayException the wx pay exception
*/
BrandBatchesQueryResult queryBrandMerchantBatches(BrandMerchantBatchesQueryRequest request) throws WxPayException;
/**
* 品牌红包商家明细单号查询明细单API
* <p>
* 适用对象:直连商户
* 文档详见:
* 请求URLhttps://api.mch.weixin.qq.com/v3/fund-app/brand-redpacket/brand-merchant-out-batches/{out_batch_no}/out-details/{out_detail_no}
* 请求方式GET
* 接口限频: 单个商户 50QPS如果超过频率限制会报错FREQUENCY_LIMITED请降低频率请求。
*
* @param request the request
* @return details query result
* @throws WxPayException the wx pay exception
*/
BrandDetailsQueryResult queryBrandMerchantDetails(BrandMerchantDetailsQueryRequest request) throws WxPayException;
}

View File

@@ -311,6 +311,13 @@ public interface WxPayService {
*/
MerchantTransferService getMerchantTransferService();
/**
* 获取品牌红包商家转账到零钱服务类
*
* @return the brand merchant transfer service
*/
BrandMerchantTransferService getBrandMerchantTransferService();
/**
* 设置企业付款服务类,允许开发者自定义实现类.
*

View File

@@ -124,6 +124,9 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
@Getter
private final MerchantTransferService merchantTransferService = new MerchantTransferServiceImpl(this);
@Getter
private final BrandMerchantTransferService brandMerchantTransferService = new BrandMerchantTransferServiceImpl(this);
protected Map<String, WxPayConfig> configMap;
@Override

View File

@@ -0,0 +1,87 @@
package com.github.binarywang.wxpay.service.impl;
import com.github.binarywang.wxpay.bean.brandmerchanttransfer.request.*;
import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandBatchesQueryResult;
import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandDetailsQueryResult;
import com.github.binarywang.wxpay.bean.brandmerchanttransfer.result.BrandTransferBatchesResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.BrandMerchantTransferService;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.v3.util.RsaCryptoUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* 品牌商户发放红包商家转账到零钱(直联商户)实现
*
* @author moran
*/
@Slf4j
@RequiredArgsConstructor
public class BrandMerchantTransferServiceImpl implements BrandMerchantTransferService {
private static final Gson GSON = (new GsonBuilder()).create();
private final WxPayService wxPayService;
@Override
public BrandTransferBatchesResult createBrandTransfer(BrandTransferBatchesRequest request) throws WxPayException {
String url = String.format("%s/v3/fund-app/brand-redpacket/brand-merchant-batches", this.wxPayService.getPayBaseUrl());
RsaCryptoUtil.encryptFields(request, this.wxPayService.getConfig().getVerifier().getValidCertificate());
String response = wxPayService.postV3WithWechatpaySerial(url, GSON.toJson(request));
return GSON.fromJson(response, BrandTransferBatchesResult.class);
}
@Override
public BrandBatchesQueryResult queryBrandWxBatches(BrandWxBatchesQueryRequest request) throws WxPayException {
String url = String.format("%s/v3/fund-app/brand-redpacket/brand-merchant-batches/%s",
this.wxPayService.getPayBaseUrl(), request.getBatchNo());
if (request.getNeedQueryDetail() != null) {
url = String.format("%s?need_query_detail=%b", url, request.getNeedQueryDetail());
}
if (request.getDetailState() != null && request.getDetailState().length() != 0) {
url = String.format("%s&detail_state=%s", url, request.getDetailState());
}
String response = wxPayService.getV3(url);
return GSON.fromJson(response, BrandBatchesQueryResult.class);
}
@Override
public BrandDetailsQueryResult queryBrandWxDetails(BrandWxDetailsQueryRequest request) throws WxPayException {
String url = String.format("%s/v3/fund-app/brand-redpacket/brand-merchant-batches/%s/details/%s",
this.wxPayService.getPayBaseUrl(), request.getBatchNo(), request.getDetailNo());
String response = wxPayService.getV3(url);
return GSON.fromJson(response, BrandDetailsQueryResult.class);
}
@Override
public BrandBatchesQueryResult queryBrandMerchantBatches(BrandMerchantBatchesQueryRequest request) throws WxPayException {
String url = String.format("%s/v3/fund-app/brand-redpacket/brand-merchant-out-batches/%s",
this.wxPayService.getPayBaseUrl(), request.getOutBatchNo());
if (request.getNeedQueryDetail() != null) {
url = String.format("%s?need_query_detail=%b", url, request.getNeedQueryDetail());
}
if (request.getDetailState() != null && request.getDetailState().length() != 0) {
url = String.format("%s&detail_state=%s", url, request.getDetailState());
}
String response = wxPayService.getV3(url);
return GSON.fromJson(response, BrandBatchesQueryResult.class);
}
@Override
public BrandDetailsQueryResult queryBrandMerchantDetails(BrandMerchantDetailsQueryRequest request) throws WxPayException {
String url = String.format("%s/v3/fund-app/brand-redpacket/brand-merchant-out-batches/%s/out-details/%s",
this.wxPayService.getPayBaseUrl(), request.getOutBatchNo(), request.getOutDetailNo());
String response = wxPayService.getV3(url);
return GSON.fromJson(response, BrandDetailsQueryResult.class);
}
}