<?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.hongbao.HongBaoMapper">
|
<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.HongBao">
|
<id column="id" property="id" jdbcType="BIGINT" />
|
<result column="auctionId" property="auctionId" jdbcType="BIGINT" />
|
<result column="payMoney" property="payMoney" jdbcType="DECIMAL" />
|
<result column="money" property="money" jdbcType="DECIMAL" />
|
<result column="param" property="param" jdbcType="VARCHAR" />
|
<result column="type" property="type" jdbcType="INTEGER" />
|
<result column="state" property="state" jdbcType="INTEGER" />
|
<result column="createtime" property="createtime" jdbcType="BIGINT" />
|
<result column="pre_get_time" property="preGettime" jdbcType="BIGINT" />
|
<result column="get_time" property="getTime" jdbcType="BIGINT" />
|
<result column="get_ip" property="getIp" jdbcType="VARCHAR" />
|
<result column="beizhu" property="beizhu" jdbcType="VARCHAR" />
|
<result column="order_id" property="orderId" jdbcType="VARCHAR" />
|
<result column="order_item_id" property="orderItemId" jdbcType="BIGINT" />
|
<result column="urank" property="urank" jdbcType="INTEGER" />
|
<result column="hasChild" property="hasChild" jdbcType="BOOLEAN" />
|
<result column="version" property="version" jdbcType="INTEGER" />
|
<result column="balance_time" property="balanceTime" jdbcType="TIMESTAMP" />
|
<association property="userInfo" column="uid"
|
javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
<id column="uid" property="id" jdbcType="BIGINT" />
|
</association>
|
<association property="parent" column="pid"
|
javaType="com.yeshi.fanli.entity.bus.user.HongBao">
|
<id column="pid" property="id" jdbcType="BIGINT" />
|
</association>
|
<association property="order" column="oid"
|
select="com.yeshi.fanli.dao.mybatis.order.OrderMapper.selectByPrimaryKey">
|
</association>
|
|
</resultMap>
|
|
<resultMap id="ResultMap" type="com.yeshi.fanli.entity.bus.user.HongBao">
|
<id column="id" property="id" jdbcType="BIGINT" />
|
<result column="auctionId" property="auctionId" jdbcType="BIGINT" />
|
<result column="payMoney" property="payMoney" jdbcType="DECIMAL" />
|
<result column="money" property="money" jdbcType="DECIMAL" />
|
<result column="param" property="param" jdbcType="VARCHAR" />
|
<result column="type" property="type" jdbcType="INTEGER" />
|
<result column="state" property="state" jdbcType="INTEGER" />
|
<result column="createtime" property="createtime" jdbcType="BIGINT" />
|
<result column="pre_get_time" property="preGettime" jdbcType="BIGINT" />
|
<result column="get_time" property="getTime" jdbcType="BIGINT" />
|
<result column="get_ip" property="getIp" jdbcType="VARCHAR" />
|
<result column="beizhu" property="beizhu" jdbcType="VARCHAR" />
|
<result column="order_id" property="orderId" jdbcType="VARCHAR" />
|
<result column="order_item_id" property="orderItemId" jdbcType="BIGINT" />
|
<result column="urank" property="urank" jdbcType="INTEGER" />
|
<result column="hasChild" property="hasChild" jdbcType="BOOLEAN" />
|
<result column="version" property="version" jdbcType="INTEGER" />
|
<result column="balance_time" property="balanceTime" jdbcType="TIMESTAMP" />
|
<result column="ShareAndInviteMoney" property="ShareAndInviteMoney"
|
jdbcType="DECIMAL" />
|
|
<association property="userInfo" column="uid"
|
select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPrimaryKey">
|
</association>
|
|
<association property="parent" column="pid"
|
javaType="com.yeshi.fanli.entity.bus.user.HongBao">
|
<id column="pid" property="id" jdbcType="BIGINT" />
|
</association>
|
|
</resultMap>
|
|
<sql id="Base_Column_List">id,uid,auctionId,payMoney,pid,money,param,type,state,createtime,pre_get_time,get_time,get_ip,beizhu,order_id,order_item_id,oid,urank,hasChild,version,balance_time
|
</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao where id = #{id,jdbcType=BIGINT}
|
</select>
|
|
<select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao where id = #{id,jdbcType=BIGINT} for update
|
</select>
|
|
|
<select id="selectByUid" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao where uid = #{0}
|
</select>
|
|
|
<select id="selectByUidAndType" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao where uid = #{uid} and type=#{type}
|
</select>
|
|
|
|
|
|
<select id="selectByOrderId" resultMap="BaseResultMap"
|
parameterType="java.lang.String">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao where order_id = #{0}
|
</select>
|
|
|
<select id="selectByOrderIdWithoutChild" resultMap="BaseResultMap"
|
parameterType="java.lang.String">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao where order_id = #{0} and pid is null
|
</select>
|
|
|
<select id="selectChildHongBaoByPid" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao where pid = #{0}
|
</select>
|
|
|
|
|
|
<select id="selectCanBalanceHongBaoCountByType" resultType="java.lang.Long"
|
parameterType="java.lang.Integer">
|
select
|
count(*)
|
from yeshi_ec_hongbao where `version`=2
|
and type = #{type} and
|
(state=1 or state=2) AND pre_get_time IS NOT
|
NULL and
|
pre_get_time>0 and unix_timestamp()*1000>=pre_get_time
|
</select>
|
|
|
|
<select id="selectCanBalanceHongBaoByType" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao where `version`=2 and type = #{type} and
|
(state=1 or state=2) AND pre_get_time IS NOT NULL and
|
pre_get_time>0 and unix_timestamp()*1000>=pre_get_time limit
|
#{count}
|
</select>
|
|
|
<select id="selectCanBalanceHongBaoByTypeAndUid" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao where uid=#{uid} and `version`=2 and type =
|
#{type} and
|
(state=1 or state=2) AND pre_get_time IS NOT NULL and
|
pre_get_time>0 and unix_timestamp()*1000>=pre_get_time limit
|
#{count}
|
</select>
|
|
<select id="selectCanBalanceHongBaoByChildHongBao" resultMap="BaseResultMap"
|
parameterType="java.lang.Integer">select h.* from yeshi_ec_hongbao h right join (select
|
distinct( `pid`) as pid from yeshi_ec_hongbao where (`type`=6 or
|
`type`=7) and `version`=2 and (state=1 or state=2) and pre_get_time is
|
not null and pre_get_time>0 and
|
unix_timestamp()*1000>=pre_get_time limit #{0} ) s on s.pid=h.`id`
|
</select>
|
|
|
<select id="selectCanBalanceHongBaoByChildHongBaoAndUid"
|
resultMap="BaseResultMap" parameterType="java.lang.Long">
|
SELECT * FROM yeshi_ec_hongbao
|
WHERE uid=#{0} and
|
(`type`=6 OR
|
`type`=7)
|
AND `version`=2 AND (state=1 OR
|
state=2) AND
|
pre_get_time IS
|
NOT NULL
|
AND pre_get_time>0 AND
|
UNIX_TIMESTAMP()*1000>=pre_get_time
|
</select>
|
|
|
|
|
<select id="selectUidCanBalanceHongBaoByChildHongBao"
|
resultType="java.lang.Long">
|
SELECT DISTINCT( `uid`) FROM yeshi_ec_hongbao WHERE
|
(`type`=6 OR
|
`type`=7)
|
AND `version`=2 AND (state=1 OR state=2) AND
|
pre_get_time IS
|
NOT NULL
|
AND pre_get_time>0 AND
|
UNIX_TIMESTAMP()*1000>=pre_get_time
|
</select>
|
|
<select id="selectByOid" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao where oid = #{0}
|
</select>
|
<select id="selectByOrderIdSortWithAucationIdAndPayMoney"
|
resultMap="BaseResultMap" parameterType="java.lang.String">SELECT h. * FROM
|
yeshi_ec_hongbao h LEFT JOIN yeshi_ec_order o ON h.`oid` =o.`id` WHERE
|
o.`orderid` =#{0} ORDER BY h.`auctionId`, h.payMoney
|
</select>
|
<select id="selectMultiHongBaoOrder" resultType="java.lang.String">SELECT a.orderid
|
FROM (SELECT COUNT(*) c,o.`orderid` AS orderid FROM yeshi_ec_hongbao h
|
LEFT JOIN yeshi_ec_order o ON o.`id`=h.`oid` WHERE h.`version`=2 AND
|
h.`type`=1 GROUP BY h.`oid` HAVING c>0 ORDER BY h.id DESC) a limit
|
10
|
</select>
|
<select id="findChildHongBaoList" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao where pid = #{0}
|
</select>
|
|
|
<select id="getTotalTiChengMoney" resultType="java.math.BigDecimal"
|
parameterType="java.lang.Long">
|
SELECT IF(a.money IS NULL,0,a.money ) FROM (SELECT
|
SUM(h.`money`) AS money FROM `yeshi_ec_hongbao` h WHERE h.`uid`=#{0}
|
AND h.`state`=3 AND (h.`type`=20 OR h.`type`=21 OR h.`type`=22 OR
|
h.`type`=6 OR h.`type`=7)) a
|
</select>
|
|
<select id="getTotalTiChengCount" resultType="java.lang.Integer"
|
parameterType="java.lang.Long">
|
SELECT
|
count(*) FROM `yeshi_ec_hongbao` h
|
WHERE
|
h.`uid`=#{0} AND (h.`type`=20 OR h.`type`=21 OR h.`type`=22 OR
|
h.`type`=6 OR h.`type`=7)
|
</select>
|
|
|
<select id="getUnGetTiChengMoney" resultType="java.math.BigDecimal"
|
parameterType="java.lang.Long">
|
SELECT IF(a.money IS NULL,0,a.money ) FROM (SELECT
|
SUM(h.`money`) AS money FROM `yeshi_ec_hongbao` h WHERE h.`uid`=#{0}
|
AND (h.`state`=1 OR h.state=2 )AND (h.`type`=20 OR h.`type`=21 OR
|
h.`type`=22 OR h.`type`=6 OR h.`type`=7)) a
|
</select>
|
|
|
<select id="selectByIdOrPid" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao where id = #{0} or pid=#{0}
|
</select>
|
|
|
|
|
|
|
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
yeshi_ec_hongbao where id = #{id,jdbcType=BIGINT}
|
</delete>
|
<insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.HongBao"
|
useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_hongbao
|
(id,uid,auctionId,payMoney,pid,money,param,type,state,createtime,pre_get_time,get_time,get_ip,beizhu,order_id,order_item_id,oid,urank,hasChild,version,balance_time)
|
values
|
(#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{auctionId,jdbcType=BIGINT},#{payMoney,jdbcType=DECIMAL},#{parent.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{param,jdbcType=VARCHAR},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createtime,jdbcType=BIGINT},#{preGettime,jdbcType=BIGINT},#{getTime,jdbcType=BIGINT},#{getIp,jdbcType=VARCHAR},#{beizhu,jdbcType=VARCHAR},#{orderId,jdbcType=VARCHAR},#{orderItemId,jdbcType=BIGINT},#{order.id,jdbcType=BIGINT},#{urank,jdbcType=INTEGER},#{hasChild,jdbcType=BOOLEAN},#{version,jdbcType=INTEGER},#{balanceTime,jdbcType=TIMESTAMP})
|
</insert>
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.HongBao"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into yeshi_ec_hongbao
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">id,</if>
|
<if test="userInfo != null">uid,</if>
|
<if test="auctionId != null">auctionId,</if>
|
<if test="payMoney != null">payMoney,</if>
|
<if test="parent != null">pid,</if>
|
<if test="money != null">money,</if>
|
<if test="param != null">param,</if>
|
<if test="type != null">type,</if>
|
<if test="state != null">state,</if>
|
<if test="createtime != null">createtime,</if>
|
<if test="preGettime != null">pre_get_time,</if>
|
<if test="getTime != null">get_time,</if>
|
<if test="getIp != null">get_ip,</if>
|
<if test="beizhu != null">beizhu,</if>
|
<if test="orderId != null">order_id,</if>
|
<if test="orderItemId != null">order_item_id,</if>
|
<if test="order != null">oid,</if>
|
<if test="urank != null">urank,</if>
|
<if test="hasChild != null">hasChild,</if>
|
<if test="version != null">version,</if>
|
<if test="balanceTime != null">balance_time,</if>
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id,jdbcType=BIGINT},</if>
|
<if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if>
|
<if test="auctionId != null">#{auctionId,jdbcType=BIGINT},</if>
|
<if test="payMoney != null">#{payMoney,jdbcType=DECIMAL},</if>
|
<if test="parent != null">#{parent.id,jdbcType=BIGINT},</if>
|
<if test="money != null">#{money,jdbcType=DECIMAL},</if>
|
<if test="param != null">#{param,jdbcType=VARCHAR},</if>
|
<if test="type != null">#{type,jdbcType=INTEGER},</if>
|
<if test="state != null">#{state,jdbcType=INTEGER},</if>
|
<if test="createtime != null">#{createtime,jdbcType=BIGINT},</if>
|
<if test="preGettime != null">#{preGettime,jdbcType=BIGINT},</if>
|
<if test="getTime != null">#{getTime,jdbcType=BIGINT},</if>
|
<if test="getIp != null">#{getIp,jdbcType=VARCHAR},</if>
|
<if test="beizhu != null">#{beizhu,jdbcType=VARCHAR},</if>
|
<if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
|
<if test="orderItemId != null">#{orderItemId,jdbcType=BIGINT},</if>
|
<if test="order != null">#{order.id,jdbcType=BIGINT},</if>
|
<if test="urank != null">#{urank,jdbcType=INTEGER},</if>
|
<if test="hasChild != null">#{hasChild,jdbcType=BOOLEAN},</if>
|
<if test="version != null">#{version,jdbcType=INTEGER},</if>
|
<if test="balanceTime != null">#{balanceTime,jdbcType=TIMESTAMP}</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.HongBao">update
|
yeshi_ec_hongbao set uid = #{userInfo.id,jdbcType=BIGINT},auctionId =
|
#{auctionId,jdbcType=BIGINT},payMoney =
|
#{payMoney,jdbcType=DECIMAL},pid = #{parent.id,jdbcType=BIGINT},money
|
= #{money,jdbcType=DECIMAL},param = #{param,jdbcType=VARCHAR},type =
|
#{type,jdbcType=INTEGER},state = #{state,jdbcType=INTEGER},createtime
|
= #{createtime,jdbcType=BIGINT},pre_get_time =
|
#{preGettime,jdbcType=BIGINT},get_time =
|
#{getTime,jdbcType=BIGINT},get_ip = #{getIp,jdbcType=VARCHAR},beizhu =
|
#{beizhu,jdbcType=VARCHAR},order_id =
|
#{orderId,jdbcType=VARCHAR},order_item_id =
|
#{orderItemId,jdbcType=BIGINT},oid = #{order.id,jdbcType=BIGINT},urank
|
= #{urank,jdbcType=INTEGER},hasChild =
|
#{hasChild,jdbcType=BOOLEAN},version = #{version,jdbcType=INTEGER}
|
,balance_time =#{balanceTime,jdbcType=TIMESTAMP} where id =
|
#{id,jdbcType=BIGINT}
|
</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.HongBao">
|
update yeshi_ec_hongbao
|
<set>
|
<if test="userInfo != null">uid=#{userInfo.id,jdbcType=BIGINT},</if>
|
<if test="auctionId != null">auctionId=#{auctionId,jdbcType=BIGINT},</if>
|
<if test="payMoney != null">payMoney=#{payMoney,jdbcType=DECIMAL},</if>
|
<if test="parent != null">pid=#{parent.id,jdbcType=BIGINT},</if>
|
<if test="money != null">money=#{money,jdbcType=DECIMAL},</if>
|
<if test="param != null">param=#{param,jdbcType=VARCHAR},</if>
|
<if test="type != null">type=#{type,jdbcType=INTEGER},</if>
|
<if test="state != null">state=#{state,jdbcType=INTEGER},</if>
|
<if test="createtime != null">createtime=#{createtime,jdbcType=BIGINT},</if>
|
<if test="preGettime != null">pre_get_time=#{preGettime,jdbcType=BIGINT},</if>
|
<if test="getTime != null">get_time=#{getTime,jdbcType=BIGINT},</if>
|
<if test="getIp != null">get_ip=#{getIp,jdbcType=VARCHAR},</if>
|
<if test="beizhu != null">beizhu=#{beizhu,jdbcType=VARCHAR},</if>
|
<if test="orderId != null">order_id=#{orderId,jdbcType=VARCHAR},</if>
|
<if test="orderItemId != null">order_item_id=#{orderItemId,jdbcType=BIGINT},</if>
|
<if test="order != null">oid=#{order.id,jdbcType=BIGINT},</if>
|
<if test="urank != null">urank=#{urank,jdbcType=INTEGER},</if>
|
<if test="hasChild != null">hasChild=#{hasChild,jdbcType=BOOLEAN},</if>
|
<if test="version != null">version=#{version,jdbcType=INTEGER},</if>
|
<if test="balanceTime !=null">balance_time =#{balanceTime,jdbcType=TIMESTAMP},</if>
|
</set>
|
where id = #{id,jdbcType=BIGINT}
|
</update>
|
|
<select id="getCountOrder" resultType="java.lang.Long">
|
SELECT count(id) FROM `yeshi_ec_hongbao`
|
WHERE 1>0 and type NOT IN
|
(3,4) AND uid =#{uid}
|
|
<if test="createtime != null and createtime !=''">
|
<![CDATA[ AND createtime <= '${createtime}' ]]>
|
</if>
|
</select>
|
|
<select id="getCountCancelOrder" resultType="java.lang.Long">
|
<!-- 用户的维权订单 -->
|
SELECT count(id) FROM `yeshi_ec_hongbao` h
|
WHERE h.`state` = 4 AND uid
|
=#{uid}
|
and (h.balance_time IS NOT NULL OR h.balance_time > 0 )
|
<if test="createtime != null and createtime !='' ">
|
<![CDATA[ AND createtime <= '${createtime}' ]]>
|
</if>
|
</select>
|
|
<select id="selectOrderByUid" resultMap="BaseResultMap">
|
SELECT * FROM `yeshi_ec_hongbao` WHERE uid =${uid}
|
<if test="startTime != null and startTime !='' ">
|
<![CDATA[ AND FROM_UNIXTIME(get_time/1000) >= '${startTime}' ]]>
|
</if>
|
<if test="endTime != null and endTime !=''">
|
<![CDATA[ AND FROM_UNIXTIME(get_time/1000) <= '${endTime}' ]]>
|
</if>
|
ORDER BY createtime DESC LIMIT #{start},#{count}
|
</select>
|
|
<select id="countOrderByUid" resultType="java.lang.Integer">
|
SELECT COALESCE(count(id),0) FROM `yeshi_ec_hongbao` WHERE uid =${uid}
|
<if test="startTime != null and startTime !=''">
|
<![CDATA[ AND FROM_UNIXTIME(get_time/1000) >= '${startTime}' ]]>
|
</if>
|
<if test="endTime != null and endTime !=''">
|
<![CDATA[ AND FROM_UNIXTIME(get_time/1000) <= '${endTime}' ]]>
|
</if>
|
</select>
|
|
<select id="countProfitByUid" resultType="java.lang.Double">
|
SELECT COALESCE(SUM(money),0) FROM `yeshi_ec_hongbao` WHERE uid
|
=${uid} AND state = 3
|
<if test="startTime != null and startTime !=''">
|
<![CDATA[ AND FROM_UNIXTIME(get_time/1000) >= '${startTime}' ]]>
|
</if>
|
<if test="endTime != null and endTime !=''">
|
<![CDATA[ AND FROM_UNIXTIME(get_time/1000) <= '${endTime}' ]]>
|
</if>
|
</select>
|
|
|
|
|
<select id="getCountCancelByUid" resultType="java.lang.Integer">
|
SELECT
|
COALESCE(count(id),0) FROM `yeshi_ec_hongbao`
|
WHERE uid =#{uid} and
|
state = 4
|
</select>
|
|
|
<select id="getCountByUid" resultType="java.lang.Integer">
|
SELECT
|
COALESCE(count(id),0) FROM `yeshi_ec_hongbao`
|
WHERE uid =#{uid}
|
</select>
|
|
|
<select id="getCountByUidAndState" resultType="java.lang.Integer">
|
SELECT
|
COALESCE(count(id),0) FROM `yeshi_ec_hongbao`
|
WHERE uid =#{uid} and
|
state=#{state}
|
</select>
|
|
<select id="getCountByUidOrder" resultType="java.lang.Long">
|
SELECT
|
IFNULL(SUM(num) , 0)AS totalNum FROM (SELECT COUNT(id) AS num FROM
|
`yeshi_ec_hongbao` h
|
WHERE uid =#{uid} AND order_id IS NOT NULL GROUP
|
BY h.order_id )A;
|
</select>
|
|
<!-- 统计已领取金额 账户历史总收益 -->
|
<select id="countReceiveMoneysByUid" resultType="java.lang.Double">
|
SELECT
|
COALESCE(SUM(money),0) FROM `yeshi_ec_hongbao` WHERE state = 3 AND uid
|
= ${uid};
|
</select>
|
|
<!-- 统计未领取金额 待入账收益 -->
|
<select id="countForecastMoneysByUid" resultType="java.lang.Double">
|
SELECT
|
COALESCE(SUM(money),0) FROM `yeshi_ec_hongbao` WHERE state in (1,2)
|
AND uid = #{uid};
|
</select>
|
|
|
<select id="queryByOrderIDAndPayMoney" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List" />
|
FROM `yeshi_ec_hongbao` h
|
WHERE h.`order_id` =#{oid} AND h.`payMoney`=
|
#{payMoney}
|
</select>
|
|
<select id="queryByOrderIDAndUid" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List" />
|
FROM `yeshi_ec_hongbao` h
|
WHERE h.`order_id` =#{oid} AND h.`uid`=
|
#{uid}
|
</select>
|
|
|
<select id="countByUidSelf" resultType="java.lang.Long">
|
<!-- 自购订单 -->
|
SELECT COALESCE(count(id),0) FROM `yeshi_ec_hongbao` hb
|
WHERE uid
|
=#{uid} and type in (1,2) <![CDATA[AND hb.state <>4]]>
|
<if test="isToday != null and isToday == 1">
|
AND TO_DAYS(FROM_UNIXTIME(hb.`createtime`/1000)) =
|
TO_DAYS(NOW())
|
</if>
|
<if test="isMonth != null and isMonth == 1">
|
AND DATE_FORMAT( FROM_UNIXTIME(hb.`createtime`/1000),
|
'%Y%m' ) =
|
DATE_FORMAT( CURDATE( ) , '%Y%m' )
|
</if>
|
</select>
|
|
|
<select id="getLastOrderTime" resultType="java.lang.Long">
|
<!-- 最近一次下单时间 -->
|
SELECT h.`createtime` FROM yeshi_ec_hongbao h WHERE h.`type` IN(1,2)
|
<![CDATA[AND h.state <>4]]>
|
AND h.`uid` = #{uid,jdbcType=BIGINT}
|
ORDER BY h.`createtime` DESC LIMIT
|
1;
|
</select>
|
|
|
<select id="getMaxMoney" resultType="java.lang.Double">
|
<!--查询前3天返利金额总额最高值 -->
|
SELECT SUM(h.`money`)AS totalMoney FROM `yeshi_ec_hongbao` h
|
WHERE <![CDATA[TO_DAYS(NOW()) - TO_DAYS(FROM_UNIXTIME(h.`createtime`/1000)) <= 3]]>
|
|
<!-- DATE_FORMAT(FROM_UNIXTIME(h.`createtime`/1000), '%Y%m' ) = DATE_FORMAT(CURDATE()
|
, '%Y%m' ) -->
|
|
<![CDATA[AND h.state <>4]]>
|
|
AND h.`type` IN
|
<foreach collection="typeArray" item="item" index="index"
|
open="(" close=")" separator=",">
|
#{item}
|
</foreach>
|
|
GROUP BY h.uid
|
ORDER BY totalMoney DESC LIMIT 0,1
|
</select>
|
|
|
|
<select id="listShareAndInviteMoney" resultMap="ResultMap">
|
SELECT IFNULL(SUM(h.`money`),0) as ShareAndInviteMoney,
|
<include refid="Base_Column_List" />
|
FROM `yeshi_ec_hongbao` h
|
WHERE
|
DATE_FORMAT(FROM_UNIXTIME(h.`createtime`/1000), '%Y-%m-%d' )= #{date}
|
<![CDATA[AND h.state <>4]]>
|
AND ( h.`type` =5 OR h.`type` =6 OR h.`type` =7 OR h.`type` =20 OR
|
h.`type` =21 OR h.`type` =22 )
|
GROUP BY h.`uid`
|
ORDER BY SUM(h.`money`)
|
DESC
|
LIMIT ${start},${count}
|
</select>
|
|
|
<select id="selectCountByTypeAndStateAndCreateTime" resultType="java.lang.Long">
|
SELECT COUNT(h.`id`) FROM yeshi_ec_hongbao h WHERE uid=#{uid}
|
<foreach collection="type" item="itemType" open="and ("
|
separator=" or " close=")">
|
h.`type`=#{itemType}
|
</foreach>
|
|
|
<foreach collection="state" item="itemState" open="and ("
|
separator=" or " close=")">
|
h.`state`=#{itemState}
|
</foreach>
|
|
AND FROM_UNIXTIME( h.`createtime`/1000)>=#{minTime} AND FROM_UNIXTIME(
|
h.`createtime`/1000)
|
<![CDATA[
|
<
|
]]>
|
#{maxTime};
|
</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 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>
|