Skip to content

Fix issue #3023 1.查询批量转账订单,传入detailStatus参数时报错 2.提交批量转账订单,传入身份证未加密 #3027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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>
* 二级商户号账户日终余额
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
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 {
Expand Down Expand Up @@ -188,6 +184,16 @@ public FundBalanceResult subNowBalance(String subMchid) throws WxPayException {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -81,11 +87,10 @@ public BatchNumberResult queryBatchByBatchId(BatchNumberRequest request) throws
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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;
Expand Down Expand Up @@ -125,6 +126,12 @@ public void testSubNowBalance() throws WxPayException {
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();
Expand Down