huliguo
2025-07-03 e3a2245265516fef78b4737d6fffc939e7c5e0af
pt-errand/src/main/resources/mapper/CourierMapper.xml
@@ -9,7 +9,7 @@
            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_courier tcc on tc.id = tcc.courier_id
        left join t_community tc2 on tcc.community_id = tc2.id
        where
            tc.del_flag=0
@@ -23,6 +23,7 @@
                AND MONTH(receiving_time) = MONTH(CURDATE()) THEN 1 END) AS `month`
        FROM t_order
        WHERE courier_id = #{courierId}
          and del_flag = 0
          AND order_status IN (2, 4, 5) -- 进行中、已完成、已评价状态
          AND receiving_time IS NOT NULL;
    </select>
@@ -33,20 +34,35 @@
            o.recipient_name as recipientName,
            o.recipient_phone as recipientPhone,
            o.order_status as orderStatus,
            o.receiving_time as receivingTime,
            o.order_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            -- 过滤未支付的订单
        left join  t_evaluation te on o.id = te.order_id and te.type = 0
        where
        o.del_flag = 0          -- 过滤未删除的订单
        and o.pay_status = 2
        and o.order_status != 3-- 过滤未支付的订单
        <choose>
            <!-- 当状态=1时,按社区ID查询 -->
            <when test="orderStatus == 1">
                AND o.community_id = #{communityId}
            </when>
            <!-- 当状态为全部时,按社区ID或者跑腿员id查询 -->
            <when test="orderStatus == null or orderStatus == 1">
                AND ((o.community_id = #{communityId} and order_status = 1) or o.courier_id = #{courierId})
            </when>
            <!-- 其他状态按快递员ID查询 -->
            <otherwise>
                AND o.courier_id = #{courierId}
            </otherwise>
        </choose>
        <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;  -- 其余订单按下单时间倒序
        o.order_time DESC
    </select>
    <select id="getCourierPageList" resultType="com.ruoyi.errand.object.vo.sys.CourierPageListVO">
        select
@@ -61,7 +77,7 @@
        where
            tc.del_flag=0
        <if test="dto.name !=null and ''!=dto.name">
            AND tc.name = #{dto.name}
            AND tc.name like concat ('%',#{dto.name},'%')
        </if>
        <if test="dto.phone !=null and ''!=dto.phone">
            AND tc.phone = #{dto.phone}
@@ -75,10 +91,12 @@
            tc.name as name,
            tc.phone as phone,
            tc.id_card as idCard,
            tcc.community_id as communityId
            tcc.community_id as communityId,
            tcm.name as communityName,
            tc.create_time as createTime
            tc.status as status
            tc.create_time as createTime,
            tc.status as status,
            tc.front_view as frontView,
            tc.back_view as backView
        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
@@ -92,12 +110,16 @@
        from
            t_courier
        where
            del_flag=0
        and
            del_flag = 0
          and status = 1
        <if test="couriers!=null and couriers.size>0">
            and
            id not in
        <foreach collection="couriers" item="item" index="index" open="(" close=")" separator=",">
            #{item}
        </foreach>
            <foreach collection="couriers" item="item" index="index" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
    </select>
</mapper>