实现“用户转化漏斗统计”

This commit is contained in:
longbinbin
2024-12-12 18:26:11 +08:00
parent 9d22f9d8cf
commit 715c351f5f
6 changed files with 426 additions and 86 deletions

View File

@ -6,95 +6,242 @@
from `order`
where
status = 1 and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
<if test="startTime!= null">
and create_at >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
<if test="endTime!= null">
and create_at &lt;= #{endTime}
</if>
</select>
<select id="countPreviewOfMember" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
from statistics
where type=2 and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
and create_time &lt;= #{endTime}
</if>
group by member_id
<select id="countPreviewVideoOfMember" resultType="java.lang.Integer">
SELECT
IFNULL(SUM(count), 0) AS count
FROM (
select count(1) as count
from statistics
where type=2 and scenic_id = #{scenicId}
<if test="startTime!= null">
and create_time >= #{startTime}
</if>
<if test="endTime!= null">
and create_time &lt;= #{endTime}
</if>
group by member_id
)a
</select>
<select id="countScanCodeOfMember" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
from statistics
where type=0 and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
and create_time &lt;= #{endTime}
</if>
group by member_id
SELECT
IFNULL(SUM(count), 0) AS count
FROM (
select count(1) as count
from statistics
where type=0 and scenic_id = #{scenicId}
<if test="startTime!= null">
and create_time >= #{startTime}
</if>
<if test="endTime!= null">
and create_time &lt;= #{endTime}
</if>
group by member_id
) AS subquery;
</select>
<select id="countClickPayOfMember" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
from statistics
where type=9 and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
and create_time &lt;= #{endTime}
</if>
group by member_id
SELECT
IFNULL(SUM(count), 0) AS count
FROM (
select count(1) as count
from statistics
where type=9 and scenic_id = #{scenicId}
<if test="startTime!= null">
and create_time >= #{startTime}
</if>
<if test="endTime!= null">
and create_time &lt;= #{endTime}
</if>
group by member_id
)a
</select>
<select id="countPayOfMember" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
from statistics
where type in(3,4) and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
and create_time &lt;= #{endTime}
</if>
group by member_id
SELECT
IFNULL(SUM(count), 0) AS count
FROM (
select count(1) as count
from statistics
where type in(3,4) and scenic_id = #{scenicId}
<if test="startTime!= null">
and create_time >= #{startTime}
</if>
<if test="endTime!= null">
and create_time &lt;= #{endTime}
</if>
group by member_id
)a
</select>
<select id="countSceneOrderNum" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
from statistics
where type=3 and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
and create_time &lt;= #{endTime}
</if>
group by morph_id
SELECT
IFNULL(SUM(count), 0) AS count
FROM (
select count(1) as count
from statistics
where type=3 and scenic_id = #{scenicId}
<if test="startTime!= null">
and create_time >= #{startTime}
</if>
<if test="endTime!= null">
and create_time &lt;= #{endTime}
</if>
group by morph_id
)a
</select>
<select id="countPushOrderNum" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
from statistics
where type=4 and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
SELECT
IFNULL(SUM(count), 0) AS count
FROM (
select count(1) as count
from statistics
where type=4 and scenic_id = #{scenicId}
<if test="startTime!= null">
and create_time >= #{startTime}
</if>
<if test="endTime!= null">
and create_time &lt;= #{endTime}
</if>
group by morph_id
)a
</select>
<select id="countPushOfMember" resultType="java.lang.Integer">
SELECT
IFNULL(SUM(count), 0) AS count
FROM (
select count(1) as count
from statistics
where type=6 and scenic_id = #{scenicId}
<if test="startTime!= null">
and create_time >= #{startTime}
</if>
<if test="endTime!= null">
and create_time &lt;= #{endTime}
</if>
group by member_id
)a
</select>
<select id="countCameraShotOfMember" resultType="java.lang.Integer">
select count(1) as count
from face_sample
where scenic_id = #{scenicId}
<if test="startTime!= null">
and create_at >= #{startTime}
</if>
<if test="endTime!= null">
and create_at &lt;= #{endTime}
</if>
</select>
<select id="countUploadFaceOfMember" resultType="java.lang.Integer">
select count(1) as count
from face
where scenic_id = #{scenicId}
<if test="startTime!= null">
and create_at >= #{startTime}
</if>
<if test="endTime!= null">
and create_at &lt;= #{endTime}
</if>
</select>
<select id="countCompleteVideoOfMember" resultType="java.lang.Integer">
select ifnull(sum(count),0) as count
from(
select count(1) as count
from video
where scenic_id = #{scenicId}
<if test="startTime!= null">
and create_time >= #{startTime}
</if>
<if test="endTime!= null">
and create_time &lt;= #{endTime}
</if>
group by member_id
)a
</select>
<select id="countTotalVisitorOfMember" resultType="java.lang.Integer">
SELECT
IFNULL(SUM(count), 0) AS count
FROM (
select count(1) as count
from statistics
where type=0 and scenic_id = #{scenicId}
<if test="startTime!= null">
and create_time >= #{startTime}
</if>
<if test="endTime!= null">
and create_time &lt;= #{endTime}
</if>
group by member_id
) AS a;
</select>
<select id="countCompleteOfVideo" resultType="java.lang.Integer">
select count(1) as count
from video
where scenic_id = #{scenicId}
<if test="startTime!= null">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
<if test="endTime!= null">
and create_time &lt;= #{endTime}
</if>
</select>
<select id="countPreviewOfVideo" resultType="java.lang.Integer">
SELECT
IFNULL(SUM(count), 0) AS count
FROM (
select count(1) as count
from statistics
where type=0 and scenic_id = #{scenicId}
<if test="startTime!= null">
and create_time >= #{startTime}
</if>
<if test="endTime!= null">
and create_time &lt;= #{endTime}
</if>
group by morph_id
)a
</select>
<select id="countPayOfOrder" resultType="java.lang.Integer">
SELECT
IFNULL(SUM(count), 0) AS count
FROM (
select count(1) as count
from statistics
where type in(3,4) and scenic_id = #{scenicId}
<if test="startTime!= null">
and create_time >= #{startTime}
</if>
<if test="endTime!= null">
and create_time &lt;= #{endTime}
</if>
group by morph_id
)a
</select>
<select id="countPushOfMember" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
<select id="countRefundOfOrder" resultType="java.lang.Integer">
select count(1) as count
from statistics
where type=6 and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
where type =5 and scenic_id = #{scenicId}
<if test="startTime!= null">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
<if test="endTime!= null">
and create_time &lt;= #{endTime}
</if>
group by member_id
</select>
<select id="countRefundAmount" resultType="java.math.BigDecimal">
select ifnull(sum(pay_price),0) as payPrice
from `order`
where
status = 2 and scenic_id = #{scenicId}
<if test="startTime!= null">
and create_at >= #{startTime}
</if>
<if test="endTime!= null">
and create_at &lt;= #{endTime}
</if>
</select>
</mapper>