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

168 lines
7.3 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.MultiScenicAreaMapper">
<select id="selectScenicSpotList" resultType="com.zhwl.statistics.domain.vo.multiscenic.MultiScenicVO">
select id, scenic_name scenicName, scenic_level level
from zdy_scenic
where del_flag = '0'
</select>
<!--不限次数的核销数一直是0这里使用时间来判断核销时间不为空即为已核销,下面涉及到查询已核销的同理-->
<select id="selectScenicSpotHotRankingList" resultType="com.zhwl.statistics.domain.vo.multiscenic.MultiScenicVO">
select zs.scenic_name scenicName,
a.c passengerFlow
from (select ztoi.dept_id, count(distinct ztod.id) c
from zdy_ticket_order_detail ztod
left join zdy_ticket_order_item ztoi on ztoi.id = ztod.order_item_id
left join zdy_ticket_order_detail_child ztodc on ztod.id = ztodc.order_detail_id
where ztod.del_flag = 0
and ztod.payment_type = 200
and ztod.refund_status != 200
and (ztod.verification_time is not null or ztodc.verification_time is not null)
group by ztoi.dept_id) a
left join zdy_scenic zs on a.dept_id = zs.dept_id
where scenic_name is not null
order by passengerFlow desc;
</select>
<select id="selectScenicSpotSaleTicketsAmountRankingList"
resultType="com.zhwl.statistics.domain.vo.multiscenic.MultiScenicVO">
select zs.scenic_name scenicName, a.c actualSalesTicketAmount
from (select ztoi.dept_id, sum(ztod.actua_amount) c
from zdy_ticket_order_detail ztod
left join zdy_ticket_order_item ztoi on ztoi.id = ztod.order_item_id
where ztod.del_flag = 0
and ztod.payment_type = 200
and ztod.refund_status != 200
group by ztoi.dept_id) a
left join zdy_scenic zs on a.dept_id = zs.dept_id
where scenic_name is not null
order by actualSalesTicketAmount desc
</select>
<select id="selectScenicSpotComplaintVolumeList"
resultType="com.zhwl.statistics.domain.vo.multiscenic.MultiScenicVO">
select b.scenic_name scenicName, c complaintVolume
from (select zcr.scenic_id, count(1) c
from zdy_cms_report zcr
where scenic_id is not null
group by zcr.scenic_id) a
left join zdy_scenic b on a.scenic_id = b.id
where b.del_flag = '0'
order by complaintVolume desc
</select>
<select id="pass7DaysTicketStatistics" parameterType="long"
resultType="com.zhwl.statistics.domain.vo.ECharsVO">
SELECT DATE_FORMAT(ztoi.create_time, '%Y-%m-%d') `name`, sum(ifnull(buy_quantity, 0)) `value`
FROM zdy_ticket_order_item ztoi
left join zdy_scenic zs on ztoi.dept_id = zs.dept_id
<where>
ztoi.del_flag = '0'
and ztoi.payment_type = 200
and ztoi.create_time >= CURDATE() - INTERVAL 6 DAY
<if test="scenicSpotId !=null">
and zs.id = #{scenicSpotId}
</if>
</where>
GROUP BY `name`
order by `name` asc
</select>
<select id="pass7DaysVerificationOrderStatistics" resultType="com.zhwl.statistics.domain.vo.ECharsVO">
select DATE_FORMAT(t.create_time, '%Y-%m-%d') `name`, sum(ifnull(buy_quantity, 0)) `value`
from (select MAX(ztod.create_time) create_time, MAX(ztod.buy_quantity) buy_quantity
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
left join zdy_scenic zs on ztoi.dept_id = zs.dept_id
<where>
ztod.del_flag = '0'
and ztod.payment_type = 200
and ztod.refund_status != 200
and ztod.create_time >= CURDATE() - INTERVAL 6 DAY
and (ztod.verification_time is not null or ztodc.verification_time is not null)
<if test="scenicSpotId !=null">
and zs.id = #{scenicSpotId}
</if>
</where>
group by ztod.id) t
GROUP BY `name`
order by `name` asc
</select>
<select id="pass7DaysSaleAmountStatistics" resultType="com.zhwl.statistics.domain.vo.ECharsVO">
SELECT DATE_FORMAT(ztod.create_time, '%Y-%m-%d') `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
left join zdy_scenic zs on ztoi.dept_id = zs.dept_id
<where>
ztod.del_flag = '0'
and ztod.payment_type = 200
and ztod.create_time >= CURDATE() - INTERVAL 6 DAY
<if test="scenicSpotId !=null">
and zs.id = #{scenicSpotId}
</if>
</where>
GROUP BY `name`
order by `name` asc
</select>
<select id="selectActualSalesTicketsQuantity" resultType="java.lang.Long">
select sum(ztod.buy_quantity) c
from zdy_ticket_order_detail ztod
where ztod.del_flag = '0'
and ztod.payment_type = 200
and ztod.refund_status != 200
</select>
<select id="selectActualSalesTicketsAmount" resultType="java.math.BigDecimal">
select sum(ztod.actua_amount)
from zdy_ticket_order_detail ztod
where ztod.del_flag = '0'
and ztod.payment_type = 200
and ztod.refund_status != 200
</select>
<select id="selectVerificationTicketsQuantity" resultType="java.lang.Long">
select count(distinct ztod.id)
from zdy_ticket_order_detail ztod
left join zdy_ticket_order_detail_child ztodc on ztod.id = ztodc.order_detail_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)
</select>
<select id="selectVerificationTicketsAmount" resultType="java.math.BigDecimal">
select sum(actua_amount)
from (select MAX(ztod.actua_amount) actua_amount
from zdy_ticket_order_detail ztod
left join zdy_ticket_order_detail_child ztodc on ztod.id = ztodc.order_detail_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)
group by ztod.id) c
</select>
<select id="selectRefundTicketsQuantity" resultType="java.lang.Long">
select sum(ztod.buy_quantity) c
from zdy_ticket_order_detail ztod
where ztod.del_flag = '0'
and ztod.payment_type = 200
and ztod.refund_status = 200
</select>
<select id="selectRefundTicketsAmount" resultType="java.math.BigDecimal">
select sum(ztod.actua_amount) c
from zdy_ticket_order_detail ztod
where ztod.del_flag = '0'
and ztod.payment_type = 200
and ztod.refund_status = 200
</select>
</mapper>