java1.8特性

1、lambda表达式

Java8为集合类引入了另一个重要概念:流(stream)。一个流通常以一个集合类实例为其数据源,然后在其上定义各种操作
例如
.filter
.forEach
dueEntry.stream().map(f -> f.getKey()).forEach(index -> {

            // 每一期的还款金额信息
            String body = repayMessage.getRepayDetails().get(index);
            JSONObject repayObj = JSON.parseObject(body);
            // 本金
            BigDecimal principal = new BigDecimal(repayObj.getDoubleValue("principal"));
            // 利息
            BigDecimal interest = new BigDecimal(repayObj.getDoubleValue("interest"));
            // 应发放积分
            Integer point = countUserPoint(principal, interest);

            // 是否有发放记录查询
            UserPointHistory history = new UserPointHistory();
            history.setIncomeType(IncomeType.REPAY.getName());
            history.setType(PointType.INCOME.getValue());
            history.setUserId(loan.getBorrowerId());
            history.setApplicationId(repayMessage.getApplication_id());
            history.setIndex(Integer.valueOf(index));
            if (userPointHistoryMapper.countByHistory(history) > 0) {
                logger.warn("UserPoint warn:repay重复的积分插入,applicationId:{}", repayMessage.getApplication_id());
                return;
            }
            // 发放积分
            providePoints(loan.getBorrowerId(), IncomeType.REPAY, repayMessage.getApplication_id(), Integer.valueOf(index), point);
        });
View Code

相关文章:

  • 2021-12-01
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
猜你喜欢
  • 2021-11-26
  • 2022-12-23
  • 2020-05-11
  • 2022-12-23
  • 2021-07-31
  • 2022-01-30
相关资源
相似解决方案