<?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.ThreeSaleMapper">
|
<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.ThreeSale">
|
<id column="id" property="id" jdbcType="BIGINT" />
|
<result column="state" property="state" jdbcType="BOOLEAN" />
|
<result column="createTime" property="createTime" jdbcType="BIGINT" />
|
<result column="expire" property="expire" jdbcType="INTEGER" />
|
|
<association property="boss" column="boss_id"
|
resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap" />
|
|
<association property="worker" column="worker_id"
|
javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
<id column="worker_id" property="id" jdbcType="BIGINT" />
|
</association>
|
|
</resultMap>
|
<sql id="Base_Column_List">id,boss_id,worker_id,state,expire,createTime</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_threeSale where id = #{id,jdbcType=BIGINT}
|
</select>
|
|
|
<select id="selectByUid" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_threeSale where boss_id = #{0} or worker_id=#{0}
|
</select>
|
|
|
|
<select id="selectBoss"
|
resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
u.*
|
from yeshi_ec_threeSale s left join
|
yeshi_ec_user u on u.id=s.boss_id where worker_id = #{0}
|
</select>
|
|
|
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
yeshi_ec_threeSale where id = #{id,jdbcType=BIGINT}
|
</delete>
|
<insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSale"
|
useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_threeSale
|
(id,boss_id,worker_id,state,expire,createTime) values
|
(#{id,jdbcType=BIGINT},#{boss.id,jdbcType=BIGINT},#{worker.id,jdbcType=BIGINT},#{state,jdbcType=BOOLEAN},#{expire,jdbcType=INTEGER},#{createTime,jdbcType=BIGINT})
|
</insert>
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSale"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into yeshi_ec_threeSale
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">id,</if>
|
<if test="boss != null">boss_id,</if>
|
<if test="worker != null">worker_id,</if>
|
<if test="state != null">state,</if>
|
<if test="expire != null">expire,</if>
|
<if test="createTime != null">createTime,</if>
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id,jdbcType=BIGINT},</if>
|
<if test="boss != null">#{boss.id,jdbcType=BIGINT},</if>
|
<if test="worker != null">#{worker.id,jdbcType=BIGINT},</if>
|
<if test="state != null">#{state,jdbcType=BOOLEAN},</if>
|
<if test="expire != null">#{expire,jdbcType=INTEGER},</if>
|
<if test="createTime != null">#{createTime,jdbcType=BIGINT},</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSale">update
|
yeshi_ec_threeSale set boss_id = #{boss.id,jdbcType=BIGINT},worker_id
|
= #{worker.id,jdbcType=BIGINT},state =
|
#{state,jdbcType=BOOLEAN},
|
expire = #{expire,jdbcType=INTEGER},
|
createTime = #{createTime,jdbcType=BIGINT}
|
where id = #{id,jdbcType=BIGINT}
|
</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSale">
|
update yeshi_ec_threeSale
|
<set>
|
<if test="boss != null">boss_id=#{boss.id,jdbcType=BIGINT},</if>
|
<if test="worker != null">worker_id=#{worker.id,jdbcType=BIGINT},</if>
|
<if test="state != null">state=#{state,jdbcType=BOOLEAN},</if>
|
<if test="expire != null">expire=#{expire,jdbcType=INTEGER},</if>
|
<if test="createTime != null">createTime=#{createTime,jdbcType=BIGINT},</if>
|
</set>
|
where id = #{id,jdbcType=BIGINT}
|
</update>
|
|
|
<update id="effectThreeSale" parameterType="java.lang.Long">
|
update
|
yeshi_ec_threeSale t
|
set t.state=1 where t.state=0 and t.worker_id=#{0} AND (t.expire = 0 OR t.expire IS NULL)
|
</update>
|
|
<!-- 查询一度队员集合 -->
|
<select id="queryMyFirstTeamList" resultMap="BaseResultMap">
|
SELECT * FROM `yeshi_ec_threesale` yet
|
WHERE yet.`state` = '1' AND yet.`boss_id` = #{bossId} AND (yet.expire = 0 OR yet.expire IS NULL)
|
<if test="key != null and key !='' ">
|
and yet.`worker_id` like '%${key}%'
|
</if>
|
ORDER BY yet.createtime DESC LIMIT ${start},${count}
|
</select>
|
|
<select id="queryCountMyFirstTeamList" resultType="java.lang.Long">
|
SELECT count(yet.id) FROM `yeshi_ec_threesale` yet
|
WHERE yet.`state` = '1' AND yet.`boss_id` = #{bossId} AND (yet.expire = 0 OR yet.expire IS NULL)
|
<if test="key != null and key !='' ">
|
and yet.`worker_id` like '%${key}%'
|
</if>
|
</select>
|
|
|
<!-- 查询二度队员集合 -->
|
<select id="queryMySecondTeamList" resultMap="BaseResultMap">
|
SELECT yet.* FROM (
|
SELECT DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale` ts
|
LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id`
|
WHERE ts.`state` = '1' AND tf.`boss_id`=#{bossId} AND (ts.expire = 0 OR ts.expire IS NULL)
|
<if test="key != null and key !='' ">
|
and ts.`worker_id` like '%${key}%'
|
</if>
|
)A
|
LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
|
ORDER BY yet.`createtime` DESC LIMIT ${start},${count}
|
</select>
|
|
<select id="queryCountMySecondTeamList" resultType="java.lang.Long" >
|
SELECT COUNT(A.id) FROM (
|
SELECT DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale` ts
|
LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id`
|
WHERE ts.`state` = '1' AND tf.`boss_id`=#{bossId} AND (ts.expire = 0 OR ts.expire IS NULL)
|
<if test="key != null and key !='' ">
|
and ts.`worker_id` like '%${key}%'
|
</if>
|
)A
|
</select>
|
|
<select id="queryLongTimeFailed" resultType="java.lang.Long">
|
<!-- 长时间未邀请成功 -->
|
SELECT h.`id` FROM `yeshi_ec_threesale` h
|
WHERE h.`state` = 0 AND (h.expire = 0 OR h.expire IS NULL)
|
<![CDATA[ AND DATE_SUB(CURDATE(), INTERVAL #{daysNum} DAY) > DATE(FROM_UNIXTIME(h.`createTime`/1000)) ]]>
|
</select>
|
|
|
<select id="queryLongTimeSuccess" resultMap="BaseResultMap">
|
<!-- 长时间未邀请成功 -->
|
SELECT * FROM `yeshi_ec_threesale` h
|
WHERE h.`state` = 1 AND (h.expire = 0 OR h.expire IS NULL)
|
<![CDATA[ AND DATE_SUB(CURDATE(), INTERVAL #{daysNum} DAY) > DATE(FROM_UNIXTIME(h.`createTime`/1000)) ]]>
|
</select>
|
|
|
<update id="updateExpire" parameterType="java.lang.Long">
|
update
|
yeshi_ec_threeSale t
|
set t.expire = 1
|
where t.`id` IN <foreach item="item" collection="list" open="(" separator=","
|
close=")">#{item}</foreach>
|
</update>
|
|
</mapper>
|