| | |
| | | List<Wallet> walletList = walletService.list(queryWrapper); |
| | | if (!walletList.isEmpty()) { |
| | | log.info("==================进入待补自动扣费================"); |
| | | |
| | | walletList.forEach((wallet) -> { |
| | | BigDecimal money = wallet.getMoney(); |
| | | BigDecimal amountToBeCovered = wallet.getAmountToBeCovered(); |
| | | if (money.compareTo(amountToBeCovered) >= 0) { |
| | | wallet.setMoney(money.subtract(amountToBeCovered)); |
| | | log.info("用户id{}已补完待补", wallet.getUserId()); |
| | | } else { |
| | | //资金不足 |
| | | BigDecimal newAmountToBeCovered = amountToBeCovered.subtract(money); |
| | | wallet.setMoney(BigDecimal.ZERO); |
| | | wallet.setAmountToBeCovered(newAmountToBeCovered); |
| | | log.info("用户id{}补待补{}", wallet.getUserId(), money.toString()); |
| | | } |
| | | walletService.updateById(wallet); |
| | | }); |
| | | } |
| | | |
| | | |