<?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="succeedTime" property="succeedTime" jdbcType="BIGINT" />
|
<result column="createTime" property="createTime" jdbcType="BIGINT" />
|
<result column="updateTime" property="updateTime" jdbcType="BIGINT" />
|
<result column="expire" property="expire" jdbcType="INTEGER" />
|
|
<association property="boss" column="boss_id"
|
javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
<id column="boss_id" property="id" jdbcType="BIGINT" />
|
</association>
|
|
<association property="worker" column="worker_id"
|
javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
<id column="worker_id" property="id" jdbcType="BIGINT" />
|
</association>
|
</resultMap>
|
|
<resultMap id="AllResultMap" type="com.yeshi.fanli.entity.bus.user.ThreeSale">
|
<id column="id" property="id" jdbcType="BIGINT" />
|
<result column="state" property="state" jdbcType="BOOLEAN" />
|
<result column="succeedTime" property="succeedTime" jdbcType="BIGINT" />
|
<result column="createTime" property="createTime" jdbcType="BIGINT" />
|
<result column="updateTime" property="updateTime" jdbcType="BIGINT" />
|
<result column="expire" property="expire" jdbcType="INTEGER" />
|
<result column="stateSuper" property="stateSuper" jdbcType="BOOLEAN" />
|
|
|
<association property="boss" column="boss_id"
|
select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPrimaryKey" />
|
|
<association property="worker" column="worker_id"
|
select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPrimaryKey" />
|
|
<association property="threeSaleExtraInfo" column="tf_id"
|
resultMap="com.yeshi.fanli.dao.mybatis.ThreeSaleExtraInfoMapper.BaseResultMap" />
|
|
</resultMap>
|
|
<sql id="Base_Column_List">id,boss_id,worker_id,state,expire,succeedTime,createTime,updateTime
|
</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 s.state = 1 AND s.worker_id = #{0}
|
LIMIT 1
|
</select>
|
|
|
|
<!-- 根据邀请者ID查询关系 -->
|
<select id="listByWorkerId" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_threeSale s where worker_id = #{0}
|
</select>
|
|
|
<!-- 根据邀请者ID查询关系 -->
|
<select id="getByWorkerId" resultMap="BaseResultMap" parameterType="java.lang.Long">
|
select <include refid="Base_Column_List" /> from yeshi_ec_threeSale
|
where worker_id = #{0} AND state=0 AND (expire = 0 OR expire IS NULL)
|
ORDER BY createTime DESC
|
LIMIT 1
|
</select>
|
|
<select id="selectLatestByWorkerIdAndState" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_threeSale s where worker_id = #{workerId} and state=#{state}
|
</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,succeedTime,createTime,updateTime)
|
values
|
(#{id,jdbcType=BIGINT},#{boss.id,jdbcType=BIGINT},#{worker.id,jdbcType=BIGINT},#{state,jdbcType=BOOLEAN},#{expire,jdbcType=INTEGER},#{succeedTime,jdbcType=BIGINT},#{createTime,jdbcType=BIGINT},#{updateTime,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="succeedTime != null">succeedTime,</if>
|
<if test="createTime != null">createTime,</if>
|
<if test="updateTime != null">updateTime,</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="succeedTime != null">#{succeedTime,jdbcType=BIGINT},</if>
|
<if test="createTime != null">#{createTime,jdbcType=BIGINT},</if>
|
<if test="updateTime != null">#{updateTime,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},
|
succeedTime =
|
#{succeedTime,jdbcType=BIGINT},
|
createTime =
|
#{createTime,jdbcType=BIGINT},
|
updateTime =
|
#{updateTime,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="succeedTime != null">succeedTime=#{succeedTime,jdbcType=BIGINT},</if>
|
<if test="createTime != null">createTime=#{createTime,jdbcType=BIGINT},</if>
|
<if test="updateTime != null">updateTime=#{updateTime,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,
|
t.succeedTime = <![CDATA[UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) * 1000]]>,
|
t.updateTime = <![CDATA[UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) * 1000]]>
|
where t.state=0 and t.worker_id=#{0} AND (t.expire = 0 OR t.expire IS
|
NULL)
|
</update>
|
|
<update id="inviteSeparate">
|
update yeshi_ec_threeSale t set t.state = 0,t.expire = 2,
|
t.updateTime = <![CDATA[UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) * 1000]]>
|
where t.worker_id=#{workerId} AND t.boss_id = #{bossId}
|
</update>
|
|
<delete id="deleteExpireRecord" parameterType="java.lang.Long">
|
DELETE FROM
|
yeshi_ec_threesale
|
WHERE expire = 1 AND boss_id = #{bossId} AND
|
worker_id = #{workerId}
|
</delete>
|
|
<!-- 查询一度队员集合 -->
|
<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 tf.`state` = 1
|
<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 tf.`state` = 1
|
<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, t.updateTime = <![CDATA[UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) * 1000]]>
|
where t.`id` IN
|
<foreach item="item" collection="list" open="(" separator=","
|
close=")">#{item}</foreach>
|
</update>
|
|
<select id="listFirstTeamQuery" resultMap="AllResultMap">
|
SELECT * FROM `yeshi_ec_threesale`
|
WHERE 1=1
|
<if test="uid != null">
|
AND `boss_id` = #{uid}
|
</if>
|
<if test="state == 0">
|
AND `state` = 0 AND (expire = 0 OR expire IS NULL)
|
</if>
|
<if test="state == 1">
|
AND `state` = 1
|
</if>
|
<if test="state ==2">
|
AND `expire` = 1 <!-- 失效 -->
|
</if>
|
<if test="startTime != null and startTime !='' ">
|
<![CDATA[AND FROM_UNIXTIME(createTime/1000) >= #{startTime}]]>
|
</if>
|
<if test="endTime != null and endTime !='' ">
|
<![CDATA[AND FROM_UNIXTIME(createTime/1000) <= #{endTime}]]>
|
</if>
|
ORDER BY createTime DESC
|
LIMIT ${start},${count}
|
</select>
|
|
<select id="countFirstTeamQuery" resultType="java.lang.Long">
|
SELECT count(id) FROM `yeshi_ec_threesale`
|
WHERE 1=1
|
<if test="uid != null">
|
AND `boss_id` = #{uid}
|
</if>
|
<if test="state == 0">
|
AND `state` = 0 AND (expire = 0 OR expire IS NULL)
|
</if>
|
<if test="state == 1">
|
AND `state` = 1
|
</if>
|
<if test="state ==2">
|
AND `expire` = 1 <!-- 失效 -->
|
</if>
|
<if test="startTime != null and startTime !='' ">
|
<![CDATA[AND FROM_UNIXTIME(createTime/1000) >= #{startTime}]]>
|
</if>
|
<if test="endTime != null and endTime !=''">
|
<![CDATA[AND FROM_UNIXTIME(createTime/1000) <= #{endTime}]]>
|
</if>
|
</select>
|
|
|
<select id="listSecondTeamQuery" resultMap="AllResultMap">
|
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 1=1 AND tf.`state` = 1
|
<if test="uid != null">
|
AND tf.`boss_id` = #{uid}
|
</if>
|
<if test="state == 0">
|
AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS
|
NULL)
|
</if>
|
<if test="state == 1">
|
AND ts.`state` = 1
|
</if>
|
<if test="state ==2">
|
AND ts.`expire` = 1 <!-- 失效 -->
|
</if>
|
<if test="startTime != null and startTime !='' ">
|
<![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]>
|
</if>
|
<if test="endTime != null and endTime !=''">
|
<![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) <= #{endTime}]]>
|
</if>
|
|
)A LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
|
ORDER BY
|
yet.`createtime` DESC
|
LIMIT ${start},${count}
|
</select>
|
|
<select id="countSecondTeamQuery" 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 1=1 AND tf.`state` = 1
|
<if test="uid != null">
|
AND tf.`boss_id` = #{uid}
|
</if>
|
<if test="state == 0">
|
AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS
|
NULL)
|
</if>
|
<if test="state == 1">
|
AND ts.`state` = 1
|
</if>
|
<if test="state ==2">
|
AND ts.`expire` = 1 <!-- 失效 -->
|
</if>
|
<if test="startTime != null and startTime !='' ">
|
<![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]>
|
</if>
|
<if test="endTime != null and endTime !=''">
|
<![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) <= #{endTime}]]>
|
</if>
|
)A
|
</select>
|
|
<select id="listSuperiorQuery" resultMap="AllResultMap">
|
SELECT * FROM `yeshi_ec_threesale` ts
|
WHERE ts.`worker_id` = #{uid}
|
<if test="state == 0">
|
AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS
|
NULL)
|
</if>
|
<if test="state == 1">
|
AND ts.`state` = 1
|
</if>
|
<if test="state ==2">
|
AND ts.`expire` = 1 <!-- 失效 -->
|
</if>
|
ORDER BY ts.`createtime` DESC
|
LIMIT ${start},${count}
|
</select>
|
|
<select id="countSuperiorQuery" resultType="java.lang.Long">
|
SELECT COUNT(ts.id) FROM `yeshi_ec_threesale` ts
|
WHERE ts.`worker_id` =
|
#{uid}
|
<if test="state == 0">
|
AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS
|
NULL)
|
</if>
|
<if test="state == 1">
|
AND ts.`state` = 1
|
</if>
|
<if test="state ==2">
|
AND ts.`expire` = 1 <!-- 失效 -->
|
</if>
|
</select>
|
|
|
<select id="listFirstTeam" resultMap="AllResultMap">
|
SELECT * FROM `yeshi_ec_threesale` ts
|
LEFT JOIN `yeshi_ec_threesale_extra_info` ff
|
ON
|
ts.`boss_id` = ff.`tf_boss_id` AND ts.`worker_id`=ff.`tf_worker_id`
|
WHERE ts.`boss_id` = #{uid}
|
<if test="state != null">
|
AND ts.`state` = #{state}
|
</if>
|
ORDER BY ts.state DESC, ts.expire, ts.createTime DESC
|
LIMIT ${start},${count}
|
</select>
|
|
<select id="countFirstTeam" resultType="java.lang.Long">
|
SELECT IFNULL(count(id),0) FROM `yeshi_ec_threesale`
|
WHERE `boss_id` = #{uid}
|
<if test="state != null">
|
AND `state` = #{state}
|
</if>
|
</select>
|
|
|
<select id="listSecondTeam" resultMap="AllResultMap">
|
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 tf.`boss_id` = #{uid} AND tf.`state` = 1)A
|
LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
|
WHERE 1=1
|
<if test="state != null">
|
AND yet.`state` = #{state}
|
</if>
|
ORDER BY
|
yet.state DESC,
|
yet.expire, yet.createTime DESC
|
LIMIT ${start},${count}
|
</select>
|
|
<select id="countSecondTeam" 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 tf.`boss_id` = #{uid} AND tf.`state` = 1
|
<if test="state != null">
|
AND ts.`state` = #{state}
|
</if>
|
)A
|
</select>
|
|
|
<select id="listFirstTeamByUndeleted" resultMap="AllResultMap">
|
SELECT * FROM `yeshi_ec_threesale` ts
|
LEFT JOIN `yeshi_ec_threesale_extra_info` ff ON (ts.`boss_id` = ff.`tf_boss_id` AND ts.`worker_id`=ff.`tf_worker_id`)
|
WHERE ts.`boss_id` = #{uid} AND (ts.`expire` = 0 OR ts.`expire` = 2 OR ts.`expire` = 4)
|
ORDER BY ts.state DESC, ts.createTime DESC
|
LIMIT ${start},${count}
|
</select>
|
|
<select id="countFirstTeamByUndeleted" resultType="java.lang.Long">
|
SELECT IFNULL(count(ts.id),0) FROM `yeshi_ec_threesale` ts
|
WHERE ts.`boss_id` = #{uid} AND (ts.`expire` = 0 OR ts.`expire` = 2 OR ts.`expire` = 4)
|
</select>
|
|
|
<select id="listSecondTeamByUndeleted" resultMap="AllResultMap">
|
SELECT yet.*,stateSuper FROM (
|
SELECT DISTINCT(ts.`id`) AS id, tf.state AS stateSuper FROM `yeshi_ec_threesale` ts
|
LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id`
|
WHERE tf.`boss_id` = #{uid} AND (tf.`expire` = 0 OR tf.`expire` = 2))A
|
LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
|
WHERE yet.`expire` = 0 OR yet.`expire` = 2 OR yet.`expire` = 3
|
ORDER BY yet.state DESC, yet.createTime DESC
|
LIMIT ${start},${count}
|
</select>
|
|
<select id="countSecondTeamByUndeleted" resultType="java.lang.Long">
|
SELECT COUNT(DISTINCT yet.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 tf.`boss_id` = #{uid} AND (tf.`expire` = 0 OR tf.`expire` = 2))A
|
LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
|
WHERE yet.`expire` = 0 OR yet.`expire` = 2 OR yet.`expire` = 3
|
</select>
|
|
|
|
<select id="getMyBoss" resultMap="AllResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_threeSale where
|
state = 1 and worker_id=#{uid}
|
</select>
|
|
|
<select id="listbyIdAndBossId" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List" />
|
FROM yeshi_ec_threeSale
|
WHERE id = #{id} AND boss_id=#{uid}
|
<if test="expire != null and expire == 1">
|
AND `expire` = 1 <!-- 失效 -->
|
</if>
|
</select>
|
|
<select id="getSuccessRelationshipNum" resultType="java.lang.Integer">
|
SELECT IFNULL(COUNT(*),0) FROM `yeshi_ec_threesale` t
|
WHERE t.`state` = 1 AND (t.`worker_id` =${uid} OR t.`boss_id` = ${uid})
|
</select>
|
|
<select id="getRelationshipByBossIdAndWorkerId" resultMap="BaseResultMap">
|
SELECT * FROM `yeshi_ec_threesale` t
|
WHERE t.`boss_id` = ${bossId} AND
|
t.`worker_id` = ${workerId}
|
AND t.`state` = 0 AND (t.`expire` = 0 OR
|
t.`expire`IS NULL)
|
LIMIT 1
|
</select>
|
|
|
<select id="getNearRelationByBossIdAndWorkerId" resultMap="BaseResultMap">
|
SELECT * FROM `yeshi_ec_threesale` t
|
WHERE t.`boss_id` = #{bossId} AND t.`worker_id` = #{workerId}
|
ORDER BY t.`state` DESC, t.`createTime` DESC
|
LIMIT 1
|
</select>
|
|
<select id="getExpireRecord" resultMap="BaseResultMap">
|
SELECT * FROM
|
`yeshi_ec_threesale`
|
WHERE expire = 1 AND boss_id = #{bossId} AND
|
worker_id = #{workerId}
|
</select>
|
|
<select id="selectSuccessByWorkerId" resultMap="BaseResultMap" parameterType="java.lang.Long">
|
SELECT * FROM `yeshi_ec_threesale`
|
WHERE `state` = 1 AND worker_id = #{0} order by id desc
|
</select>
|
|
<select id="getSuccessByDate" resultMap="AllResultMap" >
|
SELECT * FROM yeshi_ec_threesale t
|
WHERE t.`boss_id` = #{bossId} AND t.`state` = 1
|
AND <![CDATA[t.createTime >= #{minTime} AND t.createTime <= #{maxTime}]]>
|
</select>
|
|
<select id="getByWorkerIdAndTime" resultMap="BaseResultMap">
|
SELECT * FROM yeshi_ec_threesale t
|
WHERE t.`worker_id` = #{workerId} AND t.`state` = 1
|
<![CDATA[AND t.succeedTime >= #{time}]]>
|
</select>
|
|
<select id="getTeamOrderNumByWorkerId" resultType="Long">
|
SELECT IFNULL(COUNT(d.`id`),0) FROM yeshi_ec_threesale d
|
LEFT JOIN (SELECT t.`id`,t.`boss_id` FROM `yeshi_ec_threesale` t
|
WHERE t.`state` = 1 AND t.`worker_id` = #{workerId} LIMIT 1)t ON t.`boss_id` = d.`boss_id`
|
WHERE d.`id` <![CDATA[<=]]>t.id AND d.`state` = 1
|
</select>
|
|
|
<select id="getValidWorkerIdsByTime" resultMap="BaseResultMap">
|
SELECT * FROM `yeshi_ec_threesale` tr
|
WHERE tr.`state` = 1 AND tr.`boss_id` = #{uid} AND tr.`succeedTime` <![CDATA[>=]]> #{limitTime}
|
</select>
|
|
</mapper>
|