Files
FrameTour-BE/src/main/resources/mapper/StatisticsMapper.xml
2025-04-30 18:28:36 +08:00

293 lines
10 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="com.ycwl.basic.mapper.StatisticsMapper">
<insert id="addStatisticsRecord">
insert into statistics(member_id,type,morph_id,scenic_id)
value (#{memberId},#{type},#{morphId},#{scenicId})
</insert>
<select id="countOrderAmount" resultType="java.math.BigDecimal">
select ifnull(sum(pay_price),0) as payPrice
from `order`
where
(status = 1 or 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>
<select id="countPreviewVideoOfMember" resultType="java.lang.Integer">
SELECT
IFNULL(count(1), 0) AS count
FROM (
select count(1) as count
FROM `t_stats_record` r
left join `t_stats` s on r.trace_id=s.trace_id
where r.trace_id in (select trace_id from `t_stats_record` where action = "ENTER_SCENIC" and `identifier`=#{scenicId})
and action = "LOAD"
and identifier = "pages/videoSynthesis/buy"
and JSON_EXTRACT(`params`, '$.share') is null
<if test="startTime!= null">
and r.create_time >= #{startTime}
</if>
<if test="endTime!= null">
and r.create_time &lt;= #{endTime}
</if>
group by s.member_id
)a
</select>
<select id="countScanCodeOfMember" resultType="java.lang.Integer">
SELECT
IFNULL(count(1), 0) AS count
FROM (
select 1
FROM `t_stats_record` r
left join `t_stats` s on r.trace_id=s.trace_id
where r.trace_id in (select trace_id from `t_stats_record` where action = "ENTER_SCENIC" and `identifier`=#{scenicId})
and action = "LAUNCH"
and JSON_EXTRACT(`params`, '$.scene') in (1047,1048,1049)
<if test="startTime!= null">
and s.create_time >= #{startTime}
</if>
<if test="endTime!= null">
and s.create_time &lt;= #{endTime}
</if>
group by s.member_id
) AS subquery;
</select>
<select id="countClickPayOfMember" resultType="java.lang.Integer">
SELECT
IFNULL(count(1), 0) AS count
FROM (
select count(1) as count
from `order`
where scenic_id = #{scenicId}
<if test="startTime!= null">
and create_at >= #{startTime}
</if>
<if test="endTime!= null">
and create_at &lt;= #{endTime}
</if>
group by member_id
)a
</select>
<select id="countPayOfMember" resultType="java.lang.Integer">
SELECT
IFNULL(count(1), 0) AS count
FROM (
select count(1) as count
from `statistics`
where scenic_id = #{scenicId} and type in (3,4)
<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(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="countPushOrderNum" resultType="java.lang.Integer">
SELECT
IFNULL(count(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="countPushOfMember" resultType="java.lang.Integer">
SELECT
IFNULL(count(1), 0) AS count
FROM (
select count(1) as count
FROM `t_stats_record` r
left join `t_stats` s on r.trace_id=s.trace_id
where r.trace_id in (select trace_id from `t_stats_record` where action = "ENTER_SCENIC" and `identifier`=#{scenicId})
and action = "PERM_REQ" and identifier = "NOTIFY"
<if test="startTime!= null">
and r.create_time >= #{startTime}
</if>
<if test="endTime!= null">
and r.create_time &lt;= #{endTime}
</if>
group by s.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 ifnull(count(1),0) as count
from(
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>
group by member_id
) a
</select>
<select id="countCompleteVideoOfMember" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
from(
select 1
from video v
left join task t on v.task_id = t.id
left join face f on f.id = t.face_id
where f.scenic_id = #{scenicId}
<if test="startTime!= null">
and v.create_time >= #{startTime}
</if>
<if test="endTime!= null">
and v.create_time &lt;= #{endTime}
</if>
group by f.member_id
)a
</select>
<select id="countTotalVisitorOfMember" resultType="java.lang.Integer">
SELECT
IFNULL(count(1), 0) AS count
FROM (
select 1
FROM `t_stats_record` r
left join `t_stats` s on r.trace_id=s.trace_id
where r.trace_id in (select trace_id from `t_stats_record` where action = "ENTER_SCENIC" and `identifier`=#{scenicId})
and action = "LAUNCH"
<if test="startTime!= null">
and s.create_time >= #{startTime}
</if>
<if test="endTime!= null">
and s.create_time &lt;= #{endTime}
</if>
group by s.member_id
) AS subquery;
</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 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 `t_stats_record` r
left join `t_stats` s on r.trace_id=s.trace_id
where r.trace_id in (select trace_id from `t_stats_record` where action = "ENTER_SCENIC" and `identifier`=#{scenicId})
and action = "LOAD" and identifier = "pages/videoSynthesis/buy"
<if test="startTime!= null">
and s.create_time >= #{startTime}
</if>
<if test="endTime!= null">
and s.create_time &lt;= #{endTime}
</if>
group by JSON_EXTRACT(`params`, "$.id")
)a
</select>
<select id="countPayOfOrder" resultType="java.lang.Integer">
select count(1) as count
from `order`
where
pay_at is not null and 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="countRefundOfOrder" resultType="java.lang.Integer">
select count(1) as count
from `order`
where
refund_status = 1 and 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="countRefundAmount" resultType="java.math.BigDecimal">
select ifnull(sum(pay_price),0) as payPrice
from `order`
where
refund_status = 1 and 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="getBrokerIdListForUser" resultType="java.lang.Long">
select identifier
from (
select identifier, max(r.create_time) as createTime
FROM `t_stats_record` r
left join `t_stats` s on r.trace_id=s.trace_id
where action = "CODE_SCAN"
and s.member_id = #{memberId}
<if test="startTime!= null">
and r.create_time >= #{startTime}
</if>
<if test="endTime!= null">
and r.create_time &lt;= #{endTime}
</if>
group by identifier
) a
order by createTime desc
</select>
<select id="getUserRecentEnterType" resultType="java.lang.Long">
select JSON_EXTRACT(`params`, '$.scene')
FROM `t_stats_record` r
left join `t_stats` s on r.trace_id=s.trace_id
where action = "LAUNCH" and s.member_id = #{memberId}
<if test="endTime!= null">
and r.create_time &lt;= #{endTime}
</if>
order by r.create_time desc
limit 1
</select>
</mapper>