yujian
2019-12-26 012232edc4dac15517c69c2af3934f901e818b7c
fanli/src/main/java/com/yeshi/fanli/mapping/tlj/UserTaoLiJinNewbiesMapper.xml
@@ -10,6 +10,20 @@
    <result column="wnu_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="wnu_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <resultMap id="ResultMap" type="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinNewbies">
    <id column="wnu_id" property="id" jdbcType="BIGINT"/>
    <result column="wnu_money" property="money" jdbcType="DECIMAL"/>
    <result column="wnu_num" property="num" jdbcType="INTEGER"/>
    <result column="wnu_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="wnu_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="wnu_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <result column="win" property="win" jdbcType="DECIMAL"/>
    <result column="reduce" property="reduce" jdbcType="DECIMAL"/>
    <result column="state" property="state" jdbcType="INTEGER"/>
  </resultMap>
  <sql id="Base_Column_List">wnu_id,wnu_money,wnu_num,wnu_end_time,wnu_create_time,wnu_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_user_taolijin_new_user where wnu_id = #{id,jdbcType=BIGINT}
@@ -66,4 +80,19 @@
      WHERE wnu_id = #{id,jdbcType=BIGINT} FOR UPDATE
  </select>
  
  <select id="query" resultMap="ResultMap">
     SELECT d.*,SUM(IF(t.`utd_money` <![CDATA[<]]>  0,t.`utd_money`,0)) AS reduce,SUM(IF(t.`utd_money`>0,t.`utd_money`,0)) AS win, IF(d.`wnu_end_time` <![CDATA[<]]> NOW(),1,0)AS state
     FROM yeshi_ec_user_taolijin_new_user d
   LEFT JOIN `yeshi_ec_user_taolijin_detail` t ON t.`utd_uid` = d.`wnu_id`
   WHERE t.`utd_create_time` > '2019-12-14'  <if test="key != null and key !=''"> AND d.`wnu_id` LIKE '%${key}%'</if>
   GROUP BY d.`wnu_id`
   <if test="order == 1">ORDER BY d.`wnu_create_time`</if>
   <if test="order == 2">ORDER BY d.`wnu_create_time` DESC</if>
   LIMIT #{start},#{count}
  </select>
  <select id="count" resultType="Long">
     SELECT IFNULL(COUNT(d.`wnu_id`),0) FROM yeshi_ec_user_taolijin_new_user d
   WHERE  1=1  <if test="key != null and key !=''"> AND d.`wnu_id` LIKE '%${key}%'</if>
  </select>
</mapper>