|
|
@@ -42,18 +42,27 @@ public class StatisticService {
|
|
|
Map<CollectionSource, List<Order>> orderMap = orders.stream().collect(Collectors.groupingBy(Order::getSource));
|
|
|
List<Order> officialOrders = orderMap.get(CollectionSource.OFFICIAL);
|
|
|
List<Order> transferOrders = orderMap.get(CollectionSource.TRANSFER);
|
|
|
- total.put("officialNum", officialOrders.size());
|
|
|
- total.put("transferNum", transferOrders.size());
|
|
|
-
|
|
|
- BigDecimal officialPrice = officialOrders.stream()
|
|
|
- .map(Order::getTotalPrice)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal transferPrice = transferOrders.stream()
|
|
|
- .map(Order::getTotalPrice)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- total.put("officialPrice", officialPrice);
|
|
|
- total.put("transferPrice", transferPrice);
|
|
|
+ if (officialOrders==null || officialOrders.size() == 0){
|
|
|
+ total.put("officialNum", null);
|
|
|
+ total.put("officialPrice", null);
|
|
|
+ }else {
|
|
|
+ total.put("officialNum", officialOrders.size());
|
|
|
+ BigDecimal officialPrice = officialOrders.stream()
|
|
|
+ .map(Order::getTotalPrice)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ total.put("officialPrice", officialPrice);
|
|
|
+ }
|
|
|
|
|
|
+ if (transferOrders==null || transferOrders.size() == 0){
|
|
|
+ total.put("transferNum", null);
|
|
|
+ total.put("transferPrice", null);
|
|
|
+ }else {
|
|
|
+ total.put("transferNum", transferOrders.size());
|
|
|
+ BigDecimal transferPrice = transferOrders.stream()
|
|
|
+ .map(Order::getTotalPrice)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ total.put("transferPrice", transferPrice);
|
|
|
+ }
|
|
|
return total;
|
|
|
}
|
|
|
|