code review:销售统计

This commit is contained in:
YunaiV 2024-04-18 09:19:07 +08:00
parent cc82e471ea
commit b20ff55511

View File

@ -3,19 +3,23 @@
<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsFunnelMapper"> <mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsFunnelMapper">
<select id="selectCustomerCountByDate" resultType="java.lang.Long"> <select id="selectCustomerCountByDate" resultType="java.lang.Long">
SELECT COUNT(*) SELECT
COUNT(*)
FROM crm_customer FROM crm_customer
WHERE deleted = 0 WHERE deleted = 0
AND owner_user_id IN AND owner_user_id IN
<!-- TODO @puhui999这个 foreach 搞个缩进哈 - -->
<foreach collection="userIds" item="userId" open="(" close=")" separator=","> <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId} #{userId}
</foreach> </foreach>
AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND
<!-- TODO @puhui999下面这个就不缩进啦 - -->
#{times[1],javaType=java.time.LocalDateTime} #{times[1],javaType=java.time.LocalDateTime}
</select> </select>
<select id="selectBusinessCountByDateAndEndStatus" resultType="java.lang.Long"> <select id="selectBusinessCountByDateAndEndStatus" resultType="java.lang.Long">
SELECT COUNT(*) SELECT
COUNT(*)
FROM crm_business FROM crm_business
WHERE deleted = 0 WHERE deleted = 0
<if test="status != null"> <if test="status != null">
@ -31,7 +35,10 @@
<select id="selectBusinessSummaryListGroupByEndStatus" <select id="selectBusinessSummaryListGroupByEndStatus"
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByEndStatusRespVO"> resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByEndStatusRespVO">
SELECT end_status AS endStatus,COUNT(*) AS businessCount, SUM(total_price) AS totalPrice SELECT
end_status AS endStatus,
COUNT(*) AS businessCount,
SUM(total_price) AS totalPrice
FROM crm_business FROM crm_business
WHERE deleted = 0 AND end_status IS NOT NULL WHERE deleted = 0 AND end_status IS NOT NULL
AND owner_user_id IN AND owner_user_id IN
@ -46,9 +53,9 @@
<select id="selectBusinessSummaryGroupByDate" <select id="selectBusinessSummaryGroupByDate"
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByDateRespVO"> resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByDateRespVO">
SELECT SELECT
DATE_FORMAT(create_time, '%Y-%m-%d') AS time, DATE_FORMAT(create_time, '%Y-%m-%d') AS time,
COUNT(*) AS businessCreateCount, COUNT(*) AS businessCreateCount,
SUM(total_price) AS totalPrice SUM(total_price) AS totalPrice
FROM crm_business FROM crm_business
WHERE deleted = 0 WHERE deleted = 0
AND owner_user_id IN AND owner_user_id IN
@ -63,9 +70,9 @@
<select id="selectBusinessInversionRateSummaryByDate" <select id="selectBusinessInversionRateSummaryByDate"
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessInversionRateSummaryByDateRespVO"> resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessInversionRateSummaryByDateRespVO">
SELECT SELECT
DATE_FORMAT(create_time, '%Y-%m-%d') AS time, DATE_FORMAT(create_time, '%Y-%m-%d') AS time,
COUNT(*) AS businessCount, COUNT(*) AS businessCount,
SUM(IF(end_status = 1, 1, 0)) AS businessWinCount SUM(IF(end_status = 1, 1, 0)) AS businessWinCount
FROM crm_business FROM crm_business
WHERE deleted = 0 WHERE deleted = 0
AND owner_user_id IN AND owner_user_id IN