<?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 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
|
where
|
o.courier_id = #{courierId} -- 替换为实际跑腿ID
|
AND o.del_flag = 0 -- 过滤未删除的订单
|
and o.pay_status = 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>
|