admin
2020-05-06 24a8d17e007545f7426c48352109aa1a9c6587ee
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
<?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.redpack.RedPackExchangeMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackExchange">
    <id column="rpe_id" property="id" jdbcType="BIGINT"/>
    <result column="rpe_uid" property="uid" jdbcType="BIGINT"/>
    <result column="rpe_money" property="money" jdbcType="DECIMAL"/>
    <result column="rpe_state" property="state" jdbcType="INTEGER"/>
    <result column="rpe_audit_id" property="auditId" jdbcType="BIGINT"/>
    <result column="rpe_reason" property="reason" jdbcType="VARCHAR"/>
    <result column="rpe_audit_time" property="auditTime" jdbcType="TIMESTAMP"/>
    <result column="rpe_create_time" property="createTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">rpe_id,rpe_uid,rpe_money,rpe_state,rpe_audit_id,rpe_reason,rpe_audit_time,rpe_create_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_red_pack_exchange where rpe_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_red_pack_exchange where rpe_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_exchange (rpe_id,rpe_uid,rpe_money,rpe_state,rpe_audit_id,rpe_reason,rpe_audit_time,rpe_create_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{state,jdbcType=INTEGER},#{auditId,jdbcType=BIGINT},#{reason,jdbcType=VARCHAR},#{auditTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_exchange
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpe_id,</if>
      <if test="uid != null">rpe_uid,</if>
      <if test="money != null">rpe_money,</if>
      <if test="state != null">rpe_state,</if>
      <if test="auditId != null">rpe_audit_id,</if>
      <if test="reason != null">rpe_reason,</if>
      <if test="auditTime != null">rpe_audit_time,</if>
      <if test="createTime != null">rpe_create_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="money != null">#{money,jdbcType=DECIMAL},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="auditId != null">#{auditId,jdbcType=BIGINT},</if>
      <if test="reason != null">#{reason,jdbcType=VARCHAR},</if>
      <if test="auditTime != null">#{auditTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange">update yeshi_ec_red_pack_exchange set rpe_uid = #{uid,jdbcType=BIGINT},rpe_money = #{money,jdbcType=DECIMAL},rpe_state = #{state,jdbcType=INTEGER},rpe_audit_id = #{auditId,jdbcType=BIGINT},rpe_reason = #{reason,jdbcType=VARCHAR},rpe_audit_time = #{auditTime,jdbcType=TIMESTAMP},rpe_create_time = #{createTime,jdbcType=TIMESTAMP} where rpe_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange">update yeshi_ec_red_pack_exchange
    <set>
      <if test="uid != null">rpe_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="money != null">rpe_money=#{money,jdbcType=DECIMAL},</if>
      <if test="state != null">rpe_state=#{state,jdbcType=INTEGER},</if>
      <if test="auditId != null">rpe_audit_id=#{auditId,jdbcType=BIGINT},</if>
      <if test="reason != null">rpe_reason=#{reason,jdbcType=VARCHAR},</if>
      <if test="auditTime != null">rpe_audit_time=#{auditTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">rpe_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
    </set> where rpe_id = #{id,jdbcType=BIGINT}
  </update>
  
  <select id="query" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_red_pack_exchange d
    WHERE 1=1 
        <if test="key != null and key != ''">
            AND d.rpe_uid = #{key}
        </if>
         <if test="state != null ">
            AND d.rpe_state = #{state}
        </if>
    ORDER BY  d.`rpe_state`,d.`rpe_create_time` DESC
    LIMIT #{start},#{count}
  </select>
  
  <select id="count" resultType="Long">
      SELECT IFNULL(COUNT(rpe_id),0) FROM yeshi_ec_red_pack_exchange d
    WHERE 1=1 
        <if test="key != null and key != ''">
            AND d.rpe_uid = #{key}
        </if>
         <if test="state != null ">
            AND d.rpe_state = #{state}
        </if>
  </select>
  
  <select id="countByUidAndState" resultType="Long">
    SELECT IFNULL(COUNT(d.rpe_id),0) FROM yeshi_ec_red_pack_exchange d
    WHERE d.rpe_uid = #{uid} AND d.`rpe_state` = #{state}
  </select>
  
  <select id="countMoneyByUidAndState" resultType="BigDecimal">
      SELECT IFNULL(SUM(d.rpe_money),0) FROM yeshi_ec_red_pack_exchange d
    WHERE d.rpe_uid = #{uid} AND d.`rpe_state` = #{state}
  </select>
  
  <select id="countTodayByUid" resultType="Long">
      SELECT IFNULL(COUNT(d.rpe_id),0) FROM yeshi_ec_red_pack_exchange d
    WHERE d.rpe_uid = #{uid} AND TO_DAYS(d.`rpe_create_time`) = TO_DAYS(NOW())
  </select>
</mapper>