2
0

fix: 修复流量账单

This commit is contained in:
caiyuchao
2025-01-16 20:40:09 +08:00
parent 7466dcfdd7
commit b57f4a7a77
2 changed files with 11 additions and 1 deletions

View File

@@ -111,6 +111,13 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> i
account.setBalanceUsed(BigDecimal.ZERO);
account.setBalance(BigDecimal.ZERO);
cancelUserIds.add(account.getUserId());
UBill bill = new UBill();
bill.setUserId(account.getUserId());
bill.setType(2);
bill.setStatus(1);
bill.setAmount(account.getBalanceUsed());
billMapper.insert(bill);
}
this.updateById(account);
}
@@ -120,6 +127,7 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> i
bill.setUserId(historyVo.getUserId());
bill.setCdrHistoryId(historyVo.getId());
bill.setStatus(1);
bill.setType(2);
bill.setAmount(BillRuleUtil.calc(billRule, historyVo.getTrafficDown() + historyVo.getTrafficUp()));
billMapper.insert(bill);
@@ -133,6 +141,7 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> i
}
if (account.getBalance().compareTo(bill.getAmount()) > 0) {
account.setBalance(account.getBalance().subtract(bill.getAmount()));
account.setBalanceUsed(BigDecimal.ZERO);
} else {
account.setBalance(BigDecimal.ZERO);
account.setBalanceUsed(BigDecimal.ZERO);
@@ -249,6 +258,7 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> i
BigDecimal balance = Optional.ofNullable(dashboardVo.getBalance()).orElse(BigDecimal.ZERO);
if (balance.compareTo(balanceUsed) >= 0) {
dashboardVo.setBalance(balance.subtract(balanceUsed));
} else {
dashboardVo.setBalance(BigDecimal.ZERO);
}