admin
2019-03-05 e92ce10abd2c9e66c8f84b2d2d534bf48c09688e
fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml
@@ -13,7 +13,9 @@
      <result column="expire" property="expire" jdbcType="INTEGER" />
      <association property="boss" column="boss_id"
         resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap" />
         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">
@@ -119,9 +121,12 @@
      = #{worker.id,jdbcType=BIGINT},state =
      #{state,jdbcType=BOOLEAN},
      expire = #{expire,jdbcType=INTEGER},
      succeedTime = #{succeedTime,jdbcType=BIGINT},
      createTime = #{createTime,jdbcType=BIGINT},
      updateTime = #{updateTime,jdbcType=BIGINT}
      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">
@@ -148,14 +153,16 @@
   </update>
   
   <delete id="deleteExpireRecord" parameterType="java.lang.Long">
      DELETE FROM yeshi_ec_threesale
      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
      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}%'
@@ -165,8 +172,10 @@
   <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)
      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>
@@ -178,22 +187,28 @@
      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
      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}
      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
      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}%'
@@ -204,7 +219,8 @@
   <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)
      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>
@@ -212,7 +228,8 @@
   <select id="queryLongTimeSuccess" resultMap="BaseResultMap">
      <!-- 长时间未邀请成功 -->
      SELECT * FROM `yeshi_ec_threesale` h
      WHERE h.`state` = 1 AND (h.expire = 0 OR h.expire IS NULL)
      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>
@@ -279,13 +296,15 @@
      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`
      LEFT JOIN yeshi_ec_threesale tf ON
      ts.`boss_id`=tf.`worker_id`
      WHERE 1=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)
         AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS
         NULL)
      </if>
      <if test="state == 1">
         AND ts.`state` = 1
@@ -301,20 +320,24 @@
      </if>
      )A LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
      ORDER BY yet.`createtime` DESC
      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`
      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
      <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)
         AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS
         NULL)
      </if>
      <if test="state == 1">
         AND ts.`state` = 1
@@ -335,7 +358,8 @@
      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)
         AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS
         NULL)
      </if>
      <if test="state == 1">
         AND ts.`state` = 1
@@ -349,9 +373,11 @@
   <select id="countSuperiorQuery" resultType="java.lang.Long">
      SELECT COUNT(ts.id) FROM `yeshi_ec_threesale` ts
      WHERE ts.`worker_id` = #{uid}
      WHERE ts.`worker_id` =
      #{uid}
      <if test="state == 0">
         AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS NULL)
         AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS
         NULL)
      </if>
      <if test="state == 1">
         AND ts.`state` = 1
@@ -363,17 +389,20 @@
   <select id="listFirstTeam" resultMap="AllResultMap">
      SELECT * FROM `yeshi_ec_threesale` ts
      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}
      ORDER BY ts.state DESC, ts.expire, ts.createTime DESC
      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}
      WHERE `boss_id` =
      #{uid}
      <if test="state != null">
         AND `state` = #{state}
      </if>
@@ -385,17 +414,22 @@
         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})A
      LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
      LEFT JOIN yeshi_ec_threesale yet ON yet.id =
      A.id
      LEFT JOIN `yeshi_ec_threesale_extra_info` ff
      ON yet.`boss_id` = ff.`tf_boss_id` AND yet.`worker_id` =ff.`tf_worker_id`
      ORDER BY yet.state DESC, yet.expire, yet.createTime DESC
      ON yet.`boss_id` =
      ff.`tf_boss_id` AND yet.`worker_id` =ff.`tf_worker_id`
      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`
      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}
      <if test="state != null">
         AND ts.`state` = #{state}