<?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.yeshi.fanli.dao.mybatis.HongBaoV2CountMapper">
|
|
<sql id="Column_DateType">
|
<if test="dateType == 1">
|
DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d') AS 'showDate'
|
</if>
|
<if test="dateType == 2">
|
DATE_FORMAT(t.`hb_create_time`,'%m') AS 'showDate'
|
</if>
|
<if test="dateType == 3">
|
DATE_FORMAT(t.`hb_create_time`,'%Y') AS 'showDate'
|
</if>
|
</sql>
|
|
<sql id="Count_Select_DateType">
|
<if test="startTime != null and startTime != '' ">
|
AND DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
|
</if>
|
<if test="endTime != null and endTime != '' ">
|
AND DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
|
</if>
|
<if test="year != null and year != '' ">
|
AND DATE_FORMAT(t.`hb_create_time`,'%Y') = '${year}'
|
</if>
|
</sql>
|
|
<sql id="Count_Group_DateType">
|
<if test="dateType == 1">
|
GROUP BY DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d')
|
</if>
|
<if test="dateType == 2">
|
GROUP BY DATE_FORMAT(t.`hb_create_time`,'%Y-%m')
|
</if>
|
<if test="dateType == 3">
|
GROUP BY DATE_FORMAT(t.`hb_create_time`,'%Y')
|
</if>
|
</sql>
|
<sql id="Count_Select_State">
|
<if test="state != null and state == 1"> <!-- 未到账 -->
|
AND (th.hb_state = 1 or th.hb_state = 2)
|
</if>
|
<if test="state != null and state == 2"> <!-- 已到账 -->
|
AND th.hb_state = 3
|
</if>
|
<if test="state != null and state == 3"> <!-- 红包已失效 -->
|
AND th.hb_state =4
|
</if>
|
</sql>
|
<select id="countHongBaoMoney" resultType="java.util.HashMap">
|
SELECT CAST(SUM(t.`hb_money`)AS DECIMAL(19,2)) AS total,<include refid="Column_DateType"/>
|
FROM yeshi_ec_hongbao_v2 t
|
<if test="channel != null and channel != 'all' ">
|
LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active` a WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON t.`hb_uid`=a.uid
|
</if>
|
WHERE t.`hb_uid` IS NOT NULL AND (t.`hb_type`=1 OR t.`hb_type`=20) <include refid="Count_Select_DateType"/>
|
<include refid="Count_Select_State"/>
|
<include refid="Count_Group_DateType"/>
|
ORDER BY t.`hb_create_time`
|
</select>
|
|
<select id="countHongBaoNum" resultType="java.util.HashMap">
|
SELECT COUNT(t.`hb_id`)AS total,<include refid="Column_DateType"/>
|
FROM yeshi_ec_hongbao_v2 t
|
<if test="channel != null and channel != 'all' ">
|
LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active` a WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON t.`hb_uid`=a.uid
|
</if>
|
WHERE t.`hb_uid` IS NOT NULL AND (t.`hb_type`=1 OR h.`hb_type`=20) <include refid="Count_Select_DateType"/>
|
<include refid="Count_Select_State"/>
|
<include refid="Count_Group_DateType"/>
|
ORDER BY t.`hb_create_time`
|
</select>
|
|
|
</mapper>
|