admin
2020-05-20 98b1a0affd69bbe63223c21fdd2c404e8bedfccb
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
<?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.RedPackGiveRecordMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackGiveRecord">
    <id column="rpgr_id" property="id" jdbcType="BIGINT"/>
    <result column="rpgr_money" property="amount" jdbcType="DECIMAL"/>
    <result column="rpgr_give_uid" property="giveUid" jdbcType="BIGINT"/>
    <result column="rpgr_give_time" property="giveTime" jdbcType="TIMESTAMP"/>
    <result column="rpgr_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="rpgr_receive_uid" property="receiveUid" jdbcType="BIGINT"/>
    <result column="rpgr_receive_time" property="receiveTime" jdbcType="TIMESTAMP"/>
    <result column="rpgr_state" property="state" jdbcType="INTEGER"/>
  </resultMap>
  
  <resultMap id="VOResultMap" type="com.yeshi.fanli.vo.redpack.RedPackGiveVO">
    <id column="rpgr_id" property="id" jdbcType="BIGINT"/>
    <result column="rpgr_money" property="amount" jdbcType="DECIMAL"/>
    <result column="rpgr_give_uid" property="giveUid" jdbcType="BIGINT"/>
    <result column="rpgr_give_time" property="giveTime" jdbcType="TIMESTAMP"/>
    <result column="rpgr_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="rpgr_receive_uid" property="receiveUid" jdbcType="BIGINT"/>
    <result column="rpgr_receive_time" property="receiveTime" jdbcType="TIMESTAMP"/>
    <result column="rpgr_state" property="state" jdbcType="INTEGER"/>
  </resultMap>
  
  
  <sql id="Base_Column_List">rpgr_id,rpgr_money,rpgr_give_uid,rpgr_give_time,rpgr_end_time,rpgr_receive_uid,rpgr_receive_time,rpgr_state</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_red_pack_give_record where rpgr_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_red_pack_give_record where rpgr_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_give_record (rpgr_id,rpgr_money,rpgr_give_uid,rpgr_give_time,rpgr_end_time,rpgr_receive_uid,rpgr_receive_time,rpgr_state) values (#{id,jdbcType=BIGINT},#{amount,jdbcType=DECIMAL},#{giveUid,jdbcType=BIGINT},#{giveTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{receiveUid,jdbcType=BIGINT},#{receiveTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_give_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpgr_id,</if>
      <if test="amount != null">rpgr_money,</if>
      <if test="giveUid != null">rpgr_give_uid,</if>
      <if test="giveTime != null">rpgr_give_time,</if>
      <if test="endTime != null">rpgr_end_time,</if>
      <if test="receiveUid != null">rpgr_receive_uid,</if>
      <if test="receiveTime != null">rpgr_receive_time,</if>
      <if test="state != null">rpgr_state,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="amount != null">#{amount,jdbcType=DECIMAL},</if>
      <if test="giveUid != null">#{giveUid,jdbcType=BIGINT},</if>
      <if test="giveTime != null">#{giveTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="receiveUid != null">#{receiveUid,jdbcType=BIGINT},</if>
      <if test="receiveTime != null">#{receiveTime,jdbcType=TIMESTAMP},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord">update yeshi_ec_red_pack_give_record set rpgr_money = #{amount,jdbcType=DECIMAL},rpgr_give_uid = #{giveUid,jdbcType=BIGINT},rpgr_give_time = #{giveTime,jdbcType=TIMESTAMP},rpgr_end_time = #{endTime,jdbcType=TIMESTAMP},rpgr_receive_uid = #{receiveUid,jdbcType=BIGINT},rpgr_receive_time = #{receiveTime,jdbcType=TIMESTAMP},rpgr_state = #{state,jdbcType=INTEGER} where rpgr_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord">update yeshi_ec_red_pack_give_record
    <set>
      <if test="amount != null">rpgr_money=#{amount,jdbcType=DECIMAL},</if>
      <if test="giveUid != null">rpgr_give_uid=#{giveUid,jdbcType=BIGINT},</if>
      <if test="giveTime != null">rpgr_give_time=#{giveTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">rpgr_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="receiveUid != null">rpgr_receive_uid=#{receiveUid,jdbcType=BIGINT},</if>
      <if test="receiveTime != null">rpgr_receive_time=#{receiveTime,jdbcType=TIMESTAMP},</if>
      <if test="state != null">rpgr_state=#{state,jdbcType=INTEGER},</if>
    </set> where rpgr_id = #{id,jdbcType=BIGINT}
  </update>
  
  <select id="overdueList" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_red_pack_give_record
    WHERE rpgr_state = 0 AND rpgr_end_time IS NOT NULL AND rpgr_end_time <![CDATA[<]]> NOW()
    LIMIT #{count}
  </select>
  
   <select id="getGiveList" resultMap="VOResultMap">
      SELECT * FROM yeshi_ec_red_pack_give_record
    WHERE rpgr_give_uid = #{uid}
    ORDER BY rpgr_id DESC
    LIMIT #{start},#{count}
  </select>
  
  <select id="countGiveList" resultType="Long">
      SELECT IFNULL(COUNT(rpgr_id),0) FROM yeshi_ec_red_pack_give_record
    WHERE rpgr_give_uid = #{uid}
  </select>
</mapper>