|
@ -87,79 +87,30 @@ |
|
|
<!-- 第二个查询:getTwo --> |
|
|
<!-- 第二个查询:getTwo --> |
|
|
<select id="getTwo" resultType="com.example.demo.domain.work.Two"> |
|
|
<select id="getTwo" resultType="com.example.demo.domain.work.Two"> |
|
|
SELECT |
|
|
SELECT |
|
|
COALESCE((SELECT SUM(recharge_coin + free_coin + task_coin) |
|
|
|
|
|
FROM detail_y |
|
|
|
|
|
WHERE YEAR(create_time) = YEAR(CURDATE()) |
|
|
|
|
|
AND update_type = 0 |
|
|
|
|
|
<if test="areas != null"> |
|
|
|
|
|
AND area IN |
|
|
|
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")"> |
|
|
|
|
|
#{areas} |
|
|
|
|
|
</foreach> |
|
|
|
|
|
</if>), 0) AS totalgold, |
|
|
|
|
|
|
|
|
|
|
|
COALESCE((SELECT SUM(recharge_coin) |
|
|
|
|
|
FROM detail_y |
|
|
|
|
|
WHERE YEAR(create_time) = YEAR(CURDATE()) |
|
|
|
|
|
AND update_type = 0 |
|
|
|
|
|
<if test="areas != null"> |
|
|
|
|
|
AND area IN |
|
|
|
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")"> |
|
|
|
|
|
#{areas} |
|
|
|
|
|
</foreach> |
|
|
|
|
|
</if>), 0) AS totalcoin, |
|
|
|
|
|
|
|
|
|
|
|
COALESCE((SELECT SUM(recharge_coin + free_coin + task_coin) |
|
|
|
|
|
FROM detail_y |
|
|
|
|
|
WHERE DATE(create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY) |
|
|
|
|
|
AND update_type = 0 |
|
|
|
|
|
<if test="areas != null"> |
|
|
|
|
|
AND area IN |
|
|
|
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")"> |
|
|
|
|
|
#{areas} |
|
|
|
|
|
</foreach> |
|
|
|
|
|
</if>), 0) AS yesterdaytotal, |
|
|
|
|
|
|
|
|
|
|
|
COALESCE((SELECT SUM(recharge_coin) |
|
|
|
|
|
FROM detail_y |
|
|
|
|
|
WHERE DATE(create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY) |
|
|
|
|
|
AND update_type = 0 |
|
|
|
|
|
<if test="areas != null"> |
|
|
|
|
|
AND area IN |
|
|
|
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")"> |
|
|
|
|
|
#{areas} |
|
|
|
|
|
</foreach> |
|
|
|
|
|
</if>), 0) AS yesterdayrecharge, |
|
|
|
|
|
COALESCE((SELECT SUM(recharge_coin) |
|
|
|
|
|
FROM detail_y |
|
|
|
|
|
WHERE YEAR(create_time) = YEAR(CURDATE()) |
|
|
|
|
|
AND update_type = 0 |
|
|
|
|
|
<if test="areas != null"> |
|
|
|
|
|
AND area IN |
|
|
|
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")"> |
|
|
|
|
|
#{areas} |
|
|
|
|
|
</foreach> |
|
|
|
|
|
</if>), 0) AS rechargegold, |
|
|
|
|
|
COALESCE((SELECT SUM(free_coin) |
|
|
|
|
|
FROM detail_y |
|
|
|
|
|
WHERE YEAR(create_time) = YEAR(CURDATE()) |
|
|
|
|
|
AND update_type = 0 |
|
|
|
|
|
<if test="areas != null"> |
|
|
|
|
|
AND area IN |
|
|
|
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")"> |
|
|
|
|
|
#{areas} |
|
|
|
|
|
</foreach> |
|
|
|
|
|
</if>), 0) AS freegold, |
|
|
|
|
|
COALESCE((SELECT SUM(task_coin) |
|
|
|
|
|
|
|
|
COALESCE(SUM(CASE WHEN year_flag = 1 THEN total_coin ELSE 0 END), 0) AS totalgold, |
|
|
|
|
|
COALESCE(SUM(CASE WHEN year_flag = 1 THEN recharge_coin ELSE 0 END), 0) AS totalcoin, |
|
|
|
|
|
COALESCE(SUM(CASE WHEN yesterday_flag = 1 THEN total_coin ELSE 0 END), 0) AS yesterdaytotal, |
|
|
|
|
|
COALESCE(SUM(CASE WHEN yesterday_flag = 1 THEN recharge_coin ELSE 0 END), 0) AS yesterdayrecharge, |
|
|
|
|
|
COALESCE(SUM(CASE WHEN year_flag = 1 THEN recharge_coin ELSE 0 END), 0) AS rechargegold, |
|
|
|
|
|
COALESCE(SUM(CASE WHEN year_flag = 1 THEN free_coin ELSE 0 END), 0) AS freegold, |
|
|
|
|
|
COALESCE(SUM(CASE WHEN year_flag = 1 THEN task_coin ELSE 0 END), 0) AS taskgold |
|
|
|
|
|
FROM ( |
|
|
|
|
|
SELECT |
|
|
|
|
|
recharge_coin, |
|
|
|
|
|
free_coin, |
|
|
|
|
|
task_coin, |
|
|
|
|
|
recharge_coin + free_coin + task_coin AS total_coin, |
|
|
|
|
|
YEAR(create_time) = YEAR(CURDATE()) AS year_flag, |
|
|
|
|
|
DATE(create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY) AS yesterday_flag |
|
|
FROM detail_y |
|
|
FROM detail_y |
|
|
WHERE YEAR(create_time) = YEAR(CURDATE()) |
|
|
|
|
|
AND update_type = 0 |
|
|
|
|
|
|
|
|
WHERE update_type = 0 |
|
|
<if test="areas != null"> |
|
|
<if test="areas != null"> |
|
|
AND area IN |
|
|
AND area IN |
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")"> |
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")"> |
|
|
#{areas} |
|
|
|
|
|
|
|
|
#{area} |
|
|
</foreach> |
|
|
</foreach> |
|
|
</if>), 0) AS taskgold |
|
|
|
|
|
|
|
|
</if> |
|
|
|
|
|
) AS subquery |
|
|
</select> |
|
|
</select> |
|
|
|
|
|
|
|
|
<!-- 第三个查询:getThree --> |
|
|
<!-- 第三个查询:getThree --> |
|
|