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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?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.UserTaoLiJinOriginMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin">
    <id column="uto_id" property="id" jdbcType="BIGINT"/>
    <result column="uto_uid" property="uid" jdbcType="BIGINT"/>
    <result column="uto_rights_id" property="rightsId" jdbcType="VARCHAR"/>
    <result column="uto_money" property="money" jdbcType="DECIMAL"/>
    <result column="uto_money_surplus" property="moneySurplus" jdbcType="DECIMAL"/>
    <result column="uto_type" property="type" jdbcType="INTEGER"/>
    <result column="uto_origin" property="origin" typeHandler="com.yeshi.fanli.util.mybatishandler.tlj.TaoLiJinOriginEnumHandler"/>
    <result column="uto_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="uto_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="uto_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">uto_id,uto_uid,uto_rights_id,uto_money,uto_money_surplus,uto_type,uto_origin,uto_remark,uto_create_time,uto_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_user_taolijin_origin where uto_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_user_taolijin_origin where uto_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_taolijin_origin (uto_id,uto_uid,uto_rights_id,uto_money,uto_money_surplus,uto_type,uto_origin,uto_remark,uto_create_time,uto_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{rightsId,jdbcType=VARCHAR},#{money,jdbcType=DECIMAL},#{moneySurplus,jdbcType=DECIMAL},#{type,jdbcType=INTEGER},#{origin,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_taolijin_origin
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">uto_id,</if>
      <if test="uid != null">uto_uid,</if>
      <if test="rightsId != null">uto_rights_id,</if>
      <if test="money != null">uto_money,</if>
      <if test="moneySurplus != null">uto_money_surplus,</if>
      <if test="type != null">uto_type,</if>
      <if test="origin != null">uto_origin,</if>
      <if test="remark != null">uto_remark,</if>
      <if test="createTime != null">uto_create_time,</if>
      <if test="updateTime != null">uto_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
      <if test="rightsId != null">#{rightsId,jdbcType=VARCHAR},</if>
      <if test="money != null">#{money,jdbcType=DECIMAL},</if>
      <if test="moneySurplus != null">#{moneySurplus,jdbcType=DECIMAL},</if>
      <if test="type != null">#{type,jdbcType=INTEGER},</if>
      <if test="origin != null">#{origin,jdbcType=VARCHAR},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</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.UserTaoLiJinOrigin">update yeshi_ec_user_taolijin_origin set uto_uid = #{uid,jdbcType=BIGINT},uto_rights_id = #{rightsId,jdbcType=VARCHAR},uto_money = #{money,jdbcType=DECIMAL},uto_money_surplus = #{moneySurplus,jdbcType=DECIMAL},uto_type = #{type,jdbcType=INTEGER},uto_origin = #{origin,jdbcType=VARCHAR},uto_remark = #{remark,jdbcType=VARCHAR},uto_create_time = #{createTime,jdbcType=TIMESTAMP},uto_update_time = #{updateTime,jdbcType=TIMESTAMP} where uto_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin">update yeshi_ec_user_taolijin_origin
    <set>
      <if test="uid != null">uto_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="rightsId != null">uto_rights_id=#{rightsId,jdbcType=VARCHAR},</if>
      <if test="money != null">uto_money=#{money,jdbcType=DECIMAL},</if>
      <if test="moneySurplus != null">uto_money_surplus=#{moneySurplus,jdbcType=DECIMAL},</if>
      <if test="type != null">uto_type=#{type,jdbcType=INTEGER},</if>
      <if test="origin != null">uto_origin=#{origin,jdbcType=VARCHAR},</if>
      <if test="remark != null">uto_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="createTime != null">uto_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">uto_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where uto_id = #{id,jdbcType=BIGINT}
  </update>
  
  <select id="countMoneyByDate" resultType="java.math.BigDecimal">
      SELECT IFNULL(SUM(t.`uto_money`),0) FROM `yeshi_ec_user_taolijin_origin` t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` <![CDATA[<>]]>'refund' AND t.`uto_origin` <![CDATA[<>]]>'giveSendBack'
        <if test="dateType == 1"> <!-- 今日  -->
            AND TO_DAYS(t.`uto_create_time`) =  TO_DAYS(NOW());
        </if>
        <if test="dateType == 2"> <!-- 昨日  -->
          AND TO_DAYS(NOW()) - TO_DAYS(t.`uto_create_time`) = 1
        </if>
           <if test="dateType == 3"> <!-- 本月  -->
          AND DATE_FORMAT(t.`uto_create_time`, '%Y%m') =DATE_FORMAT(CURDATE(), '%Y%m')
        </if>
        <if test="dateType == 4"> <!--上月  -->
          AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),DATE_FORMAT(t.`uto_create_time`, '%Y%m')) = 1
        </if>
  </select>
  
  <select id="countByUidAndOrigin" resultType="Long">
     SELECT IFNULL(COUNT(t.`uto_id`),0) FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = #{origin}
  </select>
  
   <select id="getByUidAndOrigin" resultMap="BaseResultMap">
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = #{origin}
    LIMIT 1
  </select>
  
  <select id="countRankByThisMonth" resultType="Long">
     SELECT IFNULL(COUNT(t.`uto_id`),0) FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = 'rankWin'
          AND DATE_FORMAT(t.`uto_create_time`, '%Y%m') =DATE_FORMAT(CURDATE(), '%Y%m')
  </select>
  
   <select id="getRankByThisMonth" resultMap="BaseResultMap">
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = #{type}
          AND DATE_FORMAT(t.`uto_create_time`, '%Y%m') =DATE_FORMAT(CURDATE(), '%Y%m')
    LIMIT 1
  </select>
  
  <select id="getOverdueTaoLiJin" resultMap="BaseResultMap" >
     SELECT * FROM yeshi_ec_user_taolijin_origin t 
    WHERE t.`uto_uid` = #{uid} AND t.`uto_create_time`<![CDATA[<=]]> #{date}
          AND t.`uto_money_surplus`<![CDATA[>]]> 0 AND t.`uto_origin`<![CDATA[<>]]>'rankWin'
  </select>
  
  <select id="getOverdueTaoLiJinByRank" resultMap="BaseResultMap" >
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_create_time`<![CDATA[<=]]> #{date}
          AND t.`uto_money_surplus`<![CDATA[>]]> 0 AND t.`uto_origin`= 'rankWin'
  </select>
  
  <select id="getSurplusLiJin" resultMap="BaseResultMap" >
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_money_surplus`<![CDATA[>]]> 0
    ORDER BY t.`uto_create_time`
  </select>
  
  <select id="countByUidAndType" resultType="Long">
     SELECT IFNULL(COUNT(t.`uto_id`),0) FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = #{type}
  </select>
  
  <select id="countMoneyByOrigin" resultType="java.math.BigDecimal">
     SELECT IFNULL(SUM(t.`uto_money`),0) FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_rights_id` = #{rightsId}  AND t.`uto_origin` = #{origin}
  </select>
  
  <select id="getOriginByRightsId" resultMap="BaseResultMap" >
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_rights_id` = #{rightsId}
    LIMIT 1
  </select>
  
</mapper>