| | |
| | | <?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">
|
| | |
|
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.vo.order.HongBaoV2VO">
|
| | | <id column="hb_id" property="id" jdbcType="BIGINT" />
|
| | | <result column="hb_urank" property="urank" jdbcType="INTEGER" />
|
| | | <result column="hb_money" property="money" jdbcType="DECIMAL" />
|
| | | <result column="hb_type" property="type" jdbcType="INTEGER" />
|
| | | <result column="hb_state" property="state" jdbcType="INTEGER" />
|
| | | <result column="hb_version" property="version" jdbcType="INTEGER" />
|
| | | <result column="hb_beizhu" property="beizhu" jdbcType="VARCHAR" />
|
| | | <result column="hb_pre_get_time" property="preGetTime" jdbcType="TIMESTAMP" />
|
| | | <result column="hb_get_time" property="getTime" jdbcType="TIMESTAMP" />
|
| | | <result column="hb_create_time" property="createTime" jdbcType="TIMESTAMP" />
|
| | | <result column="hb_update_time" property="updateTime" jdbcType="TIMESTAMP" />
|
| | |
|
| | | <result column="totalMoney" property="totalMoney" jdbcType="DECIMAL" />
|
| | | |
| | | <association property="userInfo" column="hb_uid"
|
| | | javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
| | | <id column="hb_uid" property="id" jdbcType="BIGINT" />
|
| | | </association>
|
| | |
|
| | | <association property="parent" column="hb_pid"
|
| | | javaType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
|
| | | <id column="hb_pid" property="id" jdbcType="BIGINT" />
|
| | | </association>
|
| | | </resultMap>
|
| | |
|
| | |
|
| | | <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 (t.hb_state = 1 or t.hb_state = 2)
|
| | | </if>
|
| | | <if test="state != null and state == 2"> <!-- 已到账 -->
|
| | | AND t.hb_state = 3
|
| | | </if>
|
| | | <if test="state != null and state == 3"> <!-- 红包已失效 -->
|
| | | AND t.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 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
|
| | | </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" />
|
| | | <if test="channel != null and channel != 'all' ">
|
| | | AND a.uid is not null
|
| | | </if>
|
| | |
|
| | | <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 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
|
| | | </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" />
|
| | | <if test="channel != null and channel != 'all' ">
|
| | | AND a.uid is not null
|
| | | </if>
|
| | |
|
| | | <include refid="Count_Group_DateType" />
|
| | | ORDER BY t.`hb_create_time`
|
| | | </select>
|
| | |
|
| | | <select id="countNumberByUid" resultType="java.lang.Long">
|
| | | select count(hb_id) from yeshi_ec_hongbao_v2 where hb_uid=#{0}
|
| | | </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="countMoneyByUidAndState" resultType="java.math.BigDecimal">
|
| | | SELECT CAST(SUM(hb.`hb_money`)AS DECIMAL(19,2))
|
| | | FROM `yeshi_ec_hongbao_v2` hb
|
| | | WHERE hb.`hb_uid` = #{uid}
|
| | | <if test="state != null">
|
| | | AND hb.`hb_state` = #{state}
|
| | | </if>
|
| | | </select>
|
| | |
|
| | | <select id="countNumberByUidAndState" resultType="java.lang.Integer">
|
| | | SELECT COALESCE(count(hb_id),0) FROM yeshi_ec_hongbao_v2
|
| | | WHERE hb_uid =
|
| | | #{uid}
|
| | | <if test="state != null">
|
| | | AND hb_state = #{state}
|
| | | </if>
|
| | | </select>
|
| | |
|
| | |
|
| | | <select id="getTotalTiChengCount" resultType="java.lang.Integer"
|
| | | parameterType="java.lang.Long">
|
| | | SELECT count(*) FROM `yeshi_ec_hongbao_v2` h
|
| | | WHERE
|
| | | h.`hb_uid`=#{0}
|
| | | AND (h.`hb_type`=20 OR h.`hb_type`=21 OR h.`hb_type`=22 OR h.`hb_type`=6
|
| | | OR h.`hb_type`=7)
|
| | | </select>
|
| | |
|
| | | <select id="countValidNumberByUid" resultType="java.lang.Long">
|
| | | <!--统计有效订单数量 -->
|
| | | SELECT COALESCE(count(hb.hb_id),0) FROM `yeshi_ec_hongbao_v2` hb
|
| | | WHERE
|
| | | hb.hb_uid =#{uid}
|
| | | AND hb.hb_type not in (3,4)
|
| | | AND <![CDATA[hb.hb_state <> 4]]>
|
| | |
|
| | | <if test="dateType != null and dateType == 1">
|
| | | AND TO_DAYS(FROM_UNIXTIME(hb.`hb_create_time`/1000)) =
|
| | | TO_DAYS(NOW())
|
| | | </if>
|
| | | <if test="dateType != null and dateType == 2">
|
| | | AND DATE_FORMAT(
|
| | | FROM_UNIXTIME(hb.`hb_create_time`/1000),'%Y%m' ) =
|
| | | DATE_FORMAT( CURDATE( ) , '%Y%m' )
|
| | | </if>
|
| | | </select>
|
| | |
|
| | | <select id="countWillGetMoneyByUid" resultType="java.math.BigDecimal">
|
| | | SELECT CAST(SUM(hb.`hb_money`)AS DECIMAL(19,2))
|
| | | FROM `yeshi_ec_hongbao_v2` hb
|
| | | WHERE hb.`hb_uid` = #{uid} AND hb.`hb_state`
|
| | | in (1,2)
|
| | | </select>
|
| | |
|
| | | <select id="getLastHongBaoTime" resultType="java.util.Date">
|
| | | <!-- 最近一次下单时间 -->
|
| | | SELECT h.`hb_create_time` FROM yeshi_ec_hongbao_v2 h WHERE h.`hb_type`
|
| | | IN(1,2) <![CDATA[AND h.hb_state <>4]]>
|
| | | AND h.`hb_uid` = #{uid}
|
| | | ORDER BY h.`hb_create_time` DESC
|
| | | LIMIT 1;
|
| | | </select>
|
| | |
|
| | |
|
| | | <select id="count24HOderByChannel" resultType="java.util.HashMap">
|
| | | SELECT <!-- COALESCE(SUM(b.money*2),0) AS 'commision', -->
|
| | | COALESCE(COUNT(b.hb_id),0) AS 'showValue',
|
| | | <!-- COALESCE(SUM(b.payMoney),0) AS 'payMoney', -->
|
| | | <if test="type == 1">
|
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS
|
| | | 'showDate'
|
| | | </if>
|
| | | <if test="type == 2">
|
| | | FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate'
|
| | | </if>
|
| | | <if test="type == 3">
|
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate'
|
| | | </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.`hb_uid` WHERE a.uid IS NOT NULL AND (h.`hb_type`=1 OR
|
| | | h.`hb_type`=20)
|
| | | ) b
|
| | | LEFT JOIN yeshi_ec_user u ON u.`id`=b.hb_uid
|
| | | WHERE <![CDATA[ b.hb_create_time<FROM_UNIXTIME((u.`createtime`+1000*60*60*24)/1000,'%Y-%m-%d %h:%m:%s')]]>
|
| | | <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="listShareAndInviteMoney" resultMap="BaseResultMap">
|
| | | SELECT IFNULL(SUM(h.`hb_money`),0) as totalMoney,h.*
|
| | | FROM
|
| | | `yeshi_ec_hongbao_v2` h
|
| | | WHERE h.hb_state <![CDATA[<>]]>4
|
| | | AND DATE_FORMAT(h.hb_create_time, '%Y-%m-%d' )= #{date}
|
| | | AND (
|
| | | h.`hb_type` =5 OR h.`hb_type` =6 OR h.`hb_type` =7 OR h.`hb_type` =20
|
| | | OR h.`hb_type` =21 OR h.`hb_type` =22 )
|
| | | GROUP BY h.`hb_uid`
|
| | | ORDER BY
|
| | | totalMoney DESC
|
| | | LIMIT ${start},${count}
|
| | | </select>
|
| | | |
| | | <select id="countRebateCouponMoney" resultType="java.math.BigDecimal">
|
| | | SELECT IFNULL(SUM(h.`hb_money`),0) FROM `yeshi_ec_hongbao_v2` h |
| | | where h.`hb_type` = 10
|
| | | </select>
|
| | |
|
| | |
|
| | | <select id="countRebateOrder" resultType="Long">
|
| | | SELECT IFNULL(COUNT(hb_id),0) FROM `yeshi_ec_hongbao_v2`
|
| | | WHERE hb_uid = #{uid} AND (hb_type =1 OR hb_type =2)
|
| | | </select>
|
| | |
|
| | | <select id="countShareOrInviteOrder" resultType="Long">
|
| | | SELECT IFNULL(COUNT(hb_id),0) FROM `yeshi_ec_hongbao_v2` |
| | | WHERE hb_uid = #{uid}
|
| | | AND (`hb_type` =5 OR `hb_type` =6 OR `hb_type` =7 OR `hb_type` =20 OR `hb_type`=21 OR `hb_type` =22 )
|
| | | </select>
|
| | |
|
| | | |
| | | </mapper>
|
| | | |
| | | <?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"> |
| | | |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.vo.order.HongBaoV2VO"> |
| | | <id column="hb_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="hb_urank" property="urank" jdbcType="INTEGER" /> |
| | | <result column="hb_money" property="money" jdbcType="DECIMAL" /> |
| | | <result column="hb_type" property="type" jdbcType="INTEGER" /> |
| | | <result column="hb_state" property="state" jdbcType="INTEGER" /> |
| | | <result column="hb_version" property="version" jdbcType="INTEGER" /> |
| | | <result column="hb_beizhu" property="beizhu" jdbcType="VARCHAR" /> |
| | | <result column="hb_pre_get_time" property="preGetTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="hb_get_time" property="getTime" jdbcType="TIMESTAMP" /> |
| | | <result column="hb_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="hb_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | |
| | | <result column="totalMoney" property="totalMoney" jdbcType="DECIMAL" /> |
| | | |
| | | <association property="userInfo" column="hb_uid" |
| | | javaType="com.yeshi.fanli.entity.bus.user.UserInfo"> |
| | | <id column="hb_uid" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | |
| | | <association property="parent" column="hb_pid" |
| | | javaType="com.yeshi.fanli.entity.bus.user.HongBaoV2"> |
| | | <id column="hb_pid" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | </resultMap> |
| | | |
| | | |
| | | <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 (t.hb_state = 1 or t.hb_state = 2) |
| | | </if> |
| | | <if test="state != null and state == 2"> <!-- 已到账 --> |
| | | AND t.hb_state = 3 |
| | | </if> |
| | | <if test="state != null and state == 3"> <!-- 红包已失效 --> |
| | | AND t.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 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 |
| | | </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" /> |
| | | <if test="channel != null and channel != 'all' "> |
| | | AND a.uid is not null |
| | | </if> |
| | | |
| | | <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 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 |
| | | </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" /> |
| | | <if test="channel != null and channel != 'all' "> |
| | | AND a.uid is not null |
| | | </if> |
| | | |
| | | <include refid="Count_Group_DateType" /> |
| | | ORDER BY t.`hb_create_time` |
| | | </select> |
| | | |
| | | <select id="countNumberByUid" resultType="java.lang.Long"> |
| | | select count(hb_id) |
| | | from yeshi_ec_hongbao_v2 where hb_uid=#{0} |
| | | </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="countMoneyByUidAndState" resultType="java.math.BigDecimal"> |
| | | SELECT CAST(SUM(hb.`hb_money`)AS DECIMAL(19,2)) |
| | | FROM |
| | | `yeshi_ec_hongbao_v2` hb |
| | | WHERE hb.`hb_uid` = #{uid} |
| | | <if test="state != null"> |
| | | AND hb.`hb_state` = #{state} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="countNumberByUidAndState" resultType="java.lang.Integer"> |
| | | SELECT COALESCE(count(hb_id),0) FROM yeshi_ec_hongbao_v2 |
| | | WHERE hb_uid = |
| | | #{uid} |
| | | <if test="state != null"> |
| | | AND hb_state = #{state} |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <select id="getTotalTiChengCount" resultType="java.lang.Integer" |
| | | parameterType="java.lang.Long"> |
| | | SELECT count(*) FROM `yeshi_ec_hongbao_v2` h |
| | | WHERE |
| | | h.`hb_uid`=#{0} |
| | | AND (h.`hb_type`=20 OR h.`hb_type`=21 OR h.`hb_type`=22 |
| | | OR h.`hb_type`=6 |
| | | OR h.`hb_type`=7) |
| | | </select> |
| | | |
| | | <select id="countValidNumberByUid" resultType="java.lang.Long"> |
| | | <!--统计有效订单数量 --> |
| | | SELECT COALESCE(count(hb.hb_id),0) FROM `yeshi_ec_hongbao_v2` hb |
| | | WHERE |
| | | hb.hb_uid =#{uid} |
| | | AND hb.hb_type not in (3,4) |
| | | AND <![CDATA[hb.hb_state <> 4]]> |
| | | |
| | | <if test="dateType != null and dateType == 1"> |
| | | AND TO_DAYS(FROM_UNIXTIME(hb.`hb_create_time`/1000)) = |
| | | TO_DAYS(NOW()) |
| | | </if> |
| | | <if test="dateType != null and dateType == 2"> |
| | | AND DATE_FORMAT( |
| | | FROM_UNIXTIME(hb.`hb_create_time`/1000),'%Y%m' ) = |
| | | DATE_FORMAT( |
| | | CURDATE( ) , '%Y%m' ) |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="countWillGetMoneyByUid" resultType="java.math.BigDecimal"> |
| | | SELECT |
| | | CAST(SUM(hb.`hb_money`)AS DECIMAL(19,2)) |
| | | FROM `yeshi_ec_hongbao_v2` hb |
| | | WHERE hb.`hb_uid` = #{uid} AND hb.`hb_state` |
| | | in (1,2) |
| | | </select> |
| | | |
| | | <select id="getLastHongBaoTime" resultType="java.util.Date"> |
| | | <!-- 最近一次下单时间 --> |
| | | SELECT h.`hb_create_time` FROM yeshi_ec_hongbao_v2 h WHERE h.`hb_type` |
| | | IN(1,2) <![CDATA[AND h.hb_state <>4]]> |
| | | AND h.`hb_uid` = #{uid} |
| | | ORDER BY h.`hb_create_time` DESC |
| | | LIMIT 1; |
| | | </select> |
| | | |
| | | |
| | | <select id="count24HOderByChannel" resultType="java.util.HashMap"> |
| | | SELECT <!-- COALESCE(SUM(b.money*2),0) AS 'commision', --> |
| | | COALESCE(COUNT(b.hb_id),0) AS 'showValue', |
| | | <!-- COALESCE(SUM(b.payMoney),0) AS 'payMoney', --> |
| | | <if test="type == 1"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS |
| | | 'showDate' |
| | | </if> |
| | | <if test="type == 2"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate' |
| | | </if> |
| | | <if test="type == 3"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate' |
| | | </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.`hb_uid` WHERE a.uid IS NOT NULL AND (h.`hb_type`=1 OR |
| | | h.`hb_type`=20) |
| | | ) b |
| | | LEFT JOIN yeshi_ec_user u ON u.`id`=b.hb_uid |
| | | WHERE <![CDATA[ b.hb_create_time<FROM_UNIXTIME((u.`createtime`+1000*60*60*24)/1000,'%Y-%m-%d %h:%m:%s')]]> |
| | | <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="listShareAndInviteMoney" resultMap="BaseResultMap"> |
| | | SELECT IFNULL(SUM(h.`hb_money`),0) as totalMoney,h.* |
| | | FROM |
| | | `yeshi_ec_hongbao_v2` h |
| | | WHERE h.hb_state <![CDATA[<>]]>4 |
| | | AND DATE_FORMAT(h.hb_create_time, '%Y-%m-%d' )= #{date} |
| | | AND ( |
| | | h.`hb_type` =5 OR h.`hb_type` =6 OR h.`hb_type` =7 OR h.`hb_type` =20 |
| | | OR h.`hb_type` =21 OR h.`hb_type` =22 ) |
| | | GROUP BY h.`hb_uid` |
| | | ORDER BY |
| | | totalMoney DESC |
| | | LIMIT ${start},${count} |
| | | </select> |
| | | |
| | | <select id="countRebateCouponMoney" resultType="java.math.BigDecimal"> |
| | | SELECT |
| | | IFNULL(SUM(h.`hb_money`),0) FROM `yeshi_ec_hongbao_v2` h |
| | | where h.`hb_type` = 10 |
| | | </select> |
| | | |
| | | |
| | | <select id="sumAlreadyGetMoneyByUid" resultType="java.math.BigDecimal"> |
| | | SELECT IFNULL(SUM(h.`hb_money`),0) FROM `yeshi_ec_hongbao_v2` h |
| | | where h.`hb_uid` = #{uid} |
| | | <if test="typeList!=null"> |
| | | <foreach collection="typeList" item="type" open=" and (" |
| | | separator=" or " close=")"> |
| | | h.hb_type=#{type} |
| | | </foreach> |
| | | </if> |
| | | |
| | | <if test="minGetTime!=null"> |
| | | and h.hb_get_time>=#{minGetTime} |
| | | </if> |
| | | |
| | | <if test="maxGetTime!=null"> |
| | | and #{maxGetTime}>h.hb_get_time |
| | | </if> |
| | | |
| | | </select> |
| | | |
| | | |
| | | <select id="countAlreadyGetMoneyByUid" resultType="java.lang.Long"> |
| | | SELECT count(h.hb_id) FROM `yeshi_ec_hongbao_v2` h |
| | | where h.`hb_uid` = #{uid} |
| | | <if test="typeList!=null"> |
| | | <foreach collection="typeList" item="type" open=" and (" |
| | | separator=" or " close=")"> |
| | | h.hb_type=#{type} |
| | | </foreach> |
| | | </if> |
| | | |
| | | <if test="minGetTime!=null"> |
| | | and h.hb_get_time>=#{minGetTime} |
| | | </if> |
| | | |
| | | <if test="maxGetTime!=null"> |
| | | and #{maxGetTime}>h.hb_get_time |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <select id="countRebateOrder" resultType="Long"> |
| | | SELECT IFNULL(COUNT(hb_id),0) FROM `yeshi_ec_hongbao_v2` |
| | | WHERE hb_uid = #{uid} AND (hb_type =1 OR hb_type =2) |
| | | </select> |
| | | |
| | | <select id="countShareOrInviteOrder" resultType="Long"> |
| | | SELECT IFNULL(COUNT(hb_id),0) FROM `yeshi_ec_hongbao_v2` |
| | | WHERE hb_uid = #{uid} |
| | | AND (`hb_type` =5 OR `hb_type` =6 OR `hb_type` =7 OR `hb_type` =20 OR `hb_type`=21 OR `hb_type` =22 ) |
| | | </select> |
| | | |
| | | </mapper> |