| | |
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | |
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTimeInMillis(list.get(0).getCreateTime().getTime());
|
| | | UserMoneyDetailHistoryVO vo = new UserMoneyDetailHistoryVO();
|
| | | vo.setMonth(new UserMonthMoneyVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)));
|
| | | vo.setMonth(new UserMonthMoneyVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1));
|
| | | finalList.add(vo);
|
| | | } else {
|
| | | if (maxTime != null) {//
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTimeInMillis(maxTime.getTime());
|
| | | UserMoneyDetailHistoryVO vo = new UserMoneyDetailHistoryVO();
|
| | | vo.setMonth(new UserMonthMoneyVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1));
|
| | | vo.getMonth().setExpend("0");
|
| | | vo.getMonth().setIncome("0");
|
| | | finalList.add(vo);
|
| | | }
|
| | | }
|
| | |
|
| | | } else {// 二次请求
|
| | |
|
| | | int size = 20;
|
| | | int size = 21;
|
| | | List<UserMoneyDetail> tempList = userMoneyDetailMapper.selectByUidWithIndexId(uid, userMoneyDetailId, size);
|
| | | Set<Date> dateSet = new HashSet<>();// 用于储存是否在同一时间上面(精确到秒)
|
| | | if (tempList.size() > 0) {
|
| | |
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTimeInMillis(list.get(i).getCreateTime().getTime());
|
| | | UserMoneyDetailHistoryVO vo = new UserMoneyDetailHistoryVO();
|
| | | vo.setMonth(new UserMonthMoneyVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)));
|
| | | vo.setMonth(new UserMonthMoneyVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1));
|
| | | finalList.add(vo);
|
| | | }
|
| | | UserMoneyDetailHistoryVO vo = new UserMoneyDetailHistoryVO();
|
| | |
| | | // 统计月资金
|
| | |
|
| | | Map<Integer, UserMoneyDetailHistoryVO> monthMap = new TreeMap<>();
|
| | | for (int i = 0; i < finalList.size(); i++) {
|
| | | if (finalList.get(i).getMonth() != null)
|
| | | monthMap.put(i, finalList.get(i));
|
| | | }
|
| | | if (finalList.size() > 1)
|
| | | for (int i = 0; i < finalList.size(); i++) {
|
| | | if (finalList.get(i).getMonth() != null)
|
| | | monthMap.put(i, finalList.get(i));
|
| | | }
|
| | |
|
| | | List<String> dateFormat = new ArrayList<>();
|
| | | Iterator<Integer> keys = monthMap.keySet().iterator();
|
| | | while (keys.hasNext()) {
|
| | | Integer key = keys.next();
|
| | | String date = "";
|
| | | date += monthMap.get(key).getMonth().getYear();
|
| | | date += "-";
|
| | | date += (monthMap.get(key).getMonth().getMonth() + "").length() < 2
|
| | | ? "0" + monthMap.get(key).getMonth().getMonth() : monthMap.get(key).getMonth().getMonth();
|
| | | dateFormat.add(date);
|
| | | }
|
| | | List<UserMonthMoneyVO> voList = userMoneyDetailMapper.selectMonthMoneyByUid(uid, dateFormat);
|
| | | if (!monthMap.isEmpty()) {
|
| | | List<String> dateFormat = new ArrayList<>();
|
| | | Iterator<Integer> keys = monthMap.keySet().iterator();
|
| | | while (keys.hasNext()) {
|
| | | Integer key = keys.next();
|
| | | String date = "";
|
| | | date += monthMap.get(key).getMonth().getYear();
|
| | | date += "-";
|
| | | date += (monthMap.get(key).getMonth().getMonth() + "").length() < 2
|
| | | ? "0" + monthMap.get(key).getMonth().getMonth() : monthMap.get(key).getMonth().getMonth();
|
| | | dateFormat.add(date);
|
| | | }
|
| | | List<UserMonthMoneyVO> voList = userMoneyDetailMapper.selectMonthMoneyByUid(uid, dateFormat);
|
| | |
|
| | | int p = 0;
|
| | | keys = monthMap.keySet().iterator();
|
| | | while (keys.hasNext()) {
|
| | | Integer key = keys.next();
|
| | | finalList.get(key).getMonth().setExpend(voList.get(p).getExpend());
|
| | | finalList.get(key).getMonth().setIncome(voList.get(p).getIncome());
|
| | | p++;
|
| | | int p = 0;
|
| | | keys = monthMap.keySet().iterator();
|
| | | while (keys.hasNext()) {
|
| | | Integer key = keys.next();
|
| | | finalList.get(key).getMonth().setExpend(voList.get(p).getExpend());
|
| | | finalList.get(key).getMonth().setIncome(voList.get(p).getIncome());
|
| | | p++;
|
| | | }
|
| | | }
|
| | | return finalList;
|
| | | }
|
| | |
| | | return monthCount + detailCount;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<UserMoneyDetail> listByUidWithState(Long uid, int page, int pageSize) {
|
| | | return userMoneyDetailMapper.selectByUidWithState(uid, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByUidWithState(Long uid) {
|
| | | return userMoneyDetailMapper.selectCountByUidWithState(uid);
|
| | | }
|
| | |
|
| | | }
|