<?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.stylefeng.guns.modular.system.dao.IncomeMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.Income">
|
<id column="id" property="id"/>
|
<result column="userType" property="userType"/>
|
<result column="objectId" property="objectId"/>
|
<result column="type" property="type"/>
|
<result column="incomeId" property="incomeId"/>
|
<result column="orderType" property="orderType"/>
|
<result column="money" property="money"/>
|
<result column="insertTime" property="insertTime"/>
|
</resultMap>
|
<select id="getList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
|
SELECT
|
date_format(insertTime, '%Y-%m-%d') times,
|
SUM(
|
CASE
|
WHEN type = 1 THEN
|
money
|
ELSE
|
0
|
END
|
) activityMoney,
|
SUM(
|
CASE
|
WHEN type = 1 THEN
|
0
|
ELSE
|
money
|
END
|
) orderMoney
|
FROM
|
t_income
|
WHERE userType=2 AND objectId=#{id}
|
GROUP BY
|
date_format(insertTime, '%Y-%m-%d')
|
ORDER BY date_format(insertTime, '%Y-%m-%d') DESC
|
</select>
|
<select id="getExcelList" resultType="map">
|
SELECT
|
date_format(insertTime, '%Y-%m-%d') times,
|
SUM(
|
CASE
|
WHEN type = 1 THEN
|
money
|
ELSE
|
0
|
END
|
) activityMoney,
|
SUM(
|
CASE
|
WHEN type = 1 THEN
|
0
|
ELSE
|
money
|
END
|
) orderMoney
|
FROM
|
t_income
|
WHERE userType=2 AND objectId=#{id}
|
GROUP BY
|
date_format(insertTime, '%Y-%m-%d')
|
ORDER BY date_format(insertTime, '%Y-%m-%d') DESC
|
</select>
|
<select id="getList1" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
|
SELECT
|
date_format(startTime, '%Y-%m-%d') times
|
FROM
|
t_driver_work
|
GROUP BY
|
date_format(startTime, '%Y-%m-%d')
|
ORDER BY
|
date_format(startTime, '%Y-%m-%d') DESC
|
</select>
|
<select id="getList2" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
|
SELECT
|
w.driverId,
|
d. NAME,
|
o.timeNumber
|
FROM
|
t_driver_work w
|
LEFT JOIN t_driver d ON d.id = w.driverId
|
LEFT JOIN (
|
SELECT
|
IFNULL(SUM(o.timeNumber), 0) timeNumber,
|
driverId
|
FROM
|
(
|
SELECT
|
TIMESTAMPDIFF(
|
MINUTE,
|
startTime,
|
CASE
|
WHEN endTime IS NULL THEN
|
NOW()
|
ELSE
|
endTime
|
END
|
) timeNumber,
|
driverId
|
FROM
|
t_driver_work
|
WHERE
|
date_format(startTime, '%Y-%m-%d') = #{times}
|
|
) o GROUP BY
|
driverId
|
) o ON o.driverId = d.id
|
WHERE
|
date_format(startTime, '%Y-%m-%d') = #{times}
|
GROUP BY
|
w.driverId
|
</select>
|
<select id="getTotal" resultType="map">
|
SELECT COUNT(o.driverId) driverNum,SUM(o.timeNumber) timeNumber from (SELECT
|
w.driverId,
|
d. NAME,
|
o.timeNumber
|
FROM
|
t_driver_work w
|
LEFT JOIN t_driver d ON d.id = w.driverId
|
LEFT JOIN (
|
SELECT
|
IFNULL(SUM(o.timeNumber), 0) timeNumber,
|
driverId
|
FROM
|
(
|
SELECT
|
TIMESTAMPDIFF(
|
MINUTE,
|
startTime,
|
CASE
|
WHEN endTime IS NULL THEN
|
NOW()
|
ELSE
|
endTime
|
END
|
) timeNumber,
|
driverId
|
FROM
|
t_driver_work
|
WHERE
|
date_format(startTime, '%Y-%m-%d') = #{times}
|
|
) o GROUP BY
|
driverId
|
) o ON o.driverId = d.id
|
WHERE
|
date_format(startTime, '%Y-%m-%d') = #{times}
|
GROUP BY
|
w.driverId) o
|
</select>
|
</mapper>
|