mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
循环进行转账操作方法
This commit is contained in:
@@ -557,13 +557,51 @@ public class PaymentTestController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取余额到自己账户
|
||||
* 由于限制单笔转账1万,转账方法改为循环创建
|
||||
* @throws BaseAdaPayException
|
||||
*/
|
||||
@Test
|
||||
public void cycleCreateBalancePayment() throws BaseAdaPayException {
|
||||
BigDecimal totalAmount = new BigDecimal("156821.00"); // TODO 需要转账的总金额
|
||||
String outMemberId = "AM84864234"; // TODO 出账memberId
|
||||
String inMemberId = "0"; // 入账memberId
|
||||
String title = "提取余额到自己账户"; // 标题
|
||||
String desc = "2025年9月27日10点26分,售后需求:客户重新添加结算账户, 原账户余额无法提取, 由现下打款给客户"; // 描述
|
||||
String wechatAppId = wechatAppId1; // 万车充id
|
||||
|
||||
// 计算转账次数
|
||||
BigDecimal singleLimit = new BigDecimal("10000.00"); // 单笔限额
|
||||
int count = totalAmount.divide(singleLimit, 0, BigDecimal.ROUND_UP).intValue();
|
||||
|
||||
// 计算每次转账金额
|
||||
BigDecimal remainingAmount = totalAmount;
|
||||
List<BigDecimal> transferAmounts = new ArrayList<>();
|
||||
while (remainingAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 计算当前转账金额(取剩余金额和单笔最大金额中的较小值)
|
||||
BigDecimal currentAmount = remainingAmount.min(singleLimit);
|
||||
transferAmounts.add(currentAmount);
|
||||
// 减去已转账金额
|
||||
remainingAmount = remainingAmount.subtract(currentAmount);
|
||||
}
|
||||
|
||||
logger.info("计算转账次数:{}", count);
|
||||
logger.info("转账金额:{}", transferAmounts);
|
||||
|
||||
// 循环创建转账
|
||||
for (int i = 0; i < count; i++) {
|
||||
String transAmt = transferAmounts.get(i).toString(); // 金额
|
||||
adapayService.createBalancePaymentRequest(outMemberId, inMemberId, transAmt, title, desc, wechatAppId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取余额到自己账户, 转账超过1万使用循环创建{@link PaymentTestController#cycleCreateBalancePayment()}
|
||||
*/
|
||||
@Test
|
||||
public void createBalancePaymentRequestTest() {
|
||||
String outMemberId = "AM46804136"; // 出账memberId
|
||||
String outMemberId = "AM84864234"; // 出账memberId
|
||||
String inMemberId = "0"; // 入账memberId
|
||||
String transAmt = "23831.81"; // 金额
|
||||
String transAmt = "10000.00"; // 金额
|
||||
String title = "提取余额到自己账户"; // 标题
|
||||
String desc = "2025年9月27日10点26分,售后需求:客户重新添加结算账户, 原账户余额无法提取, 由现下打款给客户"; // 描述
|
||||
String wechatAppId = wechatAppId1; // 万车充id
|
||||
|
||||
Reference in New Issue
Block a user