<?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.xmomen.module.base.entity.mapper.CdCouponMapper" >
  <resultMap id="BaseResultMap" type="com.xmomen.module.base.entity.CdCoupon" >
    <id column="ID" property="id" jdbcType="INTEGER" />
    <result column="COUPON_TYPE" property="couponType" jdbcType="INTEGER" />
    <result column="COUPON_CATEGORY" property="couponCategory" jdbcType="INTEGER" />
    <result column="COUPON_NUMBER" property="couponNumber" jdbcType="VARCHAR" />
    <result column="COUPON_PASSWORD" property="couponPassword" jdbcType="VARCHAR" />
    <result column="COUPON_VALUE" property="couponValue" jdbcType="DECIMAL" />
    <result column="USER_PRICE" property="userPrice" jdbcType="DECIMAL" />
    <result column="CD_COMPANY_ID" property="cdCompanyId" jdbcType="INTEGER" />
    <result column="CD_USER_ID" property="cdUserId" jdbcType="INTEGER" />
    <result column="COUPON_DESC" property="couponDesc" jdbcType="VARCHAR" />
    <result column="IS_USED" property="isUsed" jdbcType="INTEGER" />
    <result column="IS_USEFUL" property="isUseful" jdbcType="INTEGER" />
    <result column="IS_GIFT" property="isGift" jdbcType="INTEGER" />
    <result column="IS_SEND" property="isSend" jdbcType="INTEGER" />
    <result column="PAYMENT_TYPE" property="paymentType" jdbcType="INTEGER" />
    <result column="BEGIN_TIME" property="beginTime" jdbcType="TIMESTAMP" />
    <result column="END_TIME" property="endTime" jdbcType="TIMESTAMP" />
    <result column="NOTES" property="notes" jdbcType="VARCHAR" />
    <result column="IS_OVER" property="isOver" jdbcType="INTEGER" />
    <result column="AUDIT_DATE" property="auditDate" jdbcType="TIMESTAMP" />
    <result column="BATCH" property="batch" jdbcType="VARCHAR" />
    <result column="USEFUL_DATE" property="usefulDate" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause" >
    <where >
      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    ID, COUPON_TYPE, COUPON_CATEGORY, COUPON_NUMBER, COUPON_PASSWORD, COUPON_VALUE, USER_PRICE, 
    CD_COMPANY_ID, CD_USER_ID, COUPON_DESC, IS_USED, IS_USEFUL, IS_GIFT, IS_SEND, PAYMENT_TYPE, 
    BEGIN_TIME, END_TIME, NOTES, IS_OVER, AUDIT_DATE, BATCH, USEFUL_DATE
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.xmomen.module.base.entity.CdCouponExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from cd_coupon
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <delete id="deleteByExample" parameterType="com.xmomen.module.base.entity.CdCouponExample" >
    delete from cd_coupon
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insertSelective" parameterType="com.xmomen.module.base.entity.CdCoupon" useGeneratedKeys="true" keyProperty="id" keyColumn="ID" >
    insert into cd_coupon
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        ID,
      </if>
      <if test="couponType != null" >
        COUPON_TYPE,
      </if>
      <if test="couponCategory != null" >
        COUPON_CATEGORY,
      </if>
      <if test="couponNumber != null" >
        COUPON_NUMBER,
      </if>
      <if test="couponPassword != null" >
        COUPON_PASSWORD,
      </if>
      <if test="couponValue != null" >
        COUPON_VALUE,
      </if>
      <if test="userPrice != null" >
        USER_PRICE,
      </if>
      <if test="cdCompanyId != null" >
        CD_COMPANY_ID,
      </if>
      <if test="cdUserId != null" >
        CD_USER_ID,
      </if>
      <if test="couponDesc != null" >
        COUPON_DESC,
      </if>
      <if test="isUsed != null" >
        IS_USED,
      </if>
      <if test="isUseful != null" >
        IS_USEFUL,
      </if>
      <if test="isGift != null" >
        IS_GIFT,
      </if>
      <if test="isSend != null" >
        IS_SEND,
      </if>
      <if test="paymentType != null" >
        PAYMENT_TYPE,
      </if>
      <if test="beginTime != null" >
        BEGIN_TIME,
      </if>
      <if test="endTime != null" >
        END_TIME,
      </if>
      <if test="notes != null" >
        NOTES,
      </if>
      <if test="isOver != null" >
        IS_OVER,
      </if>
      <if test="auditDate != null" >
        AUDIT_DATE,
      </if>
      <if test="batch != null" >
        BATCH,
      </if>
      <if test="usefulDate != null" >
        USEFUL_DATE,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="couponType != null" >
        #{couponType,jdbcType=INTEGER},
      </if>
      <if test="couponCategory != null" >
        #{couponCategory,jdbcType=INTEGER},
      </if>
      <if test="couponNumber != null" >
        #{couponNumber,jdbcType=VARCHAR},
      </if>
      <if test="couponPassword != null" >
        #{couponPassword,jdbcType=VARCHAR},
      </if>
      <if test="couponValue != null" >
        #{couponValue,jdbcType=DECIMAL},
      </if>
      <if test="userPrice != null" >
        #{userPrice,jdbcType=DECIMAL},
      </if>
      <if test="cdCompanyId != null" >
        #{cdCompanyId,jdbcType=INTEGER},
      </if>
      <if test="cdUserId != null" >
        #{cdUserId,jdbcType=INTEGER},
      </if>
      <if test="couponDesc != null" >
        #{couponDesc,jdbcType=VARCHAR},
      </if>
      <if test="isUsed != null" >
        #{isUsed,jdbcType=INTEGER},
      </if>
      <if test="isUseful != null" >
        #{isUseful,jdbcType=INTEGER},
      </if>
      <if test="isGift != null" >
        #{isGift,jdbcType=INTEGER},
      </if>
      <if test="isSend != null" >
        #{isSend,jdbcType=INTEGER},
      </if>
      <if test="paymentType != null" >
        #{paymentType,jdbcType=INTEGER},
      </if>
      <if test="beginTime != null" >
        #{beginTime,jdbcType=TIMESTAMP},
      </if>
      <if test="endTime != null" >
        #{endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="notes != null" >
        #{notes,jdbcType=VARCHAR},
      </if>
      <if test="isOver != null" >
        #{isOver,jdbcType=INTEGER},
      </if>
      <if test="auditDate != null" >
        #{auditDate,jdbcType=TIMESTAMP},
      </if>
      <if test="batch != null" >
        #{batch,jdbcType=VARCHAR},
      </if>
      <if test="usefulDate != null" >
        #{usefulDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.xmomen.module.base.entity.CdCouponExample" resultType="java.lang.Integer" >
    select count(*) from cd_coupon
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update cd_coupon
    <set >
      <if test="record.id != null" >
        ID = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.couponType != null" >
        COUPON_TYPE = #{record.couponType,jdbcType=INTEGER},
      </if>
      <if test="record.couponCategory != null" >
        COUPON_CATEGORY = #{record.couponCategory,jdbcType=INTEGER},
      </if>
      <if test="record.couponNumber != null" >
        COUPON_NUMBER = #{record.couponNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.couponPassword != null" >
        COUPON_PASSWORD = #{record.couponPassword,jdbcType=VARCHAR},
      </if>
      <if test="record.couponValue != null" >
        COUPON_VALUE = #{record.couponValue,jdbcType=DECIMAL},
      </if>
      <if test="record.userPrice != null" >
        USER_PRICE = #{record.userPrice,jdbcType=DECIMAL},
      </if>
      <if test="record.cdCompanyId != null" >
        CD_COMPANY_ID = #{record.cdCompanyId,jdbcType=INTEGER},
      </if>
      <if test="record.cdUserId != null" >
        CD_USER_ID = #{record.cdUserId,jdbcType=INTEGER},
      </if>
      <if test="record.couponDesc != null" >
        COUPON_DESC = #{record.couponDesc,jdbcType=VARCHAR},
      </if>
      <if test="record.isUsed != null" >
        IS_USED = #{record.isUsed,jdbcType=INTEGER},
      </if>
      <if test="record.isUseful != null" >
        IS_USEFUL = #{record.isUseful,jdbcType=INTEGER},
      </if>
      <if test="record.isGift != null" >
        IS_GIFT = #{record.isGift,jdbcType=INTEGER},
      </if>
      <if test="record.isSend != null" >
        IS_SEND = #{record.isSend,jdbcType=INTEGER},
      </if>
      <if test="record.paymentType != null" >
        PAYMENT_TYPE = #{record.paymentType,jdbcType=INTEGER},
      </if>
      <if test="record.beginTime != null" >
        BEGIN_TIME = #{record.beginTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.endTime != null" >
        END_TIME = #{record.endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.notes != null" >
        NOTES = #{record.notes,jdbcType=VARCHAR},
      </if>
      <if test="record.isOver != null" >
        IS_OVER = #{record.isOver,jdbcType=INTEGER},
      </if>
      <if test="record.auditDate != null" >
        AUDIT_DATE = #{record.auditDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.batch != null" >
        BATCH = #{record.batch,jdbcType=VARCHAR},
      </if>
      <if test="record.usefulDate != null" >
        USEFUL_DATE = #{record.usefulDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
</mapper>