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.Collections; import java.util.List; import java.util.Optional; /** * *

* 订单统计-服务类 *

* @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 annualTrendStatistics(String year) { Optional.ofNullable(year).filter(StringUtils::isNotEmpty).orElseThrow(() -> new ServiceException("年度趋势统计,请求参数年份不能为空")); return orderTaxiMapper.annualTrendStatistics(year); } /** * 总体订单 */ public TOrderStatisticsTotalOrderVo totalOrderStatistics(String startDate, String endDate) { if(StringUtils.isNotEmpty(startDate)) { startDate = startDate+" 00:00:00"; } if(StringUtils.isNotEmpty(endDate)) { endDate = endDate+" 23:59:59"; } TOrderStatisticsTotalOrderVo totalOrderVo = orderTaxiMapper.totalOrderStatistics(startDate, endDate); return Optional.ofNullable(totalOrderVo).map(TOrderStatisticsTotalOrderVo::convert).orElse(new TOrderStatisticsTotalOrderVo()); } /** * 新增乘客统计 * @param type 1 日新增,2月新增 */ public List newAddPassengerStatistics(Integer type) { return orderTaxiMapper.newAddPassengerStatistics(type); } /** * 订单量统计 * @param type 1 日订单量,2月订单量 */ public List orderCountStatistics(Integer type) { return orderTaxiMapper.orderCountStatistics(type); } /** * 当日各时段统计 */ public List orderDayHourCount(Integer startHour, Integer endHour) { return orderTaxiMapper.orderDayHourCount(startHour, endHour); } /** * 司机接单排名 * @param type 1 今日,2本周,3本月 */ public List driverCarStatistics(Integer type) { return orderTaxiMapper.driverCarStatistics(type); } /** * 乘客排名 * @param type 1 今日,2本周,3本月 */ public List passengerStatistics(Integer type) { return orderTaxiMapper.passengerStatistics(type); } }