zhwl/zhwl-business/zhwl-statistics/target/classes/mapper/statistics/VisualLargeScreenMapper.xml
2025-07-01 17:54:58 +08:00

275 lines
12 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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.zhwl.statistics.mapper.VisualLargeScreenMapper">
<select id="countTravelAgencyQuantity" resultType="long">
select count(1)
from zdy_travel_agency_info a
inner join sys_user b on a.sys_user_id = b.user_id
<where>
b.del_flag = '0'
${params.dataScope}
</where>
</select>
<select id="countDeviceGateQuantity" resultType="long">
select count(1)
from zdy_device_gate g
<where>
del_flag != 1
${params.dataScope}
</where>
</select>
<select id="countByPointType" parameterType="com.zhwl.common.core.domain.BaseEntity" resultType="long">
select count(1)
from zdy_point_data a
left join zdy_point_type b on a.point_type_id = b.id
<where>
a.del_flag = '0'
and b.del_flag = '0'
and b.potype_name = #{params.type}
${params.dataScope}
</where>
</select>
<select id="countHandsetQuantity" resultType="long">
select count(1)
from zdy_device_handheld h
<where>
del_flag = '0'
${params.dataScope}
</where>
</select>
<select id="thisMonthTicketHotList"
resultType="com.zhwl.statistics.domain.vo.ECharsVO">
select b.name `name`, a.`value`
from (select d.ticket_id, count(d.id) `value`
from zdy_ticket_order_detail d left join zdy_ticket_order_item i on d.order_item_id =i.id
<where>
d.del_flag = '0'
and d.payment_type = 200
and d.create_time >= CURRENT_DATE - INTERVAL DAY(CURRENT_DATE) - 1 DAY
${params.dataScope}
</where>
group by d.ticket_id) a
left join zdy_ticket b
on a.ticket_id = b.id
order by a.`value` desc limit 5
</select>
<select id="thisMonthTicketSalesChannelStatistic"
resultType="com.zhwl.statistics.domain.vo.ECharsVO">
select zto.order_source `name`, count(ztod.id) `value`
from zdy_ticket_order_detail ztod
left join zdy_ticket_order_item ztoi on ztod.order_item_id = ztoi.id
left join zdy_ticket_order zto on ztoi.order_id = zto.id
where ztod.del_flag = '0'
and ztod.payment_type = 200
and ztod.create_time >= CURRENT_DATE - INTERVAL DAY (CURRENT_DATE) - 1 DAY ${params.dataScope}
group by zto.order_source
order by `value` desc
</select>
<select id="thisMonthTicketSalesSum" resultType="long">
select count(ztod.id)
from zdy_ticket_order_detail ztod
left join zdy_ticket_order_item ztoi
on ztod.order_item_id = ztoi.id
where ztod.payment_type = 200
and ztod.del_flag = '0'
and ztod.create_time >= CURRENT_DATE - INTERVAL DAY (CURRENT_DATE) - 1 DAY ${params.dataScope}
</select>
<select id="pass12MonthTicketStatistics" resultType="com.zhwl.statistics.domain.vo.ECharsVO">
SELECT DATE_FORMAT(create_time, '%Y-%m') `name`, sum(ifnull(buy_quantity, 0)) `value`
FROM zdy_ticket_order_item ztoi
WHERE del_flag = 0
and payment_type = 200
and create_time >= CURDATE() - INTERVAL 1 YEAR ${params.dataScope}
GROUP BY `name`
order by `name` asc
</select>
<select id="pass12MonthVerificationOrderStatistics" resultType="com.zhwl.statistics.domain.vo.ECharsVO">
select DATE_FORMAT(t.create_time, '%Y-%m') `name`, sum(ifnull(buy_quantity, 0)) `value`
from (select MAX(a.create_time) create_time, MAX(a.buy_quantity) buy_quantity
from zdy_ticket_order_detail a
left join zdy_ticket_order_detail_child b on a.id = b.order_detail_id
left join zdy_ticket_order_item ztoi on a.order_item_id = ztoi.id
WHERE a.del_flag = 0
and a.payment_type = 200
and a.create_time >= CURDATE() - INTERVAL 1 YEAR
and (a.verification_time is not null
or b.verification_time is not null ) ${params.dataScope}
group by a.id) t
GROUP BY `name`
order by `name` asc
</select>
<select id="pass12MonthSaleAmountStatistics" resultType="com.zhwl.statistics.domain.vo.ECharsVO">
SELECT DATE_FORMAT(ztod.create_time, '%Y-%m') `name`,
sum(ifnull(ztod.actua_amount, 0)) `value`
FROM zdy_ticket_order_detail ztod
left join zdy_ticket_order_item ztoi
on ztod.order_item_id = ztoi.id
WHERE ztod.del_flag = 0
and ztod.payment_type = 200
and ztod.create_time >= CURDATE() - INTERVAL 1 YEAR ${params.dataScope}
GROUP BY `name`
order by `name` asc
</select>
<select id="todayOrderCount" resultType="long">
select count(1) todayOrderCount
from (SELECT 1
FROM zdy_ticket_order_item ztoi
left join zdy_ticket_order zto on ztoi.order_id = zto.id
WHERE ztoi.del_flag = 0
and ztoi.payment_type = 200
and DATE (ztoi.create_time) = CURDATE() ${params.dataScope}
group by zto.id) a
</select>
<!--核销次数不为0 即为已核销,考虑套票和年卡情况-->
<select id="todayVerificationOrderCount" resultType="long">
select count(1) todayVerificationOrderCount
from (select count(1)
from zdy_ticket_order_detail a
left join zdy_ticket_order_item b on a.order_item_id = b.id
left join zdy_ticket_order c on b.order_id = c.id
left join zdy_ticket_order_detail_child d on d.order_detail_id = a.id
where a.del_flag = 0
and a.payment_type = 200
and (a.verification_time is not null or d.verification_time is not null)
and (DATE (d.verification_time) = CURDATE() or DATE (a.verification_time) = CURDATE())
${params.dataScope}
group by c.id) t
</select>
<select id="todaySaleTotalAmount" resultType="decimal">
SELECT ifnull(SUM(actua_amount), 0) todaySaleTotalAmount
FROM zdy_ticket_order_detail ztod
left join zdy_ticket_order_item ztoi on ztod.order_item_id = ztoi.id
WHERE ztod.del_flag = 0
and ztod.payment_type = 200
and DATE (ztod.create_time) = CURDATE() ${params.dataScope}
</select>
<select id="thisYearOrderCount" resultType="long">
select count(1) todayOrderCount
from (SELECT 1
FROM zdy_ticket_order_item ztoi
left join zdy_ticket_order zto on ztoi.order_id = zto.id
WHERE ztoi.del_flag = 0
and ztoi.payment_type = 200
and DATE (ztoi.create_time) >= CONCAT(YEAR(NOW()), '-01-01') ${params.dataScope}
group by zto.id) a
</select>
<select id="thisYearVerificationOrderCount" resultType="long">
select count(1) todayVerificationOrderCount
from (select count(1)
from zdy_ticket_order_detail a
left join zdy_ticket_order_item b on a.order_item_id = b.id
left join zdy_ticket_order c on b.order_id = c.id
left join zdy_ticket_order_detail_child d on d.order_detail_id = a.id
where a.del_flag = 0
and a.payment_type = 200
and (a.verification_time is not null or d.verification_time is not null)
and (DATE (d.verification_time) >= CONCAT(YEAR (NOW()), '-01-01') or DATE (a.verification_time) >= CONCAT(YEAR (NOW()), '-01-01'))
${params.dataScope}
group by c.id) t
</select>
<select id="thisYearSaleTotalAmount" resultType="decimal">
SELECT ifnull(SUM(actua_amount), 0) todaySaleTotalAmount
FROM zdy_ticket_order_detail ztod
left join zdy_ticket_order_item ztoi on ztod.order_item_id = ztoi.id
WHERE ztod.del_flag = 0
and ztod.payment_type = 200
and ztod.create_time >= CONCAT(YEAR(NOW()), '-01-01')
${params.dataScope}
</select>
<!--存在套票和年卡这种情况zdy_ticket_order_detail有数据zdy_ticket_order_detail_child表无数据
所有游客统计为入园的游客(不管核销类型,因为只有核销次数等于可核销次数,核销类型才会变更为已核销,所以这里
统计只要核销次数不为0即为已入园未购票、购票未入园的不统计(多次入园的同一游客计为1),所有时间段,游客去重-->
<sql id="baseTouristSql">
(select ztod.identity_card
from zdy_ticket_order_detail ztod
left join zdy_ticket_order_detail_child ztodc on ztod.id = ztodc.order_detail_id
left join zdy_ticket_order_item ztoi on ztod.order_item_id = ztoi.id
where ztod.del_flag = 0
and ztod.payment_type = 200
and ztod.identity_card is not null
and (ztod.verification_time is not null
or ztodc.verification_time is not null)
${params.dataScope}
group by ztod.identity_card)
t
</sql>
<select id="todayEnterParkQuantity" resultType="com.zhwl.statistics.domain.vo.ECharsVO">
select CONCAT(FLOOR(h / 2) * 2, '-', FLOOR(h / 2) * 2 + 2) `name`, count(1) `value`
from (select hour (`hour`) h
from (select case
when MAX(ztodc.verification_time) is null then ztod.verification_time
else MAX(ztodc.verification_time) end `hour`
from zdy_ticket_order_detail ztod
left join zdy_ticket_order_detail_child ztodc on ztod.id = ztodc.order_detail_id
left join zdy_ticket_order_item ztoi on ztod.order_item_id = ztoi.id
where ztod.del_flag = 0
and ztod.payment_type = 200
and (ztod.verification_time is not null or ztodc.verification_time is not null)
and (DATE (ztod.verification_time) = CURRENT_DATE () or DATE (ztodc.verification_time) = CURRENT_DATE ())
${params.dataScope}
group by ztod.id) t) t1
group by `name`
</select>
<select id="touristSourcesStatistics" resultType="com.zhwl.statistics.domain.vo.ECharsVO">
select za.name `name`, t2.value `value`
from (select p, count(1) value
from (select SUBSTR(identity_card, 1, 2) p
from (select ztod.identity_card
from zdy_ticket_order_detail ztod
left join zdy_ticket_order_detail_child ztodc on ztod.id = ztodc.order_detail_id
left join zdy_ticket_order_item ztoi on ztod.order_item_id = ztoi.id
where ztod.del_flag = 0
and ztod.payment_type = 200
and ztod.identity_card is not null
${params.dataScope}
and (ztod.verification_mun > 0
or ztodc.verification_num > 0)
group by ztod.identity_card) t) t1
group by p) t2
left join zdy_area za on za.short_code = p
where za.name is not null
order by `value` desc
</select>
<select id="touristSum" resultType="long">
select count(identity_card)
from
<include refid="baseTouristSql"/>
</select>
<select id="touristAgeSegment" resultType="java.util.HashMap">
<![CDATA[
select sum(case when age > 0 and age <= 18 then 1 else 0 end) as '18岁以下',
sum(case when age > 18 and age <= 35 then 1 else 0 end) as '18-35岁',
sum(case when age > 35 and age <= 60 then 1 else 0 end) as '35-60岁',
sum(case when age > 60 then 1 else 0 end) as '60岁以上'
]]>
from (select t.identity_card, YEAR (CURRENT_DATE) - substr(t.identity_card, 7, 4) + 1 age
from
<include refid="baseTouristSql"/>) t1
</select>
<select id="touristGenderSegment" resultType="com.zhwl.statistics.domain.vo.ECharsVO">
select count(1) `value`,
case when substr(identity_card, 17, 1) / 2 = 0 then '女士' else '男士' end `name`
from
<include refid="baseTouristSql"/>
group by `name`
</select>
</mapper>