<?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.order.mapper.OrderMapper">
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ruoyi.order.entity.Order">
|
<id column="id" property="id"/>
|
<result column="site_id" property="siteId"/>
|
<result column="accept_time" property="acceptTime"/>
|
<result column="order_number" property="orderNumber"/>
|
<result column="order_money" property="orderMoney"/>
|
<result column="site_name" property="siteName"/>
|
<result column="serve_id" property="serveId"/>
|
<result column="print_count" property="printCount"/>
|
<result column="serve_name" property="serveName"/>
|
<result column="serve_price" property="servePrice"/>
|
<result column="reservation_name" property="reservationName"/>
|
<result column="reservation_phone" property="reservationPhone"/>
|
<result column="reservation_address" property="reservationAddress"/>
|
<result column="time" property="time"/>
|
<result column="server_id" property="serverId"/>
|
<result column="server_name" property="serverName"/>
|
<result column="server_phone" property="serverPhone"/>
|
<result column="reservation_remark" property="reservationRemark"/>
|
<result column="state" property="state"/>
|
<result column="createBy" property="createBy"/>
|
<result column="updateBy" property="updateBy"/>
|
<result column="createTime" property="createTime"/>
|
<result column="updateTime" property="updateTime"/>
|
<result column="is_delete" property="isDelete"/>
|
<result column="fake" property="fake"/>
|
<result column="apply_reason" property="applyReason"/>
|
</resultMap>
|
|
|
<select id="orderCountByYear" resultType="com.ruoyi.order.vo.OrderQueryVO">
|
SELECT DATE_FORMAT(createTime, '%Y-%m') AS dateTime,
|
COUNT(*) AS number,
|
sum(IFNULL(order_money, 0)) as totalPrice,
|
COUNT(CASE WHEN fake = 1 THEN 1 END) AS fakeCount
|
FROM t_order
|
<where>
|
is_delete = 0
|
and YEAR(createTime) = YEAR(NOW())
|
<if test="cityList != null and cityList.size() != 0">
|
and city_code in
|
<foreach collection="cityList" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="orderState != null">
|
and state = #{orderState}
|
</if>
|
</where>
|
GROUP BY dateTime
|
order by dateTime
|
</select>
|
|
<select id="orderCountByWeek" resultType="com.ruoyi.order.vo.OrderQueryVO">
|
SELECT DATE_FORMAT(createTime, '%Y-%m-%d') AS dateTime,
|
COUNT(*) AS number,
|
sum(IFNULL(order_money, 0)) as totalPrice,
|
COUNT(CASE WHEN fake = 1 THEN 1 END) AS fakeCount
|
FROM t_order
|
<where>
|
is_delete = 0
|
and YEARWEEK(DATE_FORMAT(createTime, '%Y-%m-%d'), 1) = YEARWEEK(NOW(), 1)
|
<if test="cityList != null and cityList.size() != 0">
|
and city_code in
|
<foreach collection="cityList" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="orderState != null">
|
and state = #{orderState}
|
</if>
|
</where>
|
GROUP BY dateTime
|
order by dateTime
|
</select>
|
|
<select id="orderCountByMonth" resultType="com.ruoyi.order.vo.OrderQueryVO">
|
SELECT DATE_FORMAT(createTime, '%Y-%m-%d') AS dateTime,
|
COUNT(*) AS number,
|
sum(IFNULL(order_money, 0)) as totalPrice,
|
COUNT(CASE WHEN fake = 1 THEN 1 END) AS fakeCount
|
FROM t_order
|
<where>
|
is_delete = 0
|
and MONTH(createTime) = MONTH(NOW())
|
AND YEAR(createTime) = YEAR(NOW())
|
<if test="cityList != null and cityList.size() != 0">
|
and city_code in
|
<foreach collection="cityList" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="orderState != null">
|
and state = #{orderState}
|
</if>
|
</where>
|
GROUP BY dateTime
|
order by dateTime
|
</select>
|
|
<select id="orderCountByToday" resultType="com.ruoyi.order.vo.OrderQueryVO">
|
SELECT DATE_FORMAT(createTime, '%Y-%m-%d') AS dateTime,
|
COUNT(*) AS number,
|
sum(IFNULL(order_money, 0)) as totalPrice,
|
COUNT(CASE WHEN fake = 1 THEN 1 END) AS fakeCount
|
FROM t_order
|
<where>
|
is_delete = 0
|
and DATE(createTime) = CURDATE()
|
<if test="cityList != null and cityList.size() != 0">
|
and city_code in
|
<foreach collection="cityList" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="orderState != null">
|
and state = #{orderState}
|
</if>
|
</where>
|
GROUP BY dateTime
|
order by dateTime
|
</select>
|
|
<select id="totalMoneyByQuarter" resultType="java.math.BigDecimal">
|
select sum(order_money)
|
from t_order
|
<where>
|
is_delete = 0
|
and state = 3
|
<if test="cityList != null and cityList.size() != 0">
|
and city_code in
|
<foreach collection="cityList" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="start != null and start != ''">
|
and createTime <![CDATA[ >= ]]> #{start}
|
</if>
|
<if test="end != null and end != ''">
|
and createTime <![CDATA[ <= ]]> #{end}
|
</if>
|
</where>
|
</select>
|
|
<select id="totalMoneyByYear" resultType="java.math.BigDecimal">
|
SELECT sum(order_money) as totalPrice
|
FROM t_order
|
where YEAR(createTime) = YEAR(NOW())
|
and is_delete = 0
|
and state = 3
|
<if test="cityList != null and cityList.size() != 0">
|
and city_code in
|
<foreach collection="cityList" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="totalMoneyByMonth" resultType="java.math.BigDecimal">
|
SELECT sum(order_money) as totalPrice
|
FROM t_order
|
where MONTH(createTime) = MONTH(NOW())
|
AND YEAR(createTime) = YEAR(NOW())
|
and is_delete = 0
|
and state = 3
|
<if test="cityList != null and cityList.size() != 0">
|
and city_code in
|
<foreach collection="cityList" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="orderCount" resultType="com.ruoyi.order.vo.OrderCountVO">
|
SELECT o.server_id as workerId,
|
SUM(CASE WHEN o.state in (1, 2) THEN 1 ELSE 0 END) AS toBeCompletedNumber,
|
SUM(CASE WHEN o.state = 3 THEN 1 ELSE 0 END) AS completedNumber,
|
SUM(CASE WHEN o.state = 6 THEN 1 ELSE 0 END) AS reInvestment
|
FROM t_order o
|
WHERE o.is_delete = 0 and DATE(o.time) = DATE(NOW())
|
and o.server_id is not null
|
<if test="cityList != null and cityList.size() != 0">
|
and o.city_code in
|
<foreach collection="cityList" item="city" open="(" separator="," close=")">
|
#{city}
|
</foreach>
|
</if>
|
<if test="phone != null and phone != ''">
|
and o.server_phone like concat('%', #{phone}, '%')
|
</if>
|
<if test="name != null and name != ''">
|
and o.server_name like concat('%', #{name}, '%')
|
</if>
|
GROUP BY o.server_id
|
</select>
|
|
<select id="queryPage" resultMap="BaseResultMap">
|
select *
|
from t_order o
|
<where>
|
o.is_delete = 0
|
<if test="data.fake != null ">
|
and o.fake = #{data.fake}
|
</if>
|
<if test="data.address != null and data.address != ''">
|
and o.reservation_address like concat('%', #{data.address}, '%')
|
</if>
|
<if test="data.orderNumber != null and data.orderNumber != ''">
|
and o.order_number like concat('%', #{data.orderNumber}, '%')
|
</if>
|
<if test="data.cityName != null and data.cityName != ''">
|
and o.city like concat('%', #{data.cityName}, '%')
|
</if>
|
<if test="data.cityList != null and data.cityList.size() != 0">
|
and o.city_code in
|
<foreach collection="data.cityList" item="c" open="(" separator="," close=")">
|
#{c}
|
</foreach>
|
</if>
|
<if test="data.servIds != null and data.servIds.size() != 0">
|
and o.serve_id in
|
<foreach collection="data.servIds" item="c" open="(" separator="," close=")">
|
#{c}
|
</foreach>
|
</if>
|
|
<if test="data.reservationName != null and data.reservationName != ''">
|
and o.reservation_name like concat('%', #{data.reservationName}, '%')
|
</if>
|
<if test="data.reservationPhone != null and data.reservationPhone != ''">
|
and o.reservation_phone like concat('%', #{data.reservationPhone}, '%')
|
</if>
|
<if test="data.state != null">
|
and o.state = #{data.state}
|
</if>
|
<if test="data.type != null">
|
and o.type = #{data.type}
|
</if>
|
<if test="data.workerName != null and data.workerName != ''">
|
and o.server_name like concat('%', #{data.workerName}, '%')
|
</if>
|
<if test="data.workerPhone != null and data.workerPhone != ''">
|
and o.server_phone like concat('%', #{data.workerPhone}, '%')
|
</if>
|
<if test="data.serveName != null and data.serveName != ''">
|
and o.site_name like concat('%', #{data.serveName}, '%')
|
</if>
|
<if test="data.orderTimeStart != null and data.orderTimeStart != ''">
|
and DATE(o.createTime) <![CDATA[ >= ]]> #{data.orderTimeStart}
|
</if>
|
<if test="data.orderTimeEnd != null and data.orderTimeEnd != ''">
|
and DATE(o.createTime) <![CDATA[ <= ]]> #{data.orderTimeEnd}
|
</if>
|
<if test="data.startTime != null and data.startTime != ''">
|
and STR_TO_DATE(SUBSTRING_INDEX(time, ' - ', 1), '%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{data.startTime}
|
</if>
|
<if test="data.endTime != null and data.endTime != ''">
|
AND STR_TO_DATE(SUBSTRING_INDEX(time, ' - ', -1), '%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{data.endTime}
|
</if>
|
<if test="data.completeTimeStart != null and data.completeTimeStart != ''">
|
and DATE(o.complete_time) <![CDATA[ >= ]]> #{data.completeTimeStart}
|
</if>
|
<if test="data.completeTimeEnd != null and data.completeTimeEnd != ''">
|
and DATE(o.complete_time) <![CDATA[ <= ]]> #{data.completeTimeEnd}
|
</if>
|
</where>
|
order by o.createTime desc
|
</select>
|
|
<select id="orderPageCount" resultMap="BaseResultMap">
|
select o.*
|
from t_order o
|
<where>
|
o.is_delete = 0
|
<if test="data.cityList != null and data.cityList.size() != 0">
|
and o.city_code in
|
<foreach collection="data.cityList" item="city" open="(" separator="," close=")">
|
#{city}
|
</foreach>
|
</if>
|
|
<if test="data.servIds != null and data.servIds.size() != 0">
|
and o.serve_id in
|
<foreach collection="data.servIds" item="c" open="(" separator="," close=")">
|
#{c}
|
</foreach>
|
</if>
|
|
<if test="data.type !=null">
|
and o.type = #{data.type}
|
</if>
|
<if test="data.fake !=null">
|
and o.fake = #{data.fake}
|
</if>
|
<if test="data.address != null and data.address != ''">
|
and o.reservation_address like concat('%', #{data.address}, '%')
|
</if>
|
<if test="data.orderNumber != null and data.orderNumber != ''">
|
and o.order_number like concat('%', #{data.orderNumber}, '%')
|
</if>
|
<if test="data.cityName != null and data.cityName != ''">
|
and o.city like concat('%', #{data.cityName}, '%')
|
</if>
|
<if test="data.reservationName != null and data.reservationName != ''">
|
and o.reservation_name like concat('%', #{data.reservationName}, '%')
|
</if>
|
<if test="data.reservationPhone != null and data.reservationPhone != ''">
|
and o.reservation_phone like concat('%', #{data.reservationPhone}, '%')
|
</if>
|
<if test="data.workerName != null and data.workerName != ''">
|
and o.server_name like concat('%', #{data.workerName}, '%')
|
</if>
|
<if test="data.workerPhone != null and data.workerPhone != ''">
|
and o.server_phone like concat('%', #{data.workerPhone}, '%')
|
</if>
|
<if test="data.serveName != null and data.serveName != ''">
|
and o.site_name like concat('%', #{data.serveName}, '%')
|
</if>
|
<if test="data.orderTimeStart != null and data.orderTimeStart != ''">
|
and DATE(o.createTime) <![CDATA[ >= ]]> #{data.orderTimeStart}
|
</if>
|
<if test="data.orderTimeEnd != null and data.orderTimeEnd != ''">
|
and DATE(o.createTime) <![CDATA[ <= ]]> #{data.orderTimeEnd}
|
</if>
|
<if test="data.startTime != null and data.startTime != ''">
|
and STR_TO_DATE(SUBSTRING_INDEX(time, ' - ', 1), '%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{data.startTime}
|
</if>
|
<if test="data.endTime != null and data.endTime != ''">
|
AND STR_TO_DATE(SUBSTRING_INDEX(time, ' - ', -1), '%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{data.endTime}
|
</if>
|
</where>
|
</select>
|
|
<select id="exportByIdList" resultMap="BaseResultMap">
|
select reservation_name,
|
reservation_phone,
|
reservation_address,
|
time,
|
serve_name,
|
server_name,
|
server_phone,site_name
|
from t_order
|
<where>
|
id in
|
<foreach collection="list" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</where>
|
</select>
|
|
<select id="exportList" resultMap="BaseResultMap">
|
select *
|
from t_order o
|
<where>
|
o.is_delete = 0
|
<if test="data.fake != null ">
|
and o.fake = #{data.fake}
|
</if>
|
<if test="data.address != null and data.address != ''">
|
and o.reservation_address like concat('%', #{data.address}, '%')
|
</if>
|
<if test="data.servIds != null and data.servIds.size() != 0">
|
and o.serve_id in
|
<foreach collection="data.servIds" item="c" open="(" separator="," close=")">
|
#{c}
|
</foreach>
|
</if>
|
<if test="data.type != null">
|
and o.type = #{data.type}
|
</if>
|
<if test="data.orderNumber != null and data.orderNumber != ''">
|
and o.order_number like concat('%', #{data.orderNumber}, '%')
|
</if>
|
<if test="data.cityName != null and data.cityName != ''">
|
and o.city like concat('%', #{data.cityName}, '%')
|
</if>
|
<if test="data.reservationName != null and data.reservationName != ''">
|
and o.reservation_name like concat('%', #{data.reservationName}, '%')
|
</if>
|
<if test="data.reservationPhone != null and data.reservationPhone != ''">
|
and o.reservation_phone like concat('%', #{data.reservationPhone}, '%')
|
</if>
|
<if test="data.state != null">
|
and o.state = #{data.state}
|
</if>
|
<if test="data.workerName != null and data.workerName != ''">
|
and o.server_name like concat('%', #{data.workerName}, '%')
|
</if>
|
<if test="data.workerPhone != null and data.workerPhone != ''">
|
and o.server_phone like concat('%', #{data.workerPhone}, '%')
|
</if>
|
<if test="data.serveName != null and data.serveName != ''">
|
and o.site_name like concat('%', #{data.serveName}, '%')
|
</if>
|
<if test="data.orderTimeStart != null and data.orderTimeStart != ''">
|
and DATE(o.createTime) <![CDATA[ >= ]]> #{data.orderTimeStart}
|
</if>
|
<if test="data.orderTimeEnd != null and data.orderTimeEnd != ''">
|
and DATE(o.createTime) <![CDATA[ <= ]]> #{data.orderTimeEnd}
|
</if>
|
<if test="data.startTime != null and data.startTime != ''">
|
and STR_TO_DATE(SUBSTRING_INDEX(time, ' - ', 1), '%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{data.startTime}
|
</if>
|
<if test="data.endTime != null and data.endTime != ''">
|
AND STR_TO_DATE(SUBSTRING_INDEX(time, ' - ', -1), '%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{data.endTime}
|
</if>
|
</where>
|
order by o.createTime desc
|
</select>
|
|
<select id="orderListWorker" resultMap="BaseResultMap">
|
select o.*
|
from t_order o
|
<where>
|
o.is_delete = 0
|
and o.server_id = #{userId}
|
<choose>
|
<when test="state == 1">
|
and o.state in (1, 2)
|
</when>
|
<when test="state == 2">
|
and o.state = 3
|
</when>
|
<otherwise>
|
and o.state in (1, 2, 3)
|
</otherwise>
|
</choose>
|
</where>
|
order by o.createTime desc
|
</select>
|
|
<select id="workerOrderRank" resultType="com.ruoyi.order.vo.WorkerOrderRankVO">
|
select server_id as workerId, COUNT(server_id) as orderNumber
|
from t_order
|
<where>
|
is_delete = 0
|
<if test="ids != null and ids.size() != 0">
|
and server_id in
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
</where>
|
GROUP BY server_id
|
ORDER BY orderNumber desc
|
</select>
|
|
<select id="orderStateCount" resultType="com.ruoyi.order.vo.WorkerOrderCountVO">
|
SELECT COALESCE(SUM(CASE WHEN o.state IN (1, 2, 3) THEN 1 ELSE 0 END), 0) AS total,
|
COALESCE(SUM(CASE WHEN o.state in (1, 2) THEN 1 ELSE 0 END), 0) AS waitVisit,
|
COALESCE(SUM(CASE WHEN o.state = 3 THEN 1 ELSE 0 END), 0) AS completed
|
FROM t_order o
|
where o.server_id = #{workerId}
|
and o.is_delete = 0
|
</select>
|
|
<select id="orderCountByTimeRange" resultType="com.ruoyi.order.vo.OrderQueryVO">
|
SELECT DATE_FORMAT(createTime, '%Y-%m-%d') AS dateTime,
|
COUNT(*) AS number,
|
sum(IFNULL(order_money, 0)) as totalPrice,
|
COUNT(CASE WHEN fake = 1 THEN 1 END) AS fakeCount
|
FROM t_order
|
<where>
|
is_delete = 0
|
<if test="cityList != null and cityList.size() != 0">
|
and city_code in
|
<foreach collection="cityList" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="orderState != null">
|
and state = #{orderState}
|
</if>
|
<if test="startTime != null and startTime != ''">
|
and createTime <![CDATA[ >= ]]> #{startTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
and createTime <![CDATA[ <= ]]> #{endTime}
|
</if>
|
</where>
|
GROUP BY dateTime
|
order by dateTime
|
</select>
|
|
<select id="orderCountByTimeRangeYear" resultType="com.ruoyi.order.vo.OrderQueryVO">
|
SELECT DATE_FORMAT(createTime, '%Y') AS dateTime, COUNT(*) AS number, sum(IFNULL(order_money, 0)) as totalPrice,
|
COUNT(CASE WHEN fake = 1 THEN 1 END) AS fakeCount
|
FROM t_order
|
<where>
|
is_delete = 0
|
<if test="cityList != null and cityList.size() != 0">
|
and city_code in
|
<foreach collection="cityList" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="orderState != null">
|
and state = #{orderState}
|
</if>
|
<if test="startTime != null and startTime != ''">
|
and createTime <![CDATA[ >= ]]> #{startTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
and createTime <![CDATA[ <= ]]> #{endTime}
|
</if>
|
</where>
|
GROUP BY dateTime
|
order by dateTime
|
</select>
|
|
<select id="orderCountByTimeRangeMonth" resultType="com.ruoyi.order.vo.OrderQueryVO">
|
SELECT DATE_FORMAT(createTime, '%Y-%m') AS dateTime,
|
COUNT(*) AS number,
|
sum(IFNULL(order_money, 0)) as totalPrice,
|
COUNT(CASE WHEN fake = 1 THEN 1 END) AS fakeCount
|
FROM t_order
|
<where>
|
is_delete = 0
|
<if test="cityList != null and cityList.size() != 0">
|
and city_code in
|
<foreach collection="cityList" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="orderState != null">
|
and state = #{orderState}
|
</if>
|
<if test="startTime != null and startTime != ''">
|
and createTime <![CDATA[ >= ]]> #{startTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
and createTime <![CDATA[ <= ]]> #{endTime}
|
</if>
|
</where>
|
GROUP BY dateTime
|
order by dateTime
|
</select>
|
<select id="papercout" resultType="com.ruoyi.common.core.vo.PaperInVo">
|
select count(*) as count, serve_id as serveId from t_order
|
where is_delete = 0 and state = 3
|
and server_id = #{workId}
|
and `time` = #{date}
|
group by serve_id
|
|
</select>
|
|
</mapper>
|