<?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.nova.sankuai.infra.mapper.VipCardOrderLogMapper">
|
|
<select id="getVipStatisticsList" resultType="com.nova.sankuai.domain.vo.VipStatisticsVo">
|
select
|
ci.id as id,
|
ci.code as code,
|
ci.name as name,
|
ci.app_id as appId,
|
sum(if((vcol.clickPayCount=0 and vcol.clickNoPayCount=0), vcol.clickTotalCount,0)) as clickTotalCount,
|
sum(if((vcol.clickPayCount=0), vcol.clickNoPayCount,0)) as clickNoPayCount,
|
sum(if((vcol.clickPayCount>0), vcol.clickPayCount,0)) as clickPayCount,
|
sum(vcol.sumAmount) as sumAmount,
|
#{visitDto.startDate} as startDate,
|
#{visitDto.endDate} as endDate
|
from (select
|
sum(IF((status='0'),1,0)) as clickTotalCount,
|
sum(IF((status='1'),1,0)) as clickNoPayCount,
|
sum(IF((status='2'),1,0)) as clickPayCount,
|
sum(IF((status='2'),selling_price,0)) as sumAmount,
|
customer_user_id,
|
channel_id from vip_card_order_log
|
<where>
|
vip_type = #{visitDto.vipType}
|
<if test="visitDto.startDate != null">
|
and creation_date >= #{visitDto.startDate}
|
</if>
|
<if test="visitDto.endDate != null">
|
and creation_date <= #{visitDto.endDate}
|
</if>
|
</where>
|
group by customer_user_id,channel_id) as vcol
|
left join channel_info ci on vcol.channel_id = ci.id
|
<where>
|
1 = 1
|
<if test="visitDto.code != null">
|
and ci.code = #{visitDto.code}
|
</if>
|
<if test="visitDto.name != null and visitDto.name !=''">
|
and ci.name like concat('%',#{visitDto.name},'%')
|
</if>
|
</where>
|
group by vcol.channel_id
|
</select>
|
|
<select id="getNoOrderDetail" resultType="com.nova.sankuai.domain.vo.VipStatisticsDetailVo">
|
select
|
vl.customer_user_id as customerUserId,
|
cu.phone as phone,
|
cu.name as customerName,
|
vl.creation_date as creationDate,
|
vl.selling_price as sellingPrice,
|
vl.marked_price as markedPrice
|
from vip_card_order_log vl
|
-- 根据日志筛选用户对应的状态
|
inner join ( select
|
sum(IF((status='0'),1,0)) as clickTotalCount,
|
sum(IF((status='1'),1,0)) as clickNoPayCount,
|
sum(IF((status='2'),1,0)) as clickPayCount,
|
customer_user_id, channel_id from vip_card_order_log
|
<where>
|
channel_id = #{detailDto.channelId} and vip_type = #{detailDto.vipType}
|
<if test="detailDto.startDate != null">
|
and creation_date >= #{detailDto.startDate}
|
</if>
|
<if test="detailDto.endDate != null">
|
and creation_date <= #{detailDto.endDate}
|
</if>
|
</where>
|
group by customer_user_id,channel_id) as tmp
|
on vl.customer_user_id = tmp.customer_user_id and vl.channel_id = tmp.channel_id
|
left join customer_user cu on vl.customer_user_id = cu.id
|
<where>
|
vl.status = 0 and tmp.clickNoPayCount = 0 and tmp.clickPayCount = 0
|
and vl.vip_type = #{detailDto.vipType}
|
<if test="detailDto.startDate != null">
|
and vl.creation_date >= #{detailDto.startDate}
|
</if>
|
<if test="detailDto.endDate != null">
|
and vl.creation_date <= #{detailDto.endDate}
|
</if>
|
<if test="detailDto.customerName != null and detailDto.customerName !=''">
|
and cu.name like concat('%',#{detailDto.customerName},'%')
|
</if>
|
<if test="detailDto.phone != null and detailDto.phone !=''">
|
and cu.phone like concat('%',#{detailDto.phone},'%')
|
</if>
|
</where>
|
</select>
|
|
<select id="getOrderedDetail" resultType="com.nova.sankuai.domain.vo.VipStatisticsDetailVo">
|
select
|
vl.customer_user_id as customerUserId,
|
cu.phone as phone,
|
cu.name as customerName,
|
vl.creation_date as creationDate,
|
vl.selling_price as sellingPrice,
|
vl.marked_price as markedPrice
|
from vip_card_order_log vl
|
-- 根据日志筛选用户对应的状态
|
inner join ( select
|
sum(IF((status='0'),1,0)) as clickTotalCount,
|
sum(IF((status='1'),1,0)) as clickNoPayCount,
|
sum(IF((status='2'),1,0)) as clickPayCount,
|
customer_user_id, channel_id from vip_card_order_log
|
<where>
|
channel_id = #{detailDto.channelId} and vip_type = #{detailDto.vipType}
|
<if test="detailDto.startDate != null">
|
and creation_date >= #{detailDto.startDate}
|
</if>
|
<if test="detailDto.endDate != null">
|
and creation_date <= #{detailDto.endDate}
|
</if>
|
</where>
|
group by customer_user_id,channel_id) as tmp
|
on vl.customer_user_id = tmp.customer_user_id and vl.channel_id = tmp.channel_id
|
left join customer_user cu on vl.customer_user_id = cu.id
|
<where>
|
vl.status = 1 and tmp.clickNoPayCount > 0 and tmp.clickPayCount = 0
|
and vl.vip_type = #{detailDto.vipType}
|
<if test="detailDto.startDate != null">
|
and vl.creation_date >= #{detailDto.startDate}
|
</if>
|
<if test="detailDto.endDate != null">
|
and vl.creation_date <= #{detailDto.endDate}
|
</if>
|
<if test="detailDto.customerName != null and detailDto.customerName !=''">
|
and cu.name like concat('%',#{detailDto.customerName},'%')
|
</if>
|
<if test="detailDto.phone != null and detailDto.phone !=''">
|
and cu.phone like concat('%',#{detailDto.phone},'%')
|
</if>
|
</where>
|
</select>
|
|
<select id="getVipSuccessDetail" resultType="com.nova.sankuai.domain.vo.VipStatisticsDetailVo">
|
select
|
vl.customer_user_id as customerUserId,
|
cu.phone as phone,
|
cu.name as customerName,
|
vl.creation_date as creationDate,
|
vl.selling_price as sellingPrice,
|
vl.marked_price as markedPrice
|
from vip_card_order_log vl
|
-- 根据日志筛选用户对应的状态
|
inner join ( select
|
sum(IF((status='0'),1,0)) as clickTotalCount,
|
sum(IF((status='1'),1,0)) as clickNoPayCount,
|
sum(IF((status='2'),1,0)) as clickPayCount,
|
customer_user_id, channel_id from vip_card_order_log
|
<where>
|
channel_id = #{detailDto.channelId}
|
and vip_type = #{detailDto.vipType}
|
<if test="detailDto.startDate != null">
|
and creation_date >= #{detailDto.startDate}
|
</if>
|
<if test="detailDto.endDate != null">
|
and creation_date <= #{detailDto.endDate}
|
</if>
|
</where>
|
group by customer_user_id,channel_id) as tmp
|
on vl.customer_user_id = tmp.customer_user_id and vl.channel_id = tmp.channel_id
|
left join customer_user cu on vl.customer_user_id = cu.id
|
<where>
|
vl.status = 2 and tmp.clickPayCount > 0 and vl.vip_type = #{detailDto.vipType}
|
<if test="detailDto.startDate != null">
|
and vl.creation_date >= #{detailDto.startDate}
|
</if>
|
<if test="detailDto.endDate != null">
|
and vl.creation_date <= #{detailDto.endDate}
|
</if>
|
<if test="detailDto.customerName != null and detailDto.customerName !=''">
|
and cu.name like concat('%',#{detailDto.customerName},'%')
|
</if>
|
<if test="detailDto.phone != null and detailDto.phone !=''">
|
and cu.phone like concat('%',#{detailDto.phone},'%')
|
</if>
|
</where>
|
</select>
|
</mapper>
|