|
|
|
@ -30,6 +30,9 @@ import java.nio.charset.StandardCharsets; |
|
|
|
import java.security.MessageDigest; |
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
@ -386,14 +389,14 @@ public class BankServiceImpl implements BankService { |
|
|
|
// 方式一:通过订单号查找最近数据 |
|
|
|
String orderNo = bankDTO.getOrderNo(); |
|
|
|
|
|
|
|
if (orderNo == null || orderNo.isEmpty()) { |
|
|
|
return Result.error("订单号为空"); |
|
|
|
if(bankDTO.getSum() <= 0){ |
|
|
|
return Result.error("最大条数不能小于等于0"); |
|
|
|
} |
|
|
|
|
|
|
|
// 从Stripe获取最近的收费记录(最多200条) |
|
|
|
List<Charge> allCharges = new ArrayList<>(); |
|
|
|
String startingAfter = null; |
|
|
|
int totalLimit = 200; // 目标获取条数 |
|
|
|
int totalLimit = bankDTO.getSum(); // 目标获取条数 |
|
|
|
int pageSize = 100; // 单次最大获取条数 |
|
|
|
|
|
|
|
do { |
|
|
|
@ -402,15 +405,17 @@ public class BankServiceImpl implements BankService { |
|
|
|
if (currentPageSize <= 0) { |
|
|
|
break; // 已获取足够条数,停止 |
|
|
|
} |
|
|
|
|
|
|
|
// 构建分页参数 |
|
|
|
Long startTime = LocalDate.parse(bankDTO.getStartTime(), DateTimeFormatter.ofPattern("yyyyMMdd")).atStartOfDay(ZoneId.of("Asia/Shanghai")).toEpochSecond(); |
|
|
|
Long endTime = LocalDate.parse(bankDTO.getEndTime(), DateTimeFormatter.ofPattern("yyyyMMdd")).atStartOfDay(ZoneId.of("Asia/Shanghai")).toEpochSecond(); |
|
|
|
ChargeListParams.Created createdCondition = ChargeListParams.Created.builder() |
|
|
|
.setGte(startTime) // 大于等于开始时间 |
|
|
|
.setLt(endTime) // 小于结束时间 |
|
|
|
.build(); |
|
|
|
ChargeListParams params = ChargeListParams.builder() |
|
|
|
.setLimit((long) currentPageSize) |
|
|
|
.setStartingAfter(startingAfter) |
|
|
|
.setCreated(1764738449L) |
|
|
|
.setCreated(createdCondition) // 加入时间筛选 |
|
|
|
.build(); |
|
|
|
// 加时间过滤:大于等于2024-12-04 00:00:00的时间戳 |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
// 执行分页查询 |
|
|
|
@ -431,6 +436,7 @@ public class BankServiceImpl implements BankService { |
|
|
|
|
|
|
|
// 在获取的所有记录中查找匹配订单号的记录 |
|
|
|
Charge matchedCharge = null; |
|
|
|
System.out.println(allCharges); |
|
|
|
for (Charge charge : allCharges) { |
|
|
|
// 从metadata中获取订单号进行匹配 |
|
|
|
if (charge.getMetadata() != null) { |
|
|
|
@ -460,9 +466,9 @@ public class BankServiceImpl implements BankService { |
|
|
|
// 设置余额交易ID |
|
|
|
stripeDTO.setBalanceTransaction(matchedCharge.getBalanceTransaction()); |
|
|
|
|
|
|
|
// 设置付款币种和金额(来自charge) |
|
|
|
// 设置付款币种和金额(来自charge和来自balanceTransaction) |
|
|
|
stripeDTO.setCurrency(matchedCharge.getCurrency().toUpperCase()); |
|
|
|
stripeDTO.setAmount(String.valueOf(matchedCharge.getAmount())); |
|
|
|
stripeDTO.setAmount(String.valueOf(balanceTransaction.getAmount())); |
|
|
|
|
|
|
|
// 设置收款币种(来自charge) |
|
|
|
stripeDTO.setChargeCurrency(matchedCharge.getCurrency().toUpperCase()); |
|
|
|
|