<?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.HongBaoV2Mapper">
|
<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.HongBaoV2">
|
<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" />
|
|
<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>
|
|
<!-- <association property="userInfo" column="hb_uid" resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap"/> -->
|
</resultMap>
|
|
|
|
<resultMap id="BaseDTOResultMap" type="com.yeshi.fanli.dto.HongBaoDTO">
|
<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="orderId" property="orderId" jdbcType="VARCHAR" />
|
|
<result column="payMoney" property="payMoney" jdbcType="DECIMAL" />
|
|
<result column="settlement" property="settlement" 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="Base_Column_List">hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time
|
</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT}
|
</select>
|
|
|
<select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT} for
|
update
|
</select>
|
|
|
|
<select id="listChildrenById" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao_v2 where hb_pid = #{0}
|
</select>
|
|
|
<select id="listCanBalanceHongBaoByType" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
FROM yeshi_ec_hongbao_v2 h WHERE h.`hb_version`=2 AND
|
h.`hb_type`=#{type} AND (h.`hb_state`=2) AND
|
h.`hb_pre_get_time` IS NOT
|
NULL AND h.`hb_pre_get_time`
|
<![CDATA[ <]]>
|
NOW() limit #{count}
|
</select>
|
|
<!-- 获取用户奖金列表 -->
|
<select id="listJiangJinByUid" resultMap="BaseDTOResultMap">
|
SELECT
|
hhh.*,co.`co_order_no` AS orderId,co.`co_payment` AS
|
payMoney,co.`co_settlement` AS settlement FROM
|
(
|
SELECT
|
hh.*,IF(h.`hb_id` IS NOT NULL,h.`hb_id`,hh.hb_id) AS hid FROM
|
(
|
SELECT
|
h.* FROM yeshi_ec_hongbao_v2 h WHERE h.hb_uid=#{uid} and
|
(h.`hb_type`=6 OR h.`hb_type`=7
|
OR h.`hb_type`=20 OR h.`hb_type`=21 OR
|
h.`hb_type`=22) AND
|
h.`hb_version`=2 ORDER BY h.`hb_create_time` DESC
|
limit #{start},#{count}
|
) hh
|
LEFT JOIN yeshi_ec_hongbao_v2 h ON
|
hh.hb_pid IS NOT NULL AND
|
h.`hb_id`=hh.hb_pid
|
) hhh LEFT JOIN
|
yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id`=hhh.hid
|
LEFT JOIN
|
yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
|
</select>
|
|
|
<!-- 获取用户奖金列表 -->
|
<select id="countJiangJinByUid" resultType="java.lang.Long">
|
SELECT count(h.hb_id)
|
FROM yeshi_ec_hongbao_v2 h WHERE h.hb_uid=#{0} and (h.`hb_type`=6 OR
|
h.`hb_type`=7
|
OR h.`hb_type`=20 OR h.`hb_type`=21 OR h.`hb_type`=22)
|
AND
|
h.`hb_version`=2
|
</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.`hb_money`) AS money FROM `yeshi_ec_hongbao_v2` h WHERE
|
h.`hb_uid`=#{0}
|
AND h.`hb_state`=3 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)) a
|
</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="getUnGetTiChengMoney" resultType="java.math.BigDecimal"
|
parameterType="java.lang.Long">
|
SELECT IF(a.money IS NULL,0,a.money ) FROM (SELECT
|
SUM(h.`hb_money`) AS money FROM `yeshi_ec_hongbao_v2` h WHERE
|
h.`hb_uid`=#{0}
|
AND (h.`hb_state`=1 OR h.hb_state=2 )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)) a
|
</select>
|
|
|
<select id="getTotalFanLiMoney" resultType="java.math.BigDecimal"
|
parameterType="java.lang.Long">
|
SELECT SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
|
WHERE h.`hb_uid`=#{uid} AND h.`hb_type`=1 AND h.`hb_state`=3
|
</select>
|
|
<select id="getUnRecievedFanLiMoney" resultType="java.math.BigDecimal"
|
parameterType="java.lang.Long">
|
SELECT SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
|
WHERE h.`hb_uid`=#{uid} AND h.`hb_type`=1 AND (h.`hb_state`=1 OR
|
h.`hb_state`=2)
|
</select>
|
|
|
<select id="listUidCanBanlanceShareAndInvite" resultType="java.lang.Long"
|
parameterType="java.lang.Integer">
|
|
SELECT DISTINCT( h.`hb_uid`) FROM yeshi_ec_hongbao_v2 h
|
WHERE
|
(`hb_type`=6 OR
|
`hb_type`=7 OR `hb_type`=20 OR `hb_type`=21 OR
|
`hb_type`=22 ) AND
|
`hb_version`=2 AND (hb_state=1 OR hb_state=2) AND
|
hb_pre_get_time IS
|
NOT NULL AND hb_pre_get_time>0 AND
|
NOW()>=hb_pre_get_time limit #{0}
|
|
</select>
|
|
|
<select id="listCanBalanceHongBaoByTypeAndUid" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_hongbao_v2 where hb_uid=#{uid} and `hb_version`=2
|
|
<foreach collection="types" item="type" open=" and ("
|
separator=" or " close=")">
|
hb_type =
|
#{type}
|
</foreach>
|
|
and
|
(hb_state=1 or hb_state=2) and
|
hb_pre_get_time IS NOT NULL AND
|
hb_pre_get_time>0 AND
|
NOW()>=hb_pre_get_time limit
|
#{count}
|
</select>
|
|
<select id="countInviteOrderCountByUidAndSettleTime" resultType="java.lang.Long">
|
SELECT COUNT(h.hb_id) FROM yeshi_ec_hongbao_v2 h LEFT JOIN
|
yeshi_ec_hongbao_order ho ON h.`hb_pid`=ho.`ho_hongbao_id` LEFT JOIN
|
yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE
|
h.`hb_uid`=#{uid} and (h.`hb_type`=6 or h.`hb_type`=7 OR
|
h.`hb_type`=21 OR h.`hb_type`=22) and co.`co_state`=#{state} and
|
co.`co_settle_time` is not null and co.`co_settle_time`>=#{minDate}
|
and #{maxDate}>co.`co_settle_time`;
|
</select>
|
|
|
|
|
<select id="getUnRecievedMoneyWithCreateTime" resultType="java.math.BigDecimal">
|
SELECT
|
SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
|
WHERE h.`hb_uid`=#{uid}
|
AND (h.`hb_state`=1 OR
|
h.`hb_state`=2) and hb_create_time>=#{minDate}
|
and #{maxDate} > hb_create_time
|
</select>
|
|
|
|
<select id="getUnRecievedMoneyWithPreGetTime" resultType="java.math.BigDecimal">
|
SELECT
|
SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
|
WHERE h.`hb_uid`=#{uid}
|
AND (h.`hb_state`=1 OR
|
h.`hb_state`=2) and hb_pre_get_time is not null
|
and hb_pre_get_time>=#{minDate}
|
and #{maxDate} > hb_pre_get_time
|
</select>
|
|
|
<select id="countByUidAndState" resultType="java.lang.Long">
|
SELECT
|
SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
|
WHERE h.`hb_uid`=#{uid}
|
AND h.`hb_state`=#{state}
|
</select>
|
|
|
|
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT}
|
</delete>
|
<insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2"
|
useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_hongbao_v2
|
(hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time)
|
values
|
(#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{urank,jdbcType=INTEGER},#{parent.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{version,jdbcType=INTEGER},#{beizhu,jdbcType=VARCHAR},#{preGetTime,jdbcType=TIMESTAMP},#{getTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
|
</insert>
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into yeshi_ec_hongbao_v2
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">hb_id,</if>
|
<if test="userInfo != null">hb_uid,</if>
|
<if test="urank != null">hb_urank,</if>
|
<if test="parent != null">hb_pid,</if>
|
<if test="money != null">hb_money,</if>
|
<if test="type != null">hb_type,</if>
|
<if test="state != null">hb_state,</if>
|
<if test="version != null">hb_version,</if>
|
<if test="beizhu != null">hb_beizhu,</if>
|
<if test="preGetTime != null">hb_pre_get_time,</if>
|
<if test="getTime != null">hb_get_time,</if>
|
<if test="createTime != null">hb_create_time,</if>
|
<if test="updateTime != null">hb_update_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="urank != null">#{urank,jdbcType=INTEGER},</if>
|
<if test="parent != null">#{parent.id,jdbcType=BIGINT},</if>
|
<if test="money != null">#{money,jdbcType=DECIMAL},</if>
|
<if test="type != null">#{type,jdbcType=INTEGER},</if>
|
<if test="state != null">#{state,jdbcType=INTEGER},</if>
|
<if test="version != null">#{version,jdbcType=INTEGER},</if>
|
<if test="beizhu != null">#{beizhu,jdbcType=VARCHAR},</if>
|
<if test="preGetTime != null">#{preGetTime,jdbcType=TIMESTAMP},</if>
|
<if test="getTime != null">#{getTime,jdbcType=TIMESTAMP},</if>
|
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
<if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2">update
|
yeshi_ec_hongbao_v2 set hb_uid =
|
#{userInfo.id,jdbcType=BIGINT},hb_urank =
|
#{urank,jdbcType=INTEGER},hb_pid =
|
#{parent.id,jdbcType=BIGINT},hb_money =
|
#{money,jdbcType=DECIMAL},hb_type = #{type,jdbcType=INTEGER},hb_state
|
= #{state,jdbcType=INTEGER},hb_version =
|
#{version,jdbcType=INTEGER},hb_beizhu =
|
#{beizhu,jdbcType=VARCHAR},hb_pre_get_time =
|
#{preGetTime,jdbcType=TIMESTAMP},hb_get_time =
|
#{getTime,jdbcType=TIMESTAMP},hb_create_time =
|
#{createTime,jdbcType=TIMESTAMP},hb_update_time =
|
#{updateTime,jdbcType=TIMESTAMP} where hb_id = #{id,jdbcType=BIGINT}
|
</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
|
update yeshi_ec_hongbao_v2
|
<set>
|
<if test="userInfo != null">hb_uid=#{userInfo.id,jdbcType=BIGINT},</if>
|
<if test="urank != null">hb_urank=#{urank,jdbcType=INTEGER},</if>
|
<if test="parent != null">hb_pid=#{parent.id,jdbcType=BIGINT},</if>
|
<if test="money != null">hb_money=#{money,jdbcType=DECIMAL},</if>
|
<if test="type != null">hb_type=#{type,jdbcType=INTEGER},</if>
|
<if test="state != null">hb_state=#{state,jdbcType=INTEGER},</if>
|
<if test="version != null">hb_version=#{version,jdbcType=INTEGER},</if>
|
<if test="beizhu != null">hb_beizhu=#{beizhu,jdbcType=VARCHAR},</if>
|
<if test="preGetTime != null">hb_pre_get_time=#{preGetTime,jdbcType=TIMESTAMP},</if>
|
<if test="getTime != null">hb_get_time=#{getTime,jdbcType=TIMESTAMP},</if>
|
<if test="createTime != null">hb_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
|
<if test="updateTime != null">hb_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
|
</set>
|
where hb_id = #{id,jdbcType=BIGINT}
|
</update>
|
</mapper>
|