|
|
@@ -2,17 +2,14 @@ package com.kym.service.impl;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.github.pagehelper.PageHelper;
|
|
|
import com.kym.common.utils.CommUtil;
|
|
|
+import com.kym.entity.SplitRecord;
|
|
|
import com.kym.entity.WashDevice;
|
|
|
import com.kym.entity.WashOrder;
|
|
|
import com.kym.entity.queryParams.StatQueryParam;
|
|
|
import com.kym.entity.vo.DashboardVo;
|
|
|
import com.kym.entity.vo.StationTrendVo;
|
|
|
-import com.kym.service.StatService;
|
|
|
-import com.kym.service.UserService;
|
|
|
-import com.kym.service.WashDeviceService;
|
|
|
-import com.kym.service.WashOrderService;
|
|
|
+import com.kym.service.*;
|
|
|
import com.kym.service.cache.KymCache;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -32,13 +29,14 @@ import java.util.stream.Collectors;
|
|
|
public class StatServiceImpl implements StatService {
|
|
|
private final UserService userService;
|
|
|
private final WashOrderService washOrderService;
|
|
|
-
|
|
|
private final WashDeviceService washDeviceService;
|
|
|
+ private final SplitRecordService splitRecordService;
|
|
|
|
|
|
- public StatServiceImpl(UserService userService, WashOrderService washOrderService, WashDeviceService washDeviceService) {
|
|
|
+ public StatServiceImpl(UserService userService, WashOrderService washOrderService, WashDeviceService washDeviceService, SplitRecordService splitRecordService) {
|
|
|
this.userService = userService;
|
|
|
this.washOrderService = washOrderService;
|
|
|
this.washDeviceService = washDeviceService;
|
|
|
+ this.splitRecordService = splitRecordService;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -131,29 +129,44 @@ public class StatServiceImpl implements StatService {
|
|
|
*/
|
|
|
@Override
|
|
|
public DashboardVo dashboard(String stationId) {
|
|
|
+ // 站点今日注册人数
|
|
|
+ var todayRegistrations = userService.countByDailyRegister(LocalDate.now(), stationId);
|
|
|
+
|
|
|
+ // 站点分账-入账数据
|
|
|
+ var todayIncome = (Integer) splitRecordService.lambdaQuery()
|
|
|
+ .eq(SplitRecord::getToStationId, stationId)
|
|
|
+ .ge(SplitRecord::getCreateTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIN))
|
|
|
+ .lt(SplitRecord::getCreateTime, LocalDateTime.of(LocalDate.now(), LocalTime.MAX))
|
|
|
+ .list().stream().mapToInt(SplitRecord::getAmount).sum();
|
|
|
+
|
|
|
// 截止到现在今日的所有洗车订单
|
|
|
var todayOrders = washOrderService.lambdaQuery()
|
|
|
.eq(WashOrder::getStationId, stationId)
|
|
|
.lt(WashOrder::getStartTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIN))
|
|
|
.list();
|
|
|
|
|
|
- // 概要
|
|
|
+ // 今日概要
|
|
|
DashboardVo dashboardVo = new DashboardVo();
|
|
|
- dashboardVo.setTodayIncome(todayOrders.stream().mapToInt(WashOrder::getAmount).sum());
|
|
|
- dashboardVo.setMonthIncome(0); // todo
|
|
|
- dashboardVo.setTotalIncome(0); // todo
|
|
|
+ dashboardVo.setTodayIncome(todayIncome);
|
|
|
dashboardVo.setTodayConsumptionAmount(todayOrders.stream().mapToInt(WashOrder::getAmount).sum());
|
|
|
+ dashboardVo.setTodayWashOrders(todayOrders.size());
|
|
|
+ dashboardVo.setTotalConsumptionAmount(todayOrders.stream().mapToInt(WashOrder::getAmount).sum());
|
|
|
+ dashboardVo.setTodayRegisteredMembers(CommUtil.isEmptyOrNull(todayRegistrations) ? 0 : todayRegistrations.get(stationId));
|
|
|
+
|
|
|
+ // 月度或者总数据 todo
|
|
|
+ dashboardVo.setMonthIncome(0); // todo
|
|
|
dashboardVo.setMonthConsumptionAmount(0); // todo
|
|
|
- dashboardVo.setTotalConsumptionAmount(0); // todo
|
|
|
- dashboardVo.setTodayRegisteredMembers(9); //todo
|
|
|
dashboardVo.setMonthRegisteredMembers(0); //todo
|
|
|
- dashboardVo.setTodayWashOrders(todayOrders.size());
|
|
|
dashboardVo.setMonthWashOrders(0); // todo
|
|
|
- dashboardVo.setTotalWashOrders(0); // todo
|
|
|
+
|
|
|
dashboardVo.setAvgOrderPrice(0); // todo
|
|
|
dashboardVo.setAvgOrderDuration(0); // todo
|
|
|
dashboardVo.setAvgWashFrequency(0.0); // todo
|
|
|
|
|
|
+ dashboardVo.setTotalIncome(0); // todo
|
|
|
+ dashboardVo.setTotalWashOrders(0); // todo
|
|
|
+
|
|
|
+
|
|
|
return dashboardVo;
|
|
|
}
|
|
|
|
|
|
@@ -182,7 +195,6 @@ public class StatServiceImpl implements StatService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
return washOrderService.stationTrend(params);
|
|
|
}
|
|
|
}
|