ShiShiYiBan/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMap...

61 lines
3.0 KiB
XML
Raw Normal View History

2024-03-15 12:09:19 +08:00
<?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
2024-04-23 23:12:36 +08:00
DATE_FORMAT(order_date, '%Y%m') AS time,
COUNT(1) AS currentMonthCount
FROM crm_contract
2024-03-15 12:09:19 +08:00
WHERE deleted = 0
2024-04-23 23:12:36 +08:00
<!-- TODO @scholar20 改成静态类引入 -->
2024-03-15 12:09:19 +08:00
AND audit_status = 20
AND owner_user_id in
2024-04-23 23:12:36 +08:00
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
<!-- TODO @scholarCrmStatisticsPerformanceReqVO 传递 year然后 java 代码里,转换出 times这样order_time 使用范围查询,避免使用函数 -->
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
2024-03-15 12:09:19 +08:00
</select>
2024-04-23 23:12:36 +08:00
<!-- TODO @scholar参考上面调整下这个 SQL 的排版、和代码建议哈 -->
2024-03-15 12:09:19 +08:00
<select id="selectContractPricePerformance"
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO">
SELECT
DATE_FORMAT(order_date, '%Y%m') AS time,
IFNULL(SUM(total_price), 0) AS currentMonthCount
2024-03-15 12:09:19 +08:00
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
2024-03-15 12:09:19 +08:00
</select>
2024-04-23 23:12:36 +08:00
<!-- TODO @scholar参考上面调整下这个 SQL 的排版、和代码建议哈 -->
2024-03-15 12:09:19 +08:00
<select id="selectReceivablePricePerformance"
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO">
SELECT
DATE_FORMAT(return_time, '%Y%m') AS time,
IFNULL(SUM(price), 0) AS currentMonthCount
2024-03-15 12:09:19 +08:00
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
2024-03-15 12:09:19 +08:00
</select>
</mapper>