|
|
@@ -3,7 +3,6 @@ package com.kym.service.impl;
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
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;
|
|
|
@@ -30,13 +29,10 @@ 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, SplitRecordService splitRecordService) {
|
|
|
+ public StatServiceImpl(UserService userService, WashOrderService washOrderService, WashDeviceService washDeviceService) {
|
|
|
this.userService = userService;
|
|
|
this.washOrderService = washOrderService;
|
|
|
this.washDeviceService = washDeviceService;
|
|
|
- this.splitRecordService = splitRecordService;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -119,15 +115,9 @@ public class StatServiceImpl implements StatService {
|
|
|
*/
|
|
|
@Override
|
|
|
public DashboardVo dashboard(String stationId) {
|
|
|
- // 站点今日注册人数
|
|
|
- var todayRegistrations = userService.countDailyRegister(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();
|
|
|
+ // 今日收入:V2结算方案从订单中计算
|
|
|
+ var todayAmountMap = washOrderService.sumAmountByDate(LocalDate.now());
|
|
|
+ var todayIncome = todayAmountMap.getOrDefault(stationId, 0);
|
|
|
|
|
|
// 截止到现在今日的所有洗车订单
|
|
|
var todayOrders = washOrderService.lambdaQuery()
|
|
|
@@ -135,28 +125,42 @@ public class StatServiceImpl implements StatService {
|
|
|
.ge(WashOrder::getStartTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIN))
|
|
|
.list();
|
|
|
|
|
|
- // 今日概要
|
|
|
+ // 站点今日注册人数
|
|
|
+ var todayRegistrations = userService.countDailyRegister(LocalDate.now(), stationId);
|
|
|
+
|
|
|
+ // 月度数据
|
|
|
+ var monthAmountMap = washOrderService.sumMonthAmount(LocalDate.now());
|
|
|
+ var monthIncome = monthAmountMap.getOrDefault(stationId, 0);
|
|
|
+ var monthRegistrations = userService.countMonthRegister(LocalDate.now());
|
|
|
+ var monthOrdersMap = washOrderService.countMonthOrders(LocalDate.now());
|
|
|
+
|
|
|
+ // 累计数据
|
|
|
+ var allOrders = washOrderService.lambdaQuery()
|
|
|
+ .eq(WashOrder::getStationId, stationId)
|
|
|
+ .list();
|
|
|
+ var totalIncome = allOrders.stream().mapToInt(WashOrder::getAmount).sum();
|
|
|
+ var totalMembers = (int) userService.count();
|
|
|
+
|
|
|
DashboardVo dashboardVo = new DashboardVo();
|
|
|
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));
|
|
|
+ dashboardVo.setTodayRegisteredMembers(CommUtil.isEmptyOrNull(todayRegistrations) ? 0 : todayRegistrations.getOrDefault(stationId, 0));
|
|
|
|
|
|
- // 月度或者总数据 todo
|
|
|
- dashboardVo.setMonthIncome(0); // todo
|
|
|
- dashboardVo.setMonthConsumptionAmount(0); // todo
|
|
|
- dashboardVo.setMonthRegisteredMembers(0); //todo
|
|
|
- dashboardVo.setMonthWashOrders(0); // todo
|
|
|
+ dashboardVo.setMonthIncome(monthIncome);
|
|
|
+ dashboardVo.setMonthConsumptionAmount(monthIncome);
|
|
|
+ dashboardVo.setMonthRegisteredMembers(monthRegistrations.getOrDefault(stationId, 0));
|
|
|
+ dashboardVo.setMonthWashOrders(monthOrdersMap.getOrDefault(stationId, 0));
|
|
|
+
|
|
|
+ dashboardVo.setTotalIncome(totalIncome);
|
|
|
+ dashboardVo.setTotalConsumptionAmount(totalIncome);
|
|
|
+ dashboardVo.setTotalWashOrders(allOrders.size());
|
|
|
+ dashboardVo.setTotalRegisteredMembers(totalMembers);
|
|
|
|
|
|
dashboardVo.setAvgOrderPrice(0); // todo
|
|
|
dashboardVo.setAvgOrderDuration(0); // todo
|
|
|
dashboardVo.setAvgWashFrequency(0.0); // todo
|
|
|
|
|
|
- dashboardVo.setTotalIncome(0); // todo
|
|
|
- dashboardVo.setTotalWashOrders(0); // todo
|
|
|
-
|
|
|
-
|
|
|
return dashboardVo;
|
|
|
}
|
|
|
|