mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-04 04:37:46 +08:00
🆕 #3023 【微信支付】增加根据账户类型查询二级商户实时余额的接口,同时修复批量转账订单相关接口的问题
This commit is contained in:
parent
1583aaf014
commit
0640c10671
@ -215,6 +215,19 @@ public interface EcommerceService {
|
||||
*/
|
||||
FundBalanceResult subNowBalance(String subMchid) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 二级商户号账户实时余额
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_3_11.shtml
|
||||
* </pre>
|
||||
*
|
||||
* @param subMchid 二级商户号
|
||||
* @param accountType 账户类型
|
||||
* @return 返回数据 fund balance result
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
FundBalanceResult subNowBalance(String subMchid, SpAccountTypeEnum accountType) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 二级商户号账户日终余额
|
||||
|
@ -26,11 +26,7 @@ import java.lang.reflect.Method;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class EcommerceServiceImpl implements EcommerceService {
|
||||
@ -188,6 +184,16 @@ public class EcommerceServiceImpl implements EcommerceService {
|
||||
return GSON.fromJson(response, FundBalanceResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FundBalanceResult subNowBalance(String subMchid, SpAccountTypeEnum accountType) throws WxPayException {
|
||||
String url = String.format("%s/v3/ecommerce/fund/balance/%s", this.payService.getPayBaseUrl(), subMchid);
|
||||
if (Objects.nonNull(accountType)) {
|
||||
url += "?account_type=" + accountType.getValue();
|
||||
}
|
||||
String response = this.payService.getV3(url);
|
||||
return GSON.fromJson(response, FundBalanceResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FundBalanceResult subDayEndBalance(String subMchid, String date) throws WxPayException {
|
||||
String url = String.format("%s/v3/ecommerce/fund/enddaybalance/%s?date=%s", this.payService.getPayBaseUrl(), subMchid, date);
|
||||
|
@ -43,13 +43,19 @@ public class PartnerTransferServiceImpl implements PartnerTransferService {
|
||||
*/
|
||||
@Override
|
||||
public PartnerTransferResult batchTransfer(PartnerTransferRequest request) throws WxPayException {
|
||||
request.getTransferDetailList().stream().forEach(p -> {
|
||||
request.getTransferDetailList().forEach(p -> {
|
||||
try {
|
||||
String userName = RsaCryptoUtil.encryptOAEP(p.getUserName(),
|
||||
this.payService.getConfig().getVerifier().getValidCertificate());
|
||||
p.setUserName(userName);
|
||||
|
||||
if (StringUtil.isNotBlank(p.getUserIdCard())) {
|
||||
String userIdCard = RsaCryptoUtil.encryptOAEP(p.getUserIdCard(),
|
||||
this.payService.getConfig().getVerifier().getValidCertificate());
|
||||
p.setUserIdCard(userIdCard);
|
||||
}
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
throw new RuntimeException("姓名转换异常!", e);
|
||||
throw new RuntimeException("姓名或身份证转换异常!", e);
|
||||
}
|
||||
});
|
||||
String url = String.format("%s/v3/partner-transfer/batches", this.payService.getPayBaseUrl());
|
||||
@ -81,11 +87,10 @@ public class PartnerTransferServiceImpl implements PartnerTransferService {
|
||||
if (request.getLimit() == null || request.getLimit() <= 0) {
|
||||
request.setLimit(20);
|
||||
}
|
||||
String query = String.format("?need_query_detail=%s&detail_status=ALL&offset=%s&limit=%s",
|
||||
request.getNeedQueryDetail(), request.getOffset(), request.getLimit());
|
||||
if (StringUtil.isNotBlank(request.getDetailStatus())) {
|
||||
query += "&detail_status=" + request.getDetailStatus();
|
||||
}
|
||||
String detailStatus = StringUtil.isNotBlank(request.getDetailStatus()) ? request.getDetailStatus() : "ALL";
|
||||
|
||||
String query = String.format("?need_query_detail=%s&detail_status=%s&offset=%s&limit=%s",
|
||||
request.getNeedQueryDetail(), detailStatus, request.getOffset(), request.getLimit());
|
||||
String response = this.payService.getV3(url + query);
|
||||
return GSON.fromJson(response, BatchNumberResult.class);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.github.binarywang.wxpay.bean.ecommerce.ProfitSharingReceiverRequest;
|
||||
import com.github.binarywang.wxpay.bean.ecommerce.ProfitSharingReceiverResult;
|
||||
import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader;
|
||||
import com.github.binarywang.wxpay.bean.ecommerce.TransactionsResult;
|
||||
import com.github.binarywang.wxpay.bean.ecommerce.enums.SpAccountTypeEnum;
|
||||
import com.github.binarywang.wxpay.bean.ecommerce.enums.TradeTypeEnum;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
@ -125,6 +126,12 @@ public class EcommerceServiceImplTest {
|
||||
wxPayService.getEcommerceService().subNowBalance(subMchid);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubNowBalanceWithAccountType() throws WxPayException {
|
||||
String subMchid = "";
|
||||
wxPayService.getEcommerceService().subNowBalance(subMchid, SpAccountTypeEnum.BASIC);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddReceivers() throws WxPayException {
|
||||
ProfitSharingReceiverRequest request = new ProfitSharingReceiverRequest();
|
||||
|
Loading…
Reference in New Issue
Block a user