| | |
| | | AND th.hb_state =4 |
| | | </if> |
| | | </sql> |
| | | |
| | | <sql id="Count_Select_Type"> |
| | | <if test="type != null and type == 1"> <!-- 自购订单 --> |
| | | AND (t.hb_type =1 or t.hb_type =2) |
| | | </if> |
| | | <if test="type != null and type == 2"> <!-- 分享订单 --> |
| | | AND t.`hb_type` = 20 |
| | | </if> |
| | | <if test="type != null and type == 3"> <!-- 邀请订单 --> |
| | | AND (t.`hb_type` = 5 OR t.`hb_type` = 6 OR t.`hb_type` = 7 OR t.`hb_type` = 21 OR t.`hb_type` = 22) |
| | | </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"/> |
| | | SELECT CAST(SUM(t.`hb_money`)AS DECIMAL(19,2)) AS showValue,<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 |
| | |
| | | </select> |
| | | |
| | | <select id="countHongBaoNum" resultType="java.util.HashMap"> |
| | | SELECT COUNT(t.`hb_id`)AS total,<include refid="Column_DateType"/> |
| | | SELECT COUNT(t.`hb_id`)AS showValue,<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 |
| | |
| | | ORDER BY t.`hb_create_time` |
| | | </select> |
| | | |
| | | |
| | | <select id="countHongBaoType" resultType="java.util.HashMap"> |
| | | SELECT COUNT(t.`hb_id`)AS showValue,<include refid="Column_DateType"/> |
| | | FROM yeshi_ec_hongbao_v2 t |
| | | WHERE t.`hb_uid` IS NOT NULL |
| | | <include refid="Count_Select_DateType"/> |
| | | <include refid="Count_Select_Type"/> |
| | | <include refid="Count_Group_DateType"/> |
| | | ORDER BY t.`hb_create_time` |
| | | </select> |
| | | |
| | | <select id="countHongBaoTotalNum" resultType="java.util.HashMap"> |
| | | SELECT COUNT(t.`hb_id`)AS showValue,<include refid="Column_DateType"/> |
| | | FROM yeshi_ec_hongbao_v2 t |
| | | WHERE t.`hb_uid` IS NOT NULL AND t.`hb_type` not in(1,3,4) <include refid="Count_Select_DateType"/> |
| | | <include refid="Count_Group_DateType"/> |
| | | ORDER BY t.`hb_create_time` |
| | | </select> |
| | | |
| | | |
| | | <select id="count24HOderByChannel" resultType="java.util.HashMap"> |
| | | SELECT COALESCE(SUM(b.money*2),0) AS 'commision', COALESCE(COUNT(b.id),0) AS'countOrder', |
| | | COALESCE(SUM(b.payMoney),0) AS 'payMoney', |
| | | <if test="type == 1"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'createDate' |
| | | </if> |
| | | <if test="type == 2"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'createDate' |
| | | </if> |
| | | <if test="type == 3"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'createDate' |
| | | </if> |
| | | FROM |
| | | ( |
| | | SELECT h.* FROM yeshi_ec_hongbao_v2 h |
| | | 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 a.uid=h.`uid` WHERE a.uid IS NOT NULL AND (h.`type`=1 OR h.`type`=20) |
| | | ) b |
| | | LEFT JOIN yeshi_ec_user u ON u.`id`=b.uid |
| | | WHERE <![CDATA[b.createtime<u.`createtime`+1000*60*60*24 ]]> |
| | | <if test="startTime != null and startTime != '' "> |
| | | AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}' |
| | | </if> |
| | | <if test="endTime != null and endTime != '' "> |
| | | AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}' |
| | | </if> |
| | | <if test="years != null and years != '' "> |
| | | AND FROM_UNIXTIME(u.`createtime`/1000,'%Y') = '${years}' |
| | | </if> |
| | | <if test="type == 1"> |
| | | GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') |
| | | </if> |
| | | <if test="type == 2"> |
| | | GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m') |
| | | </if> |
| | | <if test="type == 3"> |
| | | GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y') |
| | | </if> |
| | | ORDER BY u.`createtime` |
| | | |
| | | </select> |
| | | |
| | | <select id="countHistoryOderByChannel" resultType="java.util.HashMap"> |
| | | |
| | | SELECT COALESCE(SUM(h.`money`)*2,0) AS 'commision', COALESCE(COUNT(h.id),0) AS 'countOrder', |
| | | COALESCE(SUM(h.payMoney),0) AS 'payMoney', |
| | | <if test="type == 1"> |
| | | FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') AS 'createDate' |
| | | </if> |
| | | <if test="type == 2"> |
| | | FROM_UNIXTIME(h.`createtime`/1000,'%m') AS 'createDate' |
| | | </if> |
| | | <if test="type == 3"> |
| | | FROM_UNIXTIME(h.`createtime`/1000,'%Y') AS 'createDate' |
| | | </if> |
| | | FROM yeshi_ec_hongbao h |
| | | 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 h.`uid`=a.uid |
| | | WHERE (h.`type`=1 OR h.`type`=20) AND a.uid IS NOT NULL |
| | | <if test="startTime != null and startTime != '' "> |
| | | AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}' |
| | | </if> |
| | | <if test="endTime != null and endTime != '' "> |
| | | AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}' |
| | | </if> |
| | | <if test="years != null and years != '' "> |
| | | AND FROM_UNIXTIME(h.`createtime`/1000,'%Y') = '${years}' |
| | | </if> |
| | | <if test="type == 1"> |
| | | GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') |
| | | </if> |
| | | <if test="type == 2"> |
| | | GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m') |
| | | </if> |
| | | <if test="type == 3"> |
| | | GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y') |
| | | </if> |
| | | ORDER BY h.`createtime` |
| | | </select> |
| | | |
| | | |
| | | |
| | | </mapper> |