package com.stylefeng.guns.modular.system.service.impl;
|
|
import com.aliyun.oss.ServiceException;
|
import com.stylefeng.guns.modular.system.dao.TOrderTaxiMapper;
|
import com.stylefeng.guns.modular.system.response.*;
|
import com.stylefeng.guns.modular.system.service.TOrderStatisticsService;
|
import lombok.AllArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Service;
|
|
import java.util.List;
|
import java.util.Optional;
|
|
/**
|
*
|
* <p>
|
* 订单统计-服务类
|
* </p>
|
* @author Lux
|
* @version 1.0.0
|
* @since 2026/6/22 12:00
|
*/
|
@Slf4j
|
@Service
|
@AllArgsConstructor
|
public class TOrderStatisticsServiceImpl implements TOrderStatisticsService {
|
|
private final TOrderTaxiMapper orderTaxiMapper;
|
|
|
@Override
|
public List<TOrderStatisticsAnnualTrendVo> annualTrendStatistics(String year) {
|
Optional.ofNullable(year).filter(StringUtils::isNotEmpty).orElseThrow(() -> new ServiceException("年度趋势统计,请求参数年份不能为空"));
|
return orderTaxiMapper.annualTrendStatistics(year);
|
}
|
|
/**
|
* 总体订单
|
*/
|
public TOrderStatisticsTotalOrderVo totalOrderStatistics(String startDate, String endDate) {
|
startDate = Optional.ofNullable(startDate).filter(StringUtils::isNotEmpty).map(s -> s +" 00:00:00").orElseThrow(() -> new ServiceException("总体订单统计,开始时间不能为空"));
|
endDate = Optional.ofNullable(endDate).filter(StringUtils::isNotEmpty).map(e -> e +" 23:59:59").orElseThrow(() -> new ServiceException("总体订单统计,结束时间不能为空"));
|
TOrderStatisticsTotalOrderVo totalOrderVo = orderTaxiMapper.totalOrderStatistics(startDate, endDate);
|
return Optional.ofNullable(totalOrderVo).map(TOrderStatisticsTotalOrderVo::convert).orElse(new TOrderStatisticsTotalOrderVo());
|
}
|
|
/**
|
* 新增乘客统计
|
* @param type 1 日新增,2月新增
|
*/
|
public List<TOrderStatisticsCountVo> newAddPassengerStatistics(Integer type) {
|
Optional.ofNullable(type).orElseThrow(() -> new ServiceException("新增乘客统计,请求类型不能为空"));
|
return orderTaxiMapper.newAddPassengerStatistics(type);
|
}
|
|
/**
|
* 订单量统计
|
* @param type 1 日订单量,2月订单量
|
*/
|
public List<TOrderStatisticsCountVo> orderCountStatistics(Integer type) {
|
Optional.ofNullable(type).orElseThrow(() -> new ServiceException("订单量统计,请求类型不能为空"));
|
return orderTaxiMapper.orderCountStatistics(type);
|
}
|
|
/**
|
* 当日各时段统计
|
*/
|
public List<TOrderStatisticsCountVo> orderDayHourCount(Integer startHour, Integer endHour) {
|
return orderTaxiMapper.orderDayHourCount(startHour, endHour);
|
}
|
|
/**
|
* 司机接单排名
|
* @param type 1 今日,2本周,3本月
|
*/
|
public List<TOrderStatisticsCarVo> driverCarStatistics(Integer type) {
|
Optional.ofNullable(type).orElseThrow(() -> new ServiceException("司机接单排名统计,请求类型不能为空"));
|
return orderTaxiMapper.driverCarStatistics(type);
|
}
|
|
/**
|
* 乘客排名
|
* @param type 1 今日,2本周,3本月
|
*/
|
public List<TOrderStatisticsPassengerVo> passengerStatistics(Integer type) {
|
Optional.ofNullable(type).orElseThrow(() -> new ServiceException("乘客排名统计,请求类型不能为空"));
|
return orderTaxiMapper.passengerStatistics(type);
|
}
|
}
|