admin
2020-05-19 744594ef1a2f530fc3e86ea9dc48b62247f79420
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
<?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.SystemCouponMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.system.SystemCoupon">
    <id column="sc_id" property="id" jdbcType="BIGINT"/>
    <result column="sc_name" property="name" jdbcType="VARCHAR"/>
    <result column="sc_picture" property="picture" jdbcType="VARCHAR"/>
    <result column="sc_picture_invalid" property="pictureInvalid" jdbcType="VARCHAR"/>
    <result column="sc_effect" property="effect" jdbcType="VARCHAR"/>
    
    <result column="sc_type" property="type"
            typeHandler="com.yeshi.fanli.util.mybatishandler.CouponTypeEnumHandler" />
    
    <result column="sc_percent" property="percent" jdbcType="DECIMAL"/>
    <result column="sc_amount" property="amount" jdbcType="VARCHAR"/>
    <result column="sc_expiry_day" property="expiryDay" jdbcType="INTEGER"/>
    <result column="sc_activate_day" property="activateDay" jdbcType="INTEGER"/>
    <result column="sc_rule" property="rule" jdbcType="VARCHAR"/>
    <result column="sc_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="sc_rule_link" property="ruleLink" jdbcType="VARCHAR"/>
    <result column="sc_state" property="state" jdbcType="INTEGER"/>
    <result column="sc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="sc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">sc_id,sc_name,sc_picture,sc_picture_invalid,sc_effect,sc_type,sc_percent,sc_amount,sc_expiry_day,sc_activate_day,sc_rule,sc_remark,sc_rule_link,sc_state,sc_create_time,sc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_system_coupon where sc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_system_coupon where sc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.system.SystemCoupon" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_system_coupon (sc_id,sc_name,sc_picture,sc_picture_invalid,sc_effect,sc_type,sc_percent,sc_amount,sc_expiry_day,sc_activate_day,sc_rule,sc_remark,sc_rule_link,sc_state,sc_create_time,sc_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{pictureInvalid,jdbcType=VARCHAR},#{effect,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{percent,jdbcType=DECIMAL},#{amount,jdbcType=VARCHAR},#{expiryDay,jdbcType=INTEGER},#{activateDay,jdbcType=INTEGER},#{rule,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{ruleLink,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.system.SystemCoupon" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_system_coupon
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">sc_id,</if>
      <if test="name != null">sc_name,</if>
      <if test="picture != null">sc_picture,</if>
      <if test="pictureInvalid != null">sc_picture_invalid,</if>
      <if test="effect != null">sc_effect,</if>
      <if test="type != null">sc_type,</if>
      <if test="percent != null">sc_percent,</if>
      <if test="amount != null">sc_amount,</if>
      <if test="expiryDay != null">sc_expiry_day,</if>
      <if test="activateDay != null">sc_activate_day,</if>
      <if test="rule != null">sc_rule,</if>
      <if test="remark != null">sc_remark,</if>
      <if test="ruleLink != null">sc_rule_link,</if>
      <if test="state != null">sc_state,</if>
      <if test="createTime != null">sc_create_time,</if>
      <if test="updateTime != null">sc_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="name != null">#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
      <if test="pictureInvalid != null">#{pictureInvalid,jdbcType=VARCHAR},</if>
      <if test="effect != null">#{effect,jdbcType=VARCHAR},</if>
      <if test="type != null">#{type,jdbcType=VARCHAR},</if>
      <if test="percent != null">#{percent,jdbcType=DECIMAL},</if>
      <if test="amount != null">#{amount,jdbcType=VARCHAR},</if>
      <if test="expiryDay != null">#{expiryDay,jdbcType=INTEGER},</if>
      <if test="activateDay != null">#{activateDay,jdbcType=INTEGER},</if>
      <if test="rule != null">#{rule,jdbcType=VARCHAR},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
      <if test="ruleLink != null">#{ruleLink,jdbcType=VARCHAR},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</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.system.SystemCoupon">update yeshi_ec_system_coupon set sc_name = #{name,jdbcType=VARCHAR},sc_picture = #{picture,jdbcType=VARCHAR},sc_picture_invalid = #{pictureInvalid,jdbcType=VARCHAR},sc_effect = #{effect,jdbcType=VARCHAR},sc_type = #{type,jdbcType=VARCHAR},sc_percent = #{percent,jdbcType=DECIMAL},sc_amount = #{amount,jdbcType=VARCHAR},sc_expiry_day = #{expiryDay,jdbcType=INTEGER},sc_activate_day = #{activateDay,jdbcType=INTEGER},sc_rule = #{rule,jdbcType=VARCHAR},sc_remark = #{remark,jdbcType=VARCHAR},sc_rule_link = #{ruleLink,jdbcType=VARCHAR},sc_state = #{state,jdbcType=INTEGER},sc_create_time = #{createTime,jdbcType=TIMESTAMP},sc_update_time = #{updateTime,jdbcType=TIMESTAMP} where sc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.system.SystemCoupon">update yeshi_ec_system_coupon
    <set>
      <if test="name != null">sc_name=#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">sc_picture=#{picture,jdbcType=VARCHAR},</if>
      <if test="pictureInvalid != null">sc_picture_invalid=#{pictureInvalid,jdbcType=VARCHAR},</if>
      <if test="effect != null">sc_effect=#{effect,jdbcType=VARCHAR},</if>
      <if test="type != null">sc_type=#{type,jdbcType=VARCHAR},</if>
      <if test="percent != null">sc_percent=#{percent,jdbcType=DECIMAL},</if>
      <if test="amount != null">sc_amount=#{amount,jdbcType=VARCHAR},</if>
      <if test="expiryDay != null">sc_expiry_day=#{expiryDay,jdbcType=INTEGER},</if>
      <if test="activateDay != null">sc_activate_day=#{activateDay,jdbcType=INTEGER},</if>
      <if test="rule != null">sc_rule=#{rule,jdbcType=VARCHAR},</if>
      <if test="remark != null">sc_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="ruleLink != null">sc_rule_link=#{ruleLink,jdbcType=VARCHAR},</if>
      <if test="state != null">sc_state=#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">sc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">sc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where sc_id = #{id,jdbcType=BIGINT}
  </update>
  
  <delete id="deleteBatchByPrimaryKey"  parameterType="java.util.List">
    delete FROM yeshi_ec_system_coupon WHERE sc_id in
    <foreach collection="list" item="item" open="(" close=")"
        separator=",">#{item}</foreach>
  </delete>
  
  <select id="getCouponListByType" resultMap="BaseResultMap"  parameterType="java.util.List">
    select * FROM yeshi_ec_system_coupon 
    WHERE sc_state = 1 
        AND sc_type in
        <foreach collection="list" index="index" item="item" open="(" close=")"
            separator=",">'${item}'</foreach>
  </select>
  
  <select id="getCouponByType" resultMap="BaseResultMap" >
    select * FROM yeshi_ec_system_coupon 
    WHERE sc_type = #{type}
    limit 1
  </select>
  
  <select id="getCouponByTypeAndPercent" resultMap="BaseResultMap" >
    select * FROM yeshi_ec_system_coupon 
    WHERE sc_type = #{type} AND sc_percent = #{percent}
    limit 1
  </select>
  
</mapper>