mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
:new:【微信支付】增加品牌红包商家转账到零钱发放、查询批次、查询明细等接口
This commit is contained in:
@@ -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>
|
||||
* 适用对象:直连商户
|
||||
* 文档详见:
|
||||
* 请求URL:https://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>
|
||||
* 适用对象:直连商户
|
||||
* 文档详见:
|
||||
* 请求URL:https://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>
|
||||
* 适用对象:直连商户
|
||||
* 文档详见:
|
||||
* 请求URL:https://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>
|
||||
* 适用对象:直连商户
|
||||
* 文档详见:
|
||||
* 请求URL:https://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>
|
||||
* 适用对象:直连商户
|
||||
* 文档详见:
|
||||
* 请求URL:https://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;
|
||||
|
||||
|
||||
}
|
||||
@@ -311,6 +311,13 @@ public interface WxPayService {
|
||||
*/
|
||||
MerchantTransferService getMerchantTransferService();
|
||||
|
||||
/**
|
||||
* 获取品牌红包商家转账到零钱服务类
|
||||
*
|
||||
* @return the brand merchant transfer service
|
||||
*/
|
||||
BrandMerchantTransferService getBrandMerchantTransferService();
|
||||
|
||||
/**
|
||||
* 设置企业付款服务类,允许开发者自定义实现类.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user