mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-02-22 05:19:09 +08:00
153 lines
6.4 KiB
XML
153 lines
6.4 KiB
XML
<?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="cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsPerformanceMapper">
|
|
|
|
<select id="selectContractCountPerformance"
|
|
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO">
|
|
SELECT
|
|
t.time as time,
|
|
COALESCE(t.currentMonthCount,0) as currentMonthCount,
|
|
COALESCE(y.lastMonthCount,0) as lastMonthCount,
|
|
COALESCE(z.lastYearCount,0) as lastYearCount
|
|
FROM
|
|
(SELECT
|
|
COUNT(1) AS currentMonthCount,
|
|
DATE_FORMAT(order_date, '%Y-%m') AS time
|
|
FROM crm_contract
|
|
WHERE deleted = 0
|
|
AND audit_status = 20
|
|
AND owner_user_id in
|
|
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
|
#{userId}
|
|
</foreach>
|
|
AND DATE_FORMAT(order_date, '%Y') = DATE_FORMAT(#{times[0],javaType=java.time.LocalDateTime},'%Y')
|
|
GROUP BY time)t
|
|
LEFT JOIN
|
|
(SELECT
|
|
COUNT(1) AS lastMonthCount,
|
|
DATE_FORMAT(DATE_ADD(order_date,INTERVAL 1 MONTH), '%Y-%m') AS time
|
|
FROM crm_contract
|
|
WHERE deleted = 0
|
|
AND audit_status = 20
|
|
AND owner_user_id in
|
|
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
|
#{userId}
|
|
</foreach>
|
|
AND (DATE_FORMAT(order_date, '%Y') = DATE_FORMAT(#{times[0],javaType=java.time.LocalDateTime},'%Y')
|
|
or DATE_FORMAT(order_date, '%Y') = DATE_FORMAT(#{times[0],javaType=java.time.LocalDateTime},'%Y')-1)
|
|
GROUP BY time)y ON t.time = y.time
|
|
LEFT JOIN
|
|
(SELECT
|
|
COUNT(1) AS lastYearCount,
|
|
DATE_FORMAT(DATE_ADD(order_date,INTERVAL 1 YEAR), '%Y-%m') AS time
|
|
FROM crm_contract
|
|
WHERE deleted = 0
|
|
AND audit_status = 20
|
|
AND owner_user_id in
|
|
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
|
#{userId}
|
|
</foreach>
|
|
AND DATE_FORMAT(order_date, '%Y') = DATE_FORMAT(#{times[0],javaType=java.time.LocalDateTime},'%Y')-1
|
|
GROUP BY time)z ON t.time = z.time
|
|
</select>
|
|
<select id="selectContractPricePerformance"
|
|
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO">
|
|
SELECT
|
|
t.time as time,
|
|
COALESCE(t.currentMonthCount,0) as currentMonthCount,
|
|
COALESCE(y.lastMonthCount,0) as lastMonthCount,
|
|
COALESCE(z.lastYearCount,0) as lastYearCount
|
|
FROM
|
|
(SELECT
|
|
IFNULL(SUM(total_price), 0) AS currentMonthCount,
|
|
DATE_FORMAT(order_date, '%Y-%m') AS time
|
|
FROM crm_contract
|
|
WHERE deleted = 0
|
|
AND audit_status = 20
|
|
AND owner_user_id in
|
|
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
|
#{userId}
|
|
</foreach>
|
|
AND DATE_FORMAT(order_date, '%Y') = DATE_FORMAT(#{times[0],javaType=java.time.LocalDateTime},'%Y')
|
|
GROUP BY time)t
|
|
LEFT JOIN
|
|
(SELECT
|
|
IFNULL(SUM(total_price), 0) AS lastMonthCount,
|
|
DATE_FORMAT(DATE_ADD(order_date,INTERVAL 1 MONTH), '%Y-%m') AS time
|
|
FROM crm_contract
|
|
WHERE deleted = 0
|
|
AND audit_status = 20
|
|
AND owner_user_id in
|
|
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
|
#{userId}
|
|
</foreach>
|
|
AND (DATE_FORMAT(order_date, '%Y') = DATE_FORMAT(#{times[0],javaType=java.time.LocalDateTime},'%Y')
|
|
or DATE_FORMAT(order_date, '%Y') = DATE_FORMAT(#{times[0],javaType=java.time.LocalDateTime},'%Y')-1)
|
|
GROUP BY time)y ON t.time = y.time
|
|
LEFT JOIN
|
|
(SELECT
|
|
IFNULL(SUM(total_price), 0) AS lastYearCount,
|
|
DATE_FORMAT(DATE_ADD(order_date,INTERVAL 1 YEAR), '%Y-%m') AS time
|
|
FROM crm_contract
|
|
WHERE deleted = 0
|
|
AND audit_status = 20
|
|
AND owner_user_id in
|
|
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
|
#{userId}
|
|
</foreach>
|
|
AND DATE_FORMAT(order_date, '%Y') = DATE_FORMAT(#{times[0],javaType=java.time.LocalDateTime},'%Y')-1
|
|
GROUP BY time)z ON t.time = z.time
|
|
</select>
|
|
|
|
<select id="selectReceivablePricePerformance"
|
|
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO">
|
|
SELECT
|
|
t.time as time,
|
|
COALESCE(t.currentMonthCount,0) as currentMonthCount,
|
|
COALESCE(y.lastMonthCount,0) as lastMonthCount,
|
|
COALESCE(z.lastYearCount,0) as lastYearCount
|
|
FROM
|
|
(SELECT
|
|
IFNULL(SUM(price), 0) AS currentMonthCount,
|
|
DATE_FORMAT(return_time, '%Y-%m') AS time
|
|
FROM crm_receivable
|
|
WHERE deleted = 0
|
|
AND audit_status = 20
|
|
AND owner_user_id in
|
|
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
|
#{userId}
|
|
</foreach>
|
|
AND DATE_FORMAT(return_time, '%Y') = DATE_FORMAT(#{times[0],javaType=java.time.LocalDateTime},'%Y')
|
|
GROUP BY time)t
|
|
LEFT JOIN
|
|
(SELECT
|
|
IFNULL(SUM(price), 0) AS lastMonthCount,
|
|
DATE_FORMAT(DATE_ADD(return_time,INTERVAL 1 MONTH), '%Y-%m') AS time
|
|
FROM crm_receivable
|
|
WHERE deleted = 0
|
|
AND audit_status = 20
|
|
AND owner_user_id in
|
|
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
|
#{userId}
|
|
</foreach>
|
|
AND (DATE_FORMAT(return_time, '%Y') = DATE_FORMAT(#{times[0],javaType=java.time.LocalDateTime},'%Y')
|
|
or DATE_FORMAT(return_time, '%Y') = DATE_FORMAT(#{times[0],javaType=java.time.LocalDateTime},'%Y')-1)
|
|
GROUP BY time)y ON t.time = y.time
|
|
LEFT JOIN
|
|
(SELECT
|
|
IFNULL(SUM(price), 0) AS lastYearCount,
|
|
DATE_FORMAT(DATE_ADD(return_time,INTERVAL 1 YEAR), '%Y-%m') AS time
|
|
FROM crm_receivable
|
|
WHERE deleted = 0
|
|
AND audit_status = 20
|
|
AND owner_user_id in
|
|
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
|
#{userId}
|
|
</foreach>
|
|
AND DATE_FORMAT(return_time, '%Y') = DATE_FORMAT(#{times[0],javaType=java.time.LocalDateTime},'%Y')-1
|
|
GROUP BY time)z ON t.time = z.time
|
|
</select>
|
|
|
|
|
|
</mapper>
|