yanderong
2026-06-22 ad15ad228abdce24eaaa03507e2218b01ec2eeca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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;
 
/**
 *
 * <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) {
        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<TOrderStatisticsCountVo> newAddPassengerStatistics(Integer type) {
        return orderTaxiMapper.newAddPassengerStatistics(type);
    }
 
    /**
     * 订单量统计
     * @param type 1 日订单量,2月订单量
     */
    public List<TOrderStatisticsCountVo> orderCountStatistics(Integer type) {
        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) {
        return orderTaxiMapper.driverCarStatistics(type);
    }
 
    /**
     * 乘客排名
     * @param type 1 今日,2本周,3本月
     */
    public List<TOrderStatisticsPassengerVo> passengerStatistics(Integer type) {
        return orderTaxiMapper.passengerStatistics(type);
    }
}