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
<?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.RedPackForbidRecordMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackForbidRecord">
    <id column="rpv_id" property="id" jdbcType="BIGINT"/>
    <result column="rpv_uid" property="uid" jdbcType="BIGINT"/>
    <result column="rpv_money" property="money" jdbcType="DECIMAL"/>
    <result column="rpv_date_type" property="type" jdbcType="INTEGER"/>
    <result column="rpv_reason" property="reason" jdbcType="VARCHAR"/>
    <result column="rpv_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="rpv_admin_id" property="adminId" jdbcType="BIGINT"/>
    <result column="rpv_create_time" property="createTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">rpv_id,rpv_uid,rpv_money,rpv_date_type,rpv_reason,rpv_end_time,rpv_admin_id,rpv_create_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_red_pack_forbid_record where rpv_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_red_pack_forbid_record where rpv_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackForbidRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_forbid_record (rpv_id,rpv_uid,rpv_money,rpv_date_type,rpv_reason,rpv_end_time,rpv_admin_id,rpv_create_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=INTEGER},#{reason,jdbcType=VARCHAR},#{endTime,jdbcType=TIMESTAMP},#{adminId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackForbidRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_forbid_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpv_id,</if>
      <if test="uid != null">rpv_uid,</if>
      <if test="money != null">rpv_money,</if>
      <if test="type != null">rpv_date_type,</if>
      <if test="reason != null">rpv_reason,</if>
      <if test="endTime != null">rpv_end_time,</if>
      <if test="adminId != null">rpv_admin_id,</if>
      <if test="createTime != null">rpv_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="type != null">#{type,jdbcType=INTEGER},</if>
      <if test="reason != null">#{reason,jdbcType=VARCHAR},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="adminId != null">#{adminId,jdbcType=BIGINT},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackForbidRecord">update yeshi_ec_red_pack_forbid_record set rpv_uid = #{uid,jdbcType=BIGINT},rpv_money = #{money,jdbcType=DECIMAL},rpv_date_type = #{type,jdbcType=INTEGER},rpv_reason = #{reason,jdbcType=VARCHAR},rpv_end_time = #{endTime,jdbcType=TIMESTAMP},rpv_admin_id = #{adminId,jdbcType=BIGINT},rpv_create_time = #{createTime,jdbcType=TIMESTAMP} where rpv_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackForbidRecord">update yeshi_ec_red_pack_forbid_record
    <set>
      <if test="uid != null">rpv_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="money != null">rpv_money=#{money,jdbcType=DECIMAL},</if>
      <if test="type != null">rpv_date_type=#{type,jdbcType=INTEGER},</if>
      <if test="reason != null">rpv_reason=#{reason,jdbcType=VARCHAR},</if>
      <if test="endTime != null">rpv_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="adminId != null">rpv_admin_id=#{adminId,jdbcType=BIGINT},</if>
      <if test="createTime != null">rpv_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
    </set> where rpv_id = #{id,jdbcType=BIGINT}
  </update>
  
  <select id="query" resultMap="BaseResultMap">
    SELECT * FROM `yeshi_ec_red_pack_forbid_record` t
    WHERE t.`rpv_uid` LIKE '${key}%' 
    ORDER BY t.`rpv_create_time` DESC
    LIMIT #{start},#{count}
  </select>
  
  <select id="count" resultType="Long">
      SELECT IFNULL(COUNT(t.rpv_id),0) FROM yeshi_ec_red_pack_forbid_record t
    WHERE  t.`rpv_uid` LIKE '${key}%'
  </select>
  
  <select id="queryForbid" resultMap="BaseResultMap">
    SELECT * FROM `yeshi_ec_red_pack_forbid` d       
    LEFT JOIN yeshi_ec_red_pack_forbid_record t1 ON t1.rpv_uid = d.`rpf_uid`
    WHERE d.`rpf_uid` LIKE '${key}%' 
          AND t1.rpv_create_time IN(SELECT MAX(t2.rpv_create_time) FROM yeshi_ec_red_pack_forbid_record t2 WHERE t1.rpv_uid=t2.rpv_uid)
    ORDER BY d.`rpf_create_time` DESC
    LIMIT #{start},#{count}
  </select>
  
  <select id="countForbid" resultType="Long">
      SELECT IFNULL(COUNT(t.rpf_uid),0) FROM yeshi_ec_red_pack_forbid t
    WHERE  t.`rpf_uid` LIKE '${key}%'
  </select>
</mapper>