mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-07 14:17:47 +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;
|
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>
|
* <pre>
|
||||||
* 二级商户号账户日终余额
|
* 二级商户号账户日终余额
|
||||||
|
@ -26,11 +26,7 @@ import java.lang.reflect.Method;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.Iterator;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class EcommerceServiceImpl implements EcommerceService {
|
public class EcommerceServiceImpl implements EcommerceService {
|
||||||
@ -188,6 +184,16 @@ public class EcommerceServiceImpl implements EcommerceService {
|
|||||||
return GSON.fromJson(response, FundBalanceResult.class);
|
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
|
@Override
|
||||||
public FundBalanceResult subDayEndBalance(String subMchid, String date) throws WxPayException {
|
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);
|
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
|
@Override
|
||||||
public PartnerTransferResult batchTransfer(PartnerTransferRequest request) throws WxPayException {
|
public PartnerTransferResult batchTransfer(PartnerTransferRequest request) throws WxPayException {
|
||||||
request.getTransferDetailList().stream().forEach(p -> {
|
request.getTransferDetailList().forEach(p -> {
|
||||||
try {
|
try {
|
||||||
String userName = RsaCryptoUtil.encryptOAEP(p.getUserName(),
|
String userName = RsaCryptoUtil.encryptOAEP(p.getUserName(),
|
||||||
this.payService.getConfig().getVerifier().getValidCertificate());
|
this.payService.getConfig().getVerifier().getValidCertificate());
|
||||||
p.setUserName(userName);
|
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) {
|
} catch (IllegalBlockSizeException e) {
|
||||||
throw new RuntimeException("姓名转换异常!", e);
|
throw new RuntimeException("姓名或身份证转换异常!", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
String url = String.format("%s/v3/partner-transfer/batches", this.payService.getPayBaseUrl());
|
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) {
|
if (request.getLimit() == null || request.getLimit() <= 0) {
|
||||||
request.setLimit(20);
|
request.setLimit(20);
|
||||||
}
|
}
|
||||||
String query = String.format("?need_query_detail=%s&detail_status=ALL&offset=%s&limit=%s",
|
String detailStatus = StringUtil.isNotBlank(request.getDetailStatus()) ? request.getDetailStatus() : "ALL";
|
||||||
request.getNeedQueryDetail(), request.getOffset(), request.getLimit());
|
|
||||||
if (StringUtil.isNotBlank(request.getDetailStatus())) {
|
String query = String.format("?need_query_detail=%s&detail_status=%s&offset=%s&limit=%s",
|
||||||
query += "&detail_status=" + request.getDetailStatus();
|
request.getNeedQueryDetail(), detailStatus, request.getOffset(), request.getLimit());
|
||||||
}
|
|
||||||
String response = this.payService.getV3(url + query);
|
String response = this.payService.getV3(url + query);
|
||||||
return GSON.fromJson(response, BatchNumberResult.class);
|
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.ProfitSharingReceiverResult;
|
||||||
import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader;
|
import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader;
|
||||||
import com.github.binarywang.wxpay.bean.ecommerce.TransactionsResult;
|
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.bean.ecommerce.enums.TradeTypeEnum;
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
@ -125,6 +126,12 @@ public class EcommerceServiceImplTest {
|
|||||||
wxPayService.getEcommerceService().subNowBalance(subMchid);
|
wxPayService.getEcommerceService().subNowBalance(subMchid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubNowBalanceWithAccountType() throws WxPayException {
|
||||||
|
String subMchid = "";
|
||||||
|
wxPayService.getEcommerceService().subNowBalance(subMchid, SpAccountTypeEnum.BASIC);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddReceivers() throws WxPayException {
|
public void testAddReceivers() throws WxPayException {
|
||||||
ProfitSharingReceiverRequest request = new ProfitSharingReceiverRequest();
|
ProfitSharingReceiverRequest request = new ProfitSharingReceiverRequest();
|
||||||
|
Loading…
Reference in New Issue
Block a user