<?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 tcc 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 del_flag = 0
|
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.order_time as receivingTime,
|
te.rating as rating
|
from
|
t_order o
|
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
|
</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 like concat ('%',#{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,
|
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
|
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 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>
|
</if>
|
|
|
</select>
|
</mapper>
|