|
|
@@ -175,7 +175,7 @@ public class StatisticService {
|
|
|
return JSONObject.toJSONString(maps);
|
|
|
}
|
|
|
|
|
|
- public Map<String, Map<String, BigDecimal>> orderPriceTrendV2(String yearMonth, Long userId) {
|
|
|
+ public Map<String, BigDecimal> orderPriceTrendV2(String yearMonth, Long userId) {
|
|
|
YearMonth month = YearMonth.parse(yearMonth);
|
|
|
LocalDateTime end = month.atEndOfMonth().atTime(LocalTime.MAX);
|
|
|
LocalDateTime start = month.atDay(1).atStartOfDay();
|
|
|
@@ -189,31 +189,11 @@ public class StatisticService {
|
|
|
orders = orderRepo.findAllByCreatedAtBetweenAndMinterIdAndStatusIn(start, end, userId,
|
|
|
Arrays.asList(OrderStatus.PROCESSING, OrderStatus.FINISH));
|
|
|
}
|
|
|
-
|
|
|
- Map<CollectionSource, List<Order>> orderMap = orders.stream().collect(Collectors.groupingBy(Order::getSource));
|
|
|
- Map<String, BigDecimal> official = null;
|
|
|
- if (CollUtil.isNotEmpty(orderMap.get(CollectionSource.OFFICIAL))) {
|
|
|
- official = orderMap.get(CollectionSource.OFFICIAL)
|
|
|
- .stream()
|
|
|
- .collect(Collectors.groupingBy(
|
|
|
- item -> DateTimeFormatter.ofPattern("yyyy-MM-dd")
|
|
|
- .format(item.getCreatedAt()), Collectors.mapping(Order::getTotalPrice,
|
|
|
- Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, BigDecimal> transfer = null;
|
|
|
- if (CollUtil.isNotEmpty(orderMap.get(CollectionSource.TRANSFER))) {
|
|
|
- transfer = orderMap.get(CollectionSource.TRANSFER)
|
|
|
- .stream()
|
|
|
- .collect(Collectors.groupingBy(
|
|
|
- item -> DateTimeFormatter.ofPattern("yyyy-MM-dd")
|
|
|
- .format(item.getCreatedAt()), Collectors.mapping(Order::getTotalPrice,
|
|
|
- Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, Map<String, BigDecimal>> trend = new HashMap<>();
|
|
|
- trend.put("official", official);
|
|
|
- trend.put("transfer", transfer);
|
|
|
- return trend;
|
|
|
+ Map<String, BigDecimal> map = new HashMap<>();
|
|
|
+ map.put("official", orders.stream().filter(order -> order.getSource().equals(CollectionSource.OFFICIAL))
|
|
|
+ .map(Order::getPrice).reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
|
|
|
+ map.put("transfer", orders.stream().filter(order -> order.getSource().equals(CollectionSource.TRANSFER))
|
|
|
+ .map(Order::getPrice).reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
|
|
|
+ return map;
|
|
|
}
|
|
|
}
|