124 lines
4.9 KiB
XML
124 lines
4.9 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.zhwl.statistics.mapper.ZdyMarketingMapper">
|
|
|
|
<resultMap type="ZdyMarketingVO" id="ZdyMarketingResult">
|
|
<result property="createTimeValue" column="create_time_value"/>
|
|
<result property="ticketName" column="ticket_name"/>
|
|
<result property="orderSource" column="order_source"/>
|
|
<result property="touristSource" column="tourist_source"/>
|
|
<result property="ageGroup" column="age_group"/>
|
|
<result property="actuaAmount" column="actua_amount"/>
|
|
</resultMap>
|
|
|
|
<select id="listZdyMarketing" parameterType="ZdyMarketingDTO"
|
|
resultMap="ZdyMarketingResult">
|
|
SELECT
|
|
<if test="startDateTime == null and endDateTime == null">
|
|
DATE(ztod.create_time) AS create_time_value,
|
|
</if>
|
|
zt.id,
|
|
zt.`name` AS ticket_name,
|
|
zto.order_source,
|
|
LEFT(zut.id_card, 4) as tourist_source,
|
|
<if test="ageGroupList != null">
|
|
CASE
|
|
<foreach collection="ageGroupList" item="item">
|
|
WHEN TIMESTAMPDIFF(YEAR, STR_TO_DATE(SUBSTRING(id_card, 7, 8), '%Y%m%d'), CURDATE())
|
|
<choose>
|
|
<when test="item.ageMin != null and item.ageMax != null">
|
|
BETWEEN #{item.ageMin} AND #{item.ageMax}
|
|
</when>
|
|
<otherwise>
|
|
<if test="item.ageMin != null">
|
|
>= #{item.ageMin}
|
|
</if>
|
|
<if test="item.ageMax != null">
|
|
<= #{item.ageMax}
|
|
</if>
|
|
</otherwise>
|
|
</choose>
|
|
THEN
|
|
#{item.value}
|
|
</foreach>
|
|
ELSE ''
|
|
END AS age_group,
|
|
</if>
|
|
SUM(ztod.actua_amount) AS actua_amount
|
|
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
|
|
LEFT JOIN zdy_ticket zt ON ztod.ticket_id = zt.id
|
|
LEFT JOIN zdy_user_tourist zut ON zut.id = ztod.user_tourist_id
|
|
WHERE
|
|
ztod.user_tourist_id IS NOT NULL
|
|
AND ztod.payment_type = '200'
|
|
<if test="ticketName != null and ticketName != ''">
|
|
AND zt.name like concat('%',#{ticketName},'%')
|
|
</if>
|
|
<if test="orderSource != null and orderSource != ''">
|
|
AND zto.order_source = #{orderSource}
|
|
</if>
|
|
<if test="birthdayMin != null or birthdayMax != null">
|
|
AND zut.id_card IS NOT NULL
|
|
AND zut.id_card != ''
|
|
AND STR_TO_DATE(SUBSTRING(id_card, 7, 8), '%Y%m%d')
|
|
<choose>
|
|
<when test="birthdayMin != null and birthdayMax != null">
|
|
BETWEEN #{birthdayMin} AND #{birthdayMax}
|
|
</when>
|
|
<otherwise>
|
|
<if test="birthdayMin != null">
|
|
>= #{birthdayMin}
|
|
</if>
|
|
<if test="birthdayMax != null">
|
|
<= #{birthdayMax}
|
|
</if>
|
|
</otherwise>
|
|
</choose>
|
|
</if>
|
|
<if test="touristSource != null and touristSource != ''">
|
|
AND zut.id_card like concat(#{touristSource},'%')
|
|
</if>
|
|
<if test="startDateTime != null">
|
|
AND ztod.create_time >= #{startDateTime}
|
|
</if>
|
|
<if test="endDateTime != null">
|
|
AND ztod.create_time <= #{endDateTime}
|
|
</if>
|
|
GROUP BY
|
|
<if test="startDateTime == null and endDateTime == null">
|
|
DATE(ztod.create_time),
|
|
</if>
|
|
zt.id,zto.order_source, LEFT(zut.id_card, 4)
|
|
<if test="ageGroupList != null">
|
|
,CASE
|
|
<foreach collection="ageGroupList" item="item">
|
|
WHEN TIMESTAMPDIFF(YEAR, STR_TO_DATE(SUBSTRING(id_card, 7, 8), '%Y%m%d'), CURDATE())
|
|
<choose>
|
|
<when test="item.ageMin != null and item.ageMax != null">
|
|
BETWEEN #{item.ageMin} AND #{item.ageMax}
|
|
</when>
|
|
<otherwise>
|
|
<if test="item.ageMin != null">
|
|
>= #{item.ageMin}
|
|
</if>
|
|
<if test="item.ageMax != null">
|
|
<= #{item.ageMax}
|
|
</if>
|
|
</otherwise>
|
|
</choose>
|
|
THEN
|
|
#{item.value}
|
|
</foreach>
|
|
ELSE ''
|
|
END
|
|
</if>
|
|
<if test="startDateTime == null and endDateTime == null">
|
|
order by DATE(ztod.create_time) desc
|
|
</if>
|
|
</select>
|
|
</mapper> |