yujian
2020-04-21 5af10f175689549ca44b74e9fc1c7ee0ec92c2d7
fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml
@@ -10,6 +10,8 @@
      <result column="updateTime" property="updateTime" jdbcType="BIGINT" />
      <result column="expire" property="expire" jdbcType="INTEGER" />
      
      <result column="validState" property="validState" jdbcType="INTEGER" />
      <association property="boss" column="boss_id"
         javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
         <id column="boss_id" property="id" jdbcType="BIGINT" />
@@ -175,174 +177,116 @@
      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="listFirstTeamQuery" resultMap="AllResultMap">
      SELECT * FROM `yeshi_ec_threesale`
   <select id="listFirstTeamQuery" resultMap="BaseResultMap">
      SELECT t.*,d.`tvr_type` AS validState  FROM `yeshi_ec_threesale` t
      LEFT JOIN `yeshi_ec_user_invite_valid_record` d ON (d.`tvr_uid` = t.`boss_id` AND d.`tvr_worker_id` = t.`worker_id`)
      WHERE 1=1
      <if test="uid != null">
         AND `boss_id` = #{uid}
         AND  t.`boss_id` = #{uid}
      </if>
      <if test="state == 0">
         AND `state` = 0 AND (expire = 0 OR expire IS NULL)
      <if test="state != null">
         AND t.`state` =  #{state}
      </if>
      <if test="state == 1">
         AND `state` = 1
      <if test="validState == 1">
         AND d.`tvr_type` = 1
      </if>
      <if test="state ==2">
         AND `expire` = 1  <!-- 失效 -->
      <if test="validState == 0">
         AND d.`tvr_type` is null
      </if>
      <if test="startTime != null and startTime !='' ">
              <![CDATA[AND FROM_UNIXTIME(createTime/1000) >= #{startTime}]]>
          <![CDATA[AND FROM_UNIXTIME(t.createTime/1000) >= #{startTime}]]>
      </if>
      <if test="endTime != null and  endTime !='' ">
              <![CDATA[AND FROM_UNIXTIME(createTime/1000) <= #{endTime}]]>
           <![CDATA[AND FROM_UNIXTIME(t.createTime/1000) <= #{endTime}]]>
      </if>
      ORDER BY createTime DESC
      ORDER BY  t.createTime DESC
      LIMIT ${start},${count}
   </select>
   <select id="countFirstTeamQuery" resultType="java.lang.Long">
      SELECT count(id) FROM `yeshi_ec_threesale`
      SELECT count(t.id) FROM `yeshi_ec_threesale` t
      LEFT JOIN `yeshi_ec_user_invite_valid_record` d ON (d.`tvr_uid` = t.`boss_id` AND d.`tvr_worker_id` = t.`worker_id`)
      WHERE 1=1
      <if test="uid != null">
         AND `boss_id` = #{uid}
         AND  t.`boss_id` = #{uid}
      </if>
      <if test="state == 0">
         AND `state` = 0 AND (expire = 0 OR expire IS NULL)
      <if test="state != null">
         AND t.`state` =  #{state}
      </if>
      <if test="state == 1">
         AND `state` = 1
      <if test="validState == 1">
         AND d.`tvr_type` = 1
      </if>
      <if test="state ==2">
         AND `expire` = 1  <!-- 失效 -->
      <if test="validState == 0">
         AND d.`tvr_type` is null
      </if>
      <if test="startTime != null and startTime !='' ">
              <![CDATA[AND FROM_UNIXTIME(createTime/1000) >= #{startTime}]]>
          <![CDATA[AND FROM_UNIXTIME(t.createTime/1000) >= #{startTime}]]>
      </if>
      <if test="endTime != null and  endTime !=''">
              <![CDATA[AND FROM_UNIXTIME(createTime/1000) <= #{endTime}]]>
      <if test="endTime != null and  endTime !='' ">
           <![CDATA[AND FROM_UNIXTIME(t.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
   <select id="listSecondTeamQuery" resultMap="BaseResultMap">
      SELECT yet.*,d.`tvr_type` AS validState  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 test="state != null">
         AND ts.`state` =  #{state}
      </if>
      <if test="startTime != null and startTime !='' ">
                 <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]>
           <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]>
      </if>
      <if test="endTime != null and  endTime !=''">
                 <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) <= #{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
      LEFT JOIN `yeshi_ec_user_invite_valid_record` d ON (d.`tvr_uid` = yet.`boss_id` AND d.`tvr_worker_id` = yet.`worker_id`)
      where 1=1
      <if test="validState == 1">
         AND d.`tvr_type` = 1
      </if>
      <if test="validState == 0">
         AND d.`tvr_type` is null
      </if>
      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
      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 test="state != null">
         AND ts.`state` =  #{state}
      </if>
      <if test="startTime != null and startTime !='' ">
                 <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]>
          <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]>
      </if>
      <if test="endTime != null and endTime !=''">
                 <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) <= #{endTime}]]>
          <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) <= #{endTime}]]>
      </if>
      )A
      LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
      LEFT JOIN `yeshi_ec_user_invite_valid_record` d ON (d.`tvr_uid` = yet.`boss_id` AND d.`tvr_worker_id` = yet.`worker_id`)
      where 1=1
      <if test="validState == 0">
         AND d.`tvr_type` is null
      </if>
      <if test="validState == 1">
         AND d.`tvr_type` = 1
      </if>
   </select>
   <select id="listSuperiorQuery" resultMap="AllResultMap">
   <select id="listSuperiorQuery" resultMap="BaseResultMap">
      SELECT * FROM `yeshi_ec_threesale` ts
      WHERE ts.`worker_id` = #{uid}
      <if test="state == 0">