huliguo
2 天以前 5d7b65670282a4fad015e37d567cfa171b162052
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
92
93
94
95
96
97
98
99
100
101
102
103
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.errand.mapper.CourierMapper">
 
 
    <select id="getCourierInfo" resultType="com.ruoyi.errand.object.vo.app.CourierInfoVO">
        select
            tc.name as name,
            tc.phone as phone,
            tc2.name as communityName
        from t_courier tc
        left join t_community_courier on tc.id = tcc.courier_id
        left join t_community tc2 on tcc.community_id = tc2.id
        where
            tc.del_flag=0
            and tc.id=#{courierId}
    </select>
    <select id="getDatStatistics" resultType="com.ruoyi.errand.object.vo.app.CourierStatisticsVO">
        SELECT
            COUNT(CASE WHEN DATE(receiving_time) = CURDATE() THEN 1 END) AS `day`,
            COUNT(CASE WHEN YEARWEEK(receiving_time, 1) = YEARWEEK(CURDATE(), 1) THEN 1 END) AS `week`,
            COUNT(CASE WHEN YEAR(receiving_time) = YEAR(CURDATE())
                AND MONTH(receiving_time) = MONTH(CURDATE()) THEN 1 END) AS `month`
        FROM t_order
        WHERE courier_id = #{courierId}
          AND order_status IN (2, 4, 5) -- 进行中、已完成、已评价状态
          AND receiving_time IS NOT NULL;
    </select>
    <select id="getCourierOrderList" resultType="com.ruoyi.errand.object.vo.app.CourierOrderListVO">
        select
            o.id as id,
            o.address_detail as addressDetail,
            o.recipient_name as recipientName,
            o.recipient_phone as recipientPhone,
            o.order_status as orderStatus,
            o.receiving_time as receivingTime,
            te.rating as rating
        from
            t_order o
        left join  t_evaluation te on o.id = te.order_id
            o.courier_id = #{courierId}  -- 替换为实际跑腿ID
            AND o.del_flag = 0          -- 过滤未删除的订单
        and o.payStatus = 2            -- 过滤未支付的订单
        <if test="orderStatus !=null and orderStatus !=0">
            AND o.order_status = #{orderStatus}  -- 订单状态筛选条件
        </if>
        ORDER BY
            CASE WHEN o.order_status = 1 THEN 0 ELSE 1 END,  -- 待确认订单置顶
    o.order_time DESC;  -- 其余订单按下单时间倒序
    </select>
    <select id="getCourierPageList" resultType="com.ruoyi.errand.object.vo.sys.CourierPageListVO">
        select
        tc.id as id,
        tc.name as name,
        tc.phone as phone,
        tcm.name as communityName,
        tc.status as status
        from t_courier tc
        left join t_community_courier tcc on tc.id = tcc.courier_id
        left join t_community tcm on tcc.community_id = tcm.id
        where
            tc.del_flag=0
        <if test="dto.name !=null and ''!=dto.name">
            AND tc.name = #{dto.name}
        </if>
        <if test="dto.phone !=null and ''!=dto.phone">
            AND tc.phone = #{dto.phone}
        </if>
        <if test="dto.status !=null ">
            AND tc.status = #{dto.status}
        </if>
    </select>
    <select id="detail" resultType="com.ruoyi.errand.object.vo.sys.CourierSysDetailVO">
        select
            tc.name as name,
            tc.phone as phone,
            tc.id_card as idCard,
            tcc.community_id as communityId
            tcm.name as communityName,
            tc.create_time as createTime
            tc.status as status
        from t_courier tc
                 left join t_community_courier tcc on tc.id = tcc.courier_id
                 left join t_community tcm on tcc.community_id = tcm.id
        where
            tc.id=#{id}
    </select>
    <select id="getAllCourierList" resultType="com.ruoyi.errand.object.vo.sys.AllCourierListVO">
        select
            id as courierId,
            name as name
        from
            t_courier
        where
            del_flag=0
        and
            id not in
        <foreach collection="couriers" item="item" index="index" open="(" close=")" separator=",">
            #{item}
        </foreach>
 
    </select>
</mapper>