@Test public void listMonth() { List<IncomeBillVO> list = incomeService.listMonth(getUser().getId(), "2018-01", "2018-12"); Assert.assertNotNull(list); System.out.println(list); }
@Override @LogMethod("查询月度账单") public List<IncomeBillVO> listMonth(String userId, String startMonth, String endMonth) { List<IncomeBillVO> list = new ArrayList<>(); if (startMonth.compareTo(endMonth) > 0) { return list; } String[] starts = startMonth.split(HYPHEN); int yearStart = Integer.parseInt(starts[0]); int monthStart = Integer.parseInt(starts[1]); String[] ends = endMonth.split(HYPHEN); int yearEnd = Integer.parseInt(ends[0]); int monthEnd = Integer.parseInt(ends[1]); while (yearStart < yearEnd || (yearStart == yearEnd && monthStart <= monthEnd)) { IncomeBillVO billVO = new IncomeBillVO(); String month = yearStart + HYPHEN + Strings.padStart(String.valueOf(monthStart), 2, '0'); billVO.setDate(month); Date start = DateUtil.parseDate(month + HYPHEN + "01"); setBill(list, billVO, userId, start, DateUtil.endOfMonth(start)); if (++monthStart > 12) { yearStart++; monthStart = 1; } } return list; }
IncomeServiceImpl implements IncomeService { @Override @LogMethod("查询月度账单") public List<IncomeBillVO> listMonth(String userId, String startMonth, String endMonth) { List<IncomeBillVO> list = new ArrayList<>(); if (startMonth.compareTo(endMonth) > 0) { return list; } String[] starts = startMonth.split(HYPHEN); int yearStart = Integer.parseInt(starts[0]); int monthStart = Integer.parseInt(starts[1]); String[] ends = endMonth.split(HYPHEN); int yearEnd = Integer.parseInt(ends[0]); int monthEnd = Integer.parseInt(ends[1]); while (yearStart < yearEnd || (yearStart == yearEnd && monthStart <= monthEnd)) { IncomeBillVO billVO = new IncomeBillVO(); String month = yearStart + HYPHEN + Strings.padStart(String.valueOf(monthStart), 2, '0'); billVO.setDate(month); Date start = DateUtil.parseDate(month + HYPHEN + "01"); setBill(list, billVO, userId, start, DateUtil.endOfMonth(start)); if (++monthStart > 12) { yearStart++; monthStart = 1; } } return list; } }
IncomeServiceImpl implements IncomeService { @Override @LogMethod("查询月度账单") public List<IncomeBillVO> listMonth(String userId, String startMonth, String endMonth) { List<IncomeBillVO> list = new ArrayList<>(); if (startMonth.compareTo(endMonth) > 0) { return list; } String[] starts = startMonth.split(HYPHEN); int yearStart = Integer.parseInt(starts[0]); int monthStart = Integer.parseInt(starts[1]); String[] ends = endMonth.split(HYPHEN); int yearEnd = Integer.parseInt(ends[0]); int monthEnd = Integer.parseInt(ends[1]); while (yearStart < yearEnd || (yearStart == yearEnd && monthStart <= monthEnd)) { IncomeBillVO billVO = new IncomeBillVO(); String month = yearStart + HYPHEN + Strings.padStart(String.valueOf(monthStart), 2, '0'); billVO.setDate(month); Date start = DateUtil.parseDate(month + HYPHEN + "01"); setBill(list, billVO, userId, start, DateUtil.endOfMonth(start)); if (++monthStart > 12) { yearStart++; monthStart = 1; } } return list; } @Autowired  IncomeServiceImpl(AssetDAO assetDAO, IncomeDAO incomeDAO, MongoTemplate mongoTemplate,
                             RedisTemplate<String, Asset> assetRedisTemplate); }
IncomeServiceImpl implements IncomeService { @Override @LogMethod("查询月度账单") public List<IncomeBillVO> listMonth(String userId, String startMonth, String endMonth) { List<IncomeBillVO> list = new ArrayList<>(); if (startMonth.compareTo(endMonth) > 0) { return list; } String[] starts = startMonth.split(HYPHEN); int yearStart = Integer.parseInt(starts[0]); int monthStart = Integer.parseInt(starts[1]); String[] ends = endMonth.split(HYPHEN); int yearEnd = Integer.parseInt(ends[0]); int monthEnd = Integer.parseInt(ends[1]); while (yearStart < yearEnd || (yearStart == yearEnd && monthStart <= monthEnd)) { IncomeBillVO billVO = new IncomeBillVO(); String month = yearStart + HYPHEN + Strings.padStart(String.valueOf(monthStart), 2, '0'); billVO.setDate(month); Date start = DateUtil.parseDate(month + HYPHEN + "01"); setBill(list, billVO, userId, start, DateUtil.endOfMonth(start)); if (++monthStart > 12) { yearStart++; monthStart = 1; } } return list; } @Autowired  IncomeServiceImpl(AssetDAO assetDAO, IncomeDAO incomeDAO, MongoTemplate mongoTemplate,
                             RedisTemplate<String, Asset> assetRedisTemplate); @Override @LogMethod("查询资产可用余额") Long getAssetBalance(String userId); @Override @LogMethod("查询收益记录") List<Income> listIncome(String userId, String category, Date start, Date end); @Override @LogMethod("查询年度账单") List<IncomeBillVO> listYear(String userId, Integer startYear, Integer endYear); @Override @LogMethod("查询月度账单") List<IncomeBillVO> listMonth(String userId, String startMonth, String endMonth); @Override @LogMethod("更新收益记录") Income updateIncome(String userId, String incomeId, IncomeVO incomeVO); @Override @LogMethod("删除收益记录") void remove(String userId, String incomeId); @Override @LogMethod("添加收益记录") Income saveIncome(String userId, IncomeVO incomeVO); }
IncomeServiceImpl implements IncomeService { @Override @LogMethod("查询月度账单") public List<IncomeBillVO> listMonth(String userId, String startMonth, String endMonth) { List<IncomeBillVO> list = new ArrayList<>(); if (startMonth.compareTo(endMonth) > 0) { return list; } String[] starts = startMonth.split(HYPHEN); int yearStart = Integer.parseInt(starts[0]); int monthStart = Integer.parseInt(starts[1]); String[] ends = endMonth.split(HYPHEN); int yearEnd = Integer.parseInt(ends[0]); int monthEnd = Integer.parseInt(ends[1]); while (yearStart < yearEnd || (yearStart == yearEnd && monthStart <= monthEnd)) { IncomeBillVO billVO = new IncomeBillVO(); String month = yearStart + HYPHEN + Strings.padStart(String.valueOf(monthStart), 2, '0'); billVO.setDate(month); Date start = DateUtil.parseDate(month + HYPHEN + "01"); setBill(list, billVO, userId, start, DateUtil.endOfMonth(start)); if (++monthStart > 12) { yearStart++; monthStart = 1; } } return list; } @Autowired  IncomeServiceImpl(AssetDAO assetDAO, IncomeDAO incomeDAO, MongoTemplate mongoTemplate,
                             RedisTemplate<String, Asset> assetRedisTemplate); @Override @LogMethod("查询资产可用余额") Long getAssetBalance(String userId); @Override @LogMethod("查询收益记录") List<Income> listIncome(String userId, String category, Date start, Date end); @Override @LogMethod("查询年度账单") List<IncomeBillVO> listYear(String userId, Integer startYear, Integer endYear); @Override @LogMethod("查询月度账单") List<IncomeBillVO> listMonth(String userId, String startMonth, String endMonth); @Override @LogMethod("更新收益记录") Income updateIncome(String userId, String incomeId, IncomeVO incomeVO); @Override @LogMethod("删除收益记录") void remove(String userId, String incomeId); @Override @LogMethod("添加收益记录") Income saveIncome(String userId, IncomeVO incomeVO);  }