admin
2020-04-13 dd5b15229cb15459fa7c31ccea77dac28cbfafbd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?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.tlj.UserTaoLiJinNewbiesMapper">
  <resultMap id="BaseResultMap" 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"/>
  </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}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_user_taolijin_new_user where wnu_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinNewbies" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_taolijin_new_user (wnu_id,wnu_money,wnu_num,wnu_end_time,wnu_create_time,wnu_update_time) values (#{id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{num,jdbcType=INTEGER},#{endTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinNewbies" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_taolijin_new_user
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">wnu_id,</if>
      <if test="money != null">wnu_money,</if>
      <if test="num != null">wnu_num,</if>
      <if test="endTime != null">wnu_end_time,</if>
      <if test="createTime != null">wnu_create_time,</if>
      <if test="updateTime != null">wnu_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="money != null">#{money,jdbcType=DECIMAL},</if>
      <if test="num != null">#{num,jdbcType=INTEGER},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinNewbies">update yeshi_ec_user_taolijin_new_user set wnu_money = #{money,jdbcType=DECIMAL},wnu_num = #{num,jdbcType=INTEGER},wnu_end_time = #{endTime,jdbcType=TIMESTAMP},wnu_create_time = #{createTime,jdbcType=TIMESTAMP},wnu_update_time = #{updateTime,jdbcType=TIMESTAMP} where wnu_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinNewbies">update yeshi_ec_user_taolijin_new_user
    <set>
      <if test="money != null">wnu_money=#{money,jdbcType=DECIMAL},</if>
      <if test="num != null">wnu_num=#{num,jdbcType=INTEGER},</if>
      <if test="endTime != null">wnu_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">wnu_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">wnu_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where wnu_id = #{id,jdbcType=BIGINT}
  </update>
  
  
   <update id="subMoney">
      update yeshi_ec_user_taolijin_new_user SET wnu_money = wnu_money - #{money,jdbcType=DECIMAL},wnu_update_time = NOW()
      WHERE wnu_id = #{id,jdbcType=BIGINT}
  </update>
    
  <update id="addMoney">
      UPDATE yeshi_ec_user_taolijin_new_user SET wnu_money = wnu_money + #{money,jdbcType=DECIMAL}, wnu_num = wnu_num + 1,wnu_update_time = NOW()
      WHERE wnu_id = #{id,jdbcType=BIGINT}
  </update>
    
  <update id="resetMoney">
      UPDATE yeshi_ec_user_taolijin_new_user SET wnu_money = 0,wnu_update_time = NOW()
      WHERE wnu_id = #{id,jdbcType=BIGINT}
  </update>
  
  <select id="selectForUpdate" 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} 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>