Source:
public void rateIncreases(long loanId) { List<ExtraLoanRateModel> extraLoanRateModels = extraLoanRateMapper.findByLoanId(loanId); LoanModel loanModel = loanMapper.findById(loanId); if (CollectionUtils.isEmpty(extraLoanRateModels)) { return; } List<InvestModel> investModels = investMapper.findSuccessInvestsByLoanId(loanId); for (InvestModel investModel : investModels) { for (ExtraLoanRateModel extraLoanRateModel : extraLoanRateModels) { if ((extraLoanRateModel.getMinInvestAmount() <= investModel.getAmount() && investModel.getAmount() < extraLoanRateModel.getMaxInvestAmount()) || (extraLoanRateModel.getMaxInvestAmount() == 0 && extraLoanRateModel.getMinInvestAmount() <= investModel.getAmount())) { InvestExtraRateModel investExtraRateModel = new InvestExtraRateModel(); investExtraRateModel.setLoanId(loanId); investExtraRateModel.setInvestId(investModel.getId()); investExtraRateModel.setAmount(investModel.getAmount()); investExtraRateModel.setExtraRate(extraLoanRateModel.getRate()); Date repayDate = new DateTime(loanModel.getRecheckTime()).plusDays(loanModel.getDuration()).toDate(); investExtraRateModel.setRepayDate(repayDate); long expectedInterest = InterestCalculator.calculateExtraLoanRateInterest(loanModel, extraLoanRateModel.getRate(), investModel, repayDate); investExtraRateModel.setExpectedInterest(expectedInterest); MembershipModel membershipModel = userMembershipEvaluator.evaluate(investModel.getLoginName()); long expectedFee = new BigDecimal(membershipModel.getFee()) .multiply(new BigDecimal(expectedInterest)) .setScale(0, BigDecimal.ROUND_DOWN) .longValue(); investExtraRateModel.setExpectedFee(expectedFee); investExtraRateMapper.create(investExtraRateModel); } } } }

Target:
public void rateIncreases(long loanId) { List<ExtraLoanRateModel> extraLoanRateModels = extraLoanRateMapper.findByLoanId(loanId); if (CollectionUtils.isEmpty(extraLoanRateModels)) { return; } LoanModel loanModel = loanMapper.findById(loanId); Date repayDate = new DateTime(loanModel.getRecheckTime()).plusDays(loanModel.getDuration()).toDate(); List<InvestModel> investModels = investMapper.findSuccessInvestsByLoanId(loanId); for (InvestModel investModel : investModels) { for (ExtraLoanRateModel extraLoanRateModel : extraLoanRateModels) { if ((extraLoanRateModel.getMinInvestAmount() <= investModel.getAmount() && investModel.getAmount() < extraLoanRateModel.getMaxInvestAmount()) || (extraLoanRateModel.getMaxInvestAmount() == 0 && extraLoanRateModel.getMinInvestAmount() <= investModel.getAmount())) { InvestExtraRateModel investExtraRateModel = new InvestExtraRateModel(); investExtraRateModel.setLoanId(loanId); investExtraRateModel.setInvestId(investModel.getId()); investExtraRateModel.setAmount(investModel.getAmount()); investExtraRateModel.setLoginName(investModel.getLoginName()); investExtraRateModel.setExtraRate(extraLoanRateModel.getRate()); investExtraRateModel.setRepayDate(repayDate); long expectedInterest = InterestCalculator.calculateExtraLoanRateInterest(loanModel, extraLoanRateModel.getRate(), investModel, repayDate); investExtraRateModel.setExpectedInterest(expectedInterest); long expectedFee = new BigDecimal(investModel.getInvestFeeRate()) .multiply(new BigDecimal(expectedInterest)) .setScale(0, BigDecimal.ROUND_DOWN) .longValue(); investExtraRateModel.setExpectedFee(expectedFee); investExtraRateMapper.create(investExtraRateModel); } } } }