<?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.OrderMapper">
|
|
|
<select id="getAppUserOrderList" resultType="com.ruoyi.errand.object.vo.app.AppUserOrderListVO">
|
select
|
o.id,
|
o.address_detail,
|
o.recipient_name,
|
o.recipient_phone,
|
o.order_status,
|
o.order_time,
|
o.rating,
|
o.courier_id,
|
c.name,
|
c.phone
|
from t_order o
|
left join t_courier c on o.courier_id = c.id
|
where
|
o.del_flag=0
|
and o.pay_status=2
|
and o.app_user_id = #{appUserId}
|
<if test="orderStatus!=null and orderStatus!=0">
|
and o.order_status = #{orderStatus}
|
</if>
|
</select>
|
<select id="getOrderDetail" resultType="com.ruoyi.errand.object.vo.app.OrderDetailVO">
|
select
|
o.id as id,
|
o.community_id as communityId,
|
o.community_name as communityName,
|
o.address_detail as addressDetail,
|
o.recipient_name as recipientName,
|
o.recipient_phone as recipientPhone,
|
o.agency_matters as agencyMatters,
|
o.num as num,
|
o.remark as remark,
|
o.pics as pics,
|
o.courier_pics as courierPics,
|
o.order_status as orderStatus,
|
o.order_number as orderNumber,
|
o.order_time as orderTime,
|
o.pay_method as payMethod,
|
o.payment_amount as paymentAmount,
|
c.courier_name as courierName,
|
c.courier_phone as courierPhone,
|
e.rating as rating,
|
e.content as content
|
from t_order o
|
left join t_courier c on o.courier_id = c.id
|
left join t_evaluation e on o.id = e.order_id
|
where
|
o.id=#{id}
|
and o.del_flag=0
|
and e.type = 0
|
</select>
|
|
<select id="getOrderTopInfoByDate" resultType="java.util.Map">
|
select
|
count(*) as num,
|
COALESCE(SUM(payment_amount), 0.00) AS amount
|
from
|
t_order
|
where
|
del_flag=0
|
and
|
order_status in (4,5)
|
<if test="communityId!=null and communityId!=0">
|
and communityId =#{communityId}
|
</if>
|
<if test="start!=null and end!=null">
|
and order_time BETWEEN #{start} AND #{end}
|
</if>
|
|
|
</select>
|
<select id="countGroupByDate" resultType="java.util.Map">
|
SELECT
|
CASE #{datePattern}
|
WHEN 'HH时' THEN DATE_FORMAT(order_time, '%H时')
|
WHEN 'EEEE' THEN ELT(DAYOFWEEK(order_time), '星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六')
|
WHEN 'dd日' THEN DATE_FORMAT(order_time, '%d日')
|
WHEN 'MM月' THEN DATE_FORMAT(order_time, '%m月')
|
WHEN 'yyyy-MM-dd' THEN DATE_FORMAT(order_time, '%Y-%m-%d')
|
ELSE DATE_FORMAT(order_time, '%Y-%m-%d')
|
END AS `date`,
|
COUNT(*) AS `num`,
|
COALESCE(SUM(payment_amount), 0.00) AS amount
|
FROM t_order
|
WHERE order_time BETWEEN #{start} AND #{end}
|
and del_flag=0 and order_status in (4,5)
|
GROUP BY
|
CASE #{datePattern}
|
WHEN 'HH时' THEN DATE_FORMAT(order_time, '%H时')
|
WHEN 'EEEE' THEN ELT(DAYOFWEEK(order_time), '星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六')
|
WHEN 'dd日' THEN DATE_FORMAT(order_time, '%d日')
|
WHEN 'MM月' THEN DATE_FORMAT(order_time, '%m月')
|
WHEN 'yyyy-MM-dd' THEN DATE_FORMAT(order_time, '%Y-%m-%d')
|
ELSE DATE_FORMAT(order_time, '%Y-%m-%d')
|
END
|
ORDER BY order_time
|
</select>
|
|
<select id="selectPageTotal" resultType="java.lang.Long">
|
SELECT COUNT(*) FROM (
|
SELECT tau.id, 1 as type, t.order_status, t.order_time
|
FROM t_order t
|
INNER JOIN t_app_user tau ON t.app_user_id = tau.id
|
WHERE
|
t.del_flag=0
|
and t.pay_status=2
|
<if test="dto.appUserName!=null and ''!=dto.appUserName">
|
and tau.name like concat('%',#{dto.appUserName},'%')
|
</if>
|
|
<if test="dto.phone!=null and ''!=dto.phone">
|
and tau.phone like concat('%',#{dto.phone},'%')
|
</if>
|
<if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
|
and t.order_status = #{dto.orderStatus}
|
</if>
|
<if test="dto.orderStatus ==4">
|
and t.order_status in(4,5)
|
</if>
|
<if test="dto.startTime!=null and dto.endTime != null">
|
and t.order_time between #{dto.startTime} and #{dto.endTime}
|
</if>
|
UNION ALL
|
SELECT tau.id, 2 as type, t.order_status, t.order_time
|
FROM t_vip_order t
|
INNER JOIN t_app_user tau ON t.app_user_id = tau.id
|
WHERE t.del_flag=0
|
and t.pay_status=2
|
<if test="dto.appUserName!=null and ''!=dto.appUserName">
|
and tau.name like concat('%',#{dto.appUserName},'%')
|
</if>
|
|
<if test="dto.phone!=null and ''!=dto.phone">
|
and tau.phone like concat('%',#{dto.phone},'%')
|
</if>
|
|
<if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
|
and t.order_status = #{dto.orderStatus}
|
</if>
|
<if test="dto.orderStatus ==4">
|
and t.order_status in(4,5)
|
</if>
|
<if test="dto.startTime!=null and dto.endTime != null">
|
and t.order_time between #{dto.startTime} and #{dto.endTime}
|
</if>
|
) t
|
where
|
1=1
|
<if test="dto.type!=null and 0!=dto.type">
|
and t.type = #{dto.type}
|
</if>
|
</select>
|
|
|
<select id="financeStatistics" resultType="com.ruoyi.errand.object.vo.sys.FinanceStatisticsVO">
|
select * from (
|
SELECT t.id as id,
|
t.order_time as orderTime,
|
1 as type,
|
t.order_number as orderNumber,
|
tau.name as appUserName,
|
tau.phone as phone,
|
t.order_status as orderStatus
|
FROM t_order t
|
INNER JOIN t_app_user tau ON t.app_user_id = tau.id
|
WHERE t.del_flag=0
|
and t.pay_status=2
|
<if test="dto.appUserName!=null and ''!=dto.appUserName">
|
and tau.name like concat('%',#{dto.appUserName},'%')
|
</if>
|
<if test="dto.phone!=null and ''!=dto.phone">
|
and tau.phone like concat('%',#{dto.phone},'%')
|
</if>
|
<if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
|
and t.order_status = #{dto.orderStatus}
|
</if>
|
<if test="dto.orderStatus ==4">
|
and t.order_status in(4,5)
|
</if>
|
<if test="dto.startTime!=null and dto.endTime != null">
|
and t.order_time between #{dto.startTime} and #{dto.endTime}
|
</if>
|
UNION ALL
|
SELECT t.id as id,
|
t.order_time as orderTime,
|
2 as type,
|
t.order_number as orderNumber,
|
tau.name as appUserName,
|
tau.phone as phone,
|
t.order_status as orderStatus
|
FROM t_vip_order t
|
INNER JOIN t_app_user tau ON t.app_user_id = tau.id
|
WHERE t.del_flag=0
|
and t.pay_status=2
|
<if test="dto.appUserName!=null and ''!=dto.appUserName">
|
and tau.name like concat('%',#{dto.appUserName},'%')
|
</if>
|
|
<if test="dto.phone!=null and ''!=dto.phone">
|
and tau.phone like concat('%',#{dto.phone},'%')
|
</if>
|
|
<if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
|
and t.order_status = #{dto.orderStatus}
|
</if>
|
<if test="dto.orderStatus ==4">
|
and t.order_status in(4,5)
|
</if>
|
|
<if test="dto.startTime!=null and dto.endTime != null">
|
and t.order_time between #{dto.startTime} and #{dto.endTime}
|
</if>
|
) t
|
where
|
1=1
|
<if test="dto.type!=null and 0!=dto.type">
|
and t.type = #{dto.type}
|
</if>
|
ORDER BY t.orderTime DESC
|
LIMIT #{dto.pageNum}, #{dto.pageSize}
|
</select>
|
<select id="getOrderPageList" resultType="com.ruoyi.errand.object.vo.sys.OrderPageListVO">
|
select
|
o.id as id,
|
o.order_number as orderNumber,
|
o.order_time as orderTime,
|
o.payment_amount as paymentAmount,
|
o.finish_time as finishTime,
|
o.order_status as orderStatus,
|
o.community_name as communityName,
|
tau.name as appUserName,
|
tau.phone as appUserPhone,
|
tc.name as courierName,
|
tc.phone as courierPhone
|
from t_order o
|
inner join t_app_user tau on o.app_user_id = tau.id
|
left join t_courier tc on o.courier_id = tc.id
|
where
|
o.del_flag=0
|
and o.pay_status=2
|
<if test="dto.orderNumber!=null and ''!=dto.orderNumber">
|
and o.order_number like concat('%',#{dto.orderNumber},'%')
|
</if>
|
<if test="dto.communityName!=null and ''!=dto.communityName">
|
and o.community_name like concat('%',#{dto.communityName},'%')
|
</if>
|
<if test="dto.appUserName!=null and ''!=dto.appUserName">
|
and tau.name like concat('%',#{dto.appUserName},'%')
|
</if>
|
<if test="dto.appUserPhone!=null and ''!=dto.appUserPhone">
|
and tau.phone like concat('%',#{dto.appUserPhone},'%')
|
</if>
|
<if test="dto.courierName!=null and ''!=dto.courierName">
|
and tc.name like concat('%',#{dto.courierName},'%')
|
</if>
|
<if test="dto.courierPhone!=null and ''!=dto.courierPhone">
|
and tc.phone like concat('%',#{dto.courierPhone},'%')
|
</if>
|
<if test="dto.orderStartTime!=null and dto.orderEndTime != null">
|
and o.order_time between #{dto.orderStartTime} and #{dto.orderEndTime}
|
</if>
|
<if test="dto.finishStartTime!=null and dto.finishEndTime != null">
|
and o.finishTime between #{dto.finishStartTime} and #{dto.finishEndTime}
|
</if>
|
<if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
|
and o.order_status = #{dto.orderStatus}
|
</if>
|
<if test="dto.orderStatus ==4">
|
and o.order_status in(4,5)
|
</if>
|
</select>
|
<select id="detail" resultType="com.ruoyi.errand.object.vo.sys.OrderSysDetailVO">
|
select
|
o.order_status as orderStatus,
|
tau.name as appUserName,
|
tau.phone as appUserPhone,
|
o.community_name as communityName,
|
o.recipient_name as recipientName,
|
o.recipient_phone as recipientPhone,
|
o.address_detail as addressDetail,
|
o.agency_matters as agencyMatters,
|
o.num as num,
|
o.remark as remark,
|
o.pics as pics,
|
tc.name as courierName,
|
tc.phone as courierPhone,
|
o.courier_pics as courierPics,
|
o.order_number as orderNumber,
|
o.order_time as orderTime,
|
o.finish_time as finishTime,
|
o.payment_amount as paymentAmount,
|
teu.rating as userRating,
|
teu.content as userContent,
|
tec.rating as courierRating,
|
tec.content as courierContent
|
from t_order o
|
inner join t_app_user tau on o.app_user_id = tau.id
|
left join t_courier tc on o.courier_id = tc.id
|
left join t_evaluation teu on o.id = teu.order_id and teu.type=0
|
left join t_evaluation tec on o.id = teu.order_id and teu.type=1
|
where
|
o.id=#{id}
|
</select>
|
<select id="export" resultType="com.ruoyi.errand.object.vo.sys.FinanceStatisticsVO">
|
select * from (
|
SELECT t.id as id,
|
t.order_time as orderTime,
|
1 as type,
|
t.order_number as orderNumber,
|
tau.name as appUserName,
|
tau.phone as phone,
|
t.order_status as orderStatus
|
FROM t_order t
|
INNER JOIN t_app_user tau ON t.app_user_id = tau.id
|
WHERE t.del_flag=0
|
and t.pay_status=2
|
<if test="dto.appUserName!=null and ''!=dto.appUserName">
|
and tau.name like concat('%',#{dto.appUserName},'%')
|
</if>
|
<if test="dto.phone!=null and ''!=dto.phone">
|
and tau.phone like concat('%',#{dto.phone},'%')
|
</if>
|
<if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
|
and t.order_status = #{dto.orderStatus}
|
</if>
|
<if test="dto.orderStatus ==4">
|
and t.order_status in(4,5)
|
</if>
|
<if test="dto.startTime!=null and dto.endTime != null">
|
and t.order_time between #{dto.startTime} and #{dto.endTime}
|
</if>
|
UNION ALL
|
SELECT t.id as id,
|
t.order_time as orderTime,
|
2 as type,
|
t.order_number as orderNumber,
|
tau.name as appUserName,
|
tau.phone as phone,
|
t.order_status as orderStatus
|
FROM t_vip_order t
|
INNER JOIN t_app_user tau ON t.app_user_id = tau.id
|
WHERE t.del_flag=0
|
and t.pay_status=2
|
<if test="dto.appUserName!=null and ''!=dto.appUserName">
|
and tau.name like concat('%',#{dto.appUserName},'%')
|
</if>
|
|
<if test="dto.phone!=null and ''!=dto.phone">
|
and tau.phone like concat('%',#{dto.phone},'%')
|
</if>
|
|
<if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
|
and t.order_status = #{dto.orderStatus}
|
</if>
|
<if test="dto.orderStatus ==4">
|
and t.order_status in(4,5)
|
</if>
|
|
<if test="dto.startTime!=null and dto.endTime != null">
|
and t.order_time between #{dto.startTime} and #{dto.endTime}
|
</if>
|
) t
|
where
|
1=1
|
<if test="dto.type!=null and 0!=dto.type">
|
and t.type = #{dto.type}
|
</if>
|
ORDER BY t.orderTime DESC
|
</select>
|
<select id="orderExport" resultType="com.ruoyi.errand.object.vo.sys.OrderPageListVO">
|
select
|
o.id as id,
|
o.order_number as orderNumber,
|
o.order_time as orderTime,
|
o.payment_amount as paymentAmount,
|
o.finish_time as finishTime,
|
o.order_status as orderStatus,
|
o.community_name as communityName,
|
tau.name as appUserName,
|
tau.phone as appUserPhone,
|
tc.name as courierName,
|
tc.phone as courierPhone
|
from t_order o
|
inner join t_app_user tau on o.app_user_id = tau.id
|
left join t_courier tc on o.courier_id = tc.id
|
where
|
o.del_flag=0
|
and o.pay_status=2
|
<if test="dto.orderNumber!=null and ''!=dto.orderNumber">
|
and o.order_number like concat('%',#{dto.orderNumber},'%')
|
</if>
|
<if test="dto.communityName!=null and ''!=dto.communityName">
|
and o.community_name like concat('%',#{dto.communityName},'%')
|
</if>
|
<if test="dto.appUserName!=null and ''!=dto.appUserName">
|
and tau.name like concat('%',#{dto.appUserName},'%')
|
</if>
|
<if test="dto.appUserPhone!=null and ''!=dto.appUserPhone">
|
and tau.phone like concat('%',#{dto.appUserPhone},'%')
|
</if>
|
<if test="dto.courierName!=null and ''!=dto.courierName">
|
and tc.name like concat('%',#{dto.courierName},'%')
|
</if>
|
<if test="dto.courierPhone!=null and ''!=dto.courierPhone">
|
and tc.phone like concat('%',#{dto.courierPhone},'%')
|
</if>
|
<if test="dto.orderStartTime!=null and dto.orderEndTime != null">
|
and o.order_time between #{dto.orderStartTime} and #{dto.orderEndTime}
|
</if>
|
<if test="dto.finishStartTime!=null and dto.finishEndTime != null">
|
and o.finishTime between #{dto.finishStartTime} and #{dto.finishEndTime}
|
</if>
|
<if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
|
and o.order_status = #{dto.orderStatus}
|
</if>
|
<if test="dto.orderStatus ==4">
|
and o.order_status in(4,5)
|
</if>
|
</select>
|
</mapper>
|