CouponGrantMapper.xml 12.7 KB
<?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="cn.runsa.crmapp.coupon.mapper.CouponGrantMapper" >
  <resultMap id="BaseResultMap" type="cn.runsa.crmapp.coupon.entity.CouponGrant" >
    <id column="GRT_ID" property="grtId" jdbcType="BIGINT" />
    <result column="DOC_CODE" property="docCode" jdbcType="VARCHAR" />
    <result column="CPL_ID" property="cplId" jdbcType="VARCHAR" />
    <result column="GRT_TARGET" property="grtTarget" jdbcType="VARCHAR" />
    <result column="PER_NUM" property="perNum" jdbcType="INTEGER" />
    <result column="TOTAL_NUM" property="totalNum" jdbcType="BIGINT" />
    <result column="ENABLE" property="enable" jdbcType="BIT" />
    <result column="GRT_STAT" property="grtStat" jdbcType="TINYINT" />
    <result column="REC_TIME" property="recTime" jdbcType="TIMESTAMP" />
    <result column="REC_USER" property="recUser" jdbcType="BIGINT" />
    <result column="REMARK" property="remark" jdbcType="VARCHAR" />
  </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" >
    GRT_ID, DOC_CODE, CPL_ID, GRT_TARGET, PER_NUM, TOTAL_NUM, ENABLE, GRT_STAT, REC_TIME, 
    REC_USER, REMARK
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="cn.runsa.crmapp.coupon.entity.CouponGrantExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from crm_coupons_grant
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    select 
    <include refid="Base_Column_List" />
    from crm_coupons_grant
    where GRT_ID = #{grtId,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    delete from crm_coupons_grant
    where GRT_ID = #{grtId,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="cn.runsa.crmapp.coupon.entity.CouponGrantExample" >
    delete from crm_coupons_grant
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="cn.runsa.crmapp.coupon.entity.CouponGrant" >
    insert into crm_coupons_grant (GRT_ID, DOC_CODE, CPL_ID, 
      GRT_TARGET, PER_NUM, TOTAL_NUM, 
      ENABLE, GRT_STAT, REC_TIME, 
      REC_USER, REMARK)
    values (#{grtId,jdbcType=BIGINT}, #{docCode,jdbcType=VARCHAR}, #{cplId,jdbcType=VARCHAR}, 
      #{grtTarget,jdbcType=VARCHAR}, #{perNum,jdbcType=INTEGER}, #{totalNum,jdbcType=BIGINT}, 
      #{enable,jdbcType=BIT}, #{grtStat,jdbcType=TINYINT}, #{recTime,jdbcType=TIMESTAMP}, 
      #{recUser,jdbcType=BIGINT}, #{remark,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="cn.runsa.crmapp.coupon.entity.CouponGrant" >
    insert into crm_coupons_grant
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="grtId != null" >
        GRT_ID,
      </if>
      <if test="docCode != null" >
        DOC_CODE,
      </if>
      <if test="cplId != null" >
        CPL_ID,
      </if>
      <if test="grtTarget != null" >
        GRT_TARGET,
      </if>
      <if test="perNum != null" >
        PER_NUM,
      </if>
      <if test="totalNum != null" >
        TOTAL_NUM,
      </if>
      <if test="enable != null" >
        ENABLE,
      </if>
      <if test="grtStat != null" >
        GRT_STAT,
      </if>
      <if test="recTime != null" >
        REC_TIME,
      </if>
      <if test="recUser != null" >
        REC_USER,
      </if>
      <if test="remark != null" >
        REMARK,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="grtId != null" >
        #{grtId,jdbcType=BIGINT},
      </if>
      <if test="docCode != null" >
        #{docCode,jdbcType=VARCHAR},
      </if>
      <if test="cplId != null" >
        #{cplId,jdbcType=VARCHAR},
      </if>
      <if test="grtTarget != null" >
        #{grtTarget,jdbcType=VARCHAR},
      </if>
      <if test="perNum != null" >
        #{perNum,jdbcType=INTEGER},
      </if>
      <if test="totalNum != null" >
        #{totalNum,jdbcType=BIGINT},
      </if>
      <if test="enable != null" >
        #{enable,jdbcType=BIT},
      </if>
      <if test="grtStat != null" >
        #{grtStat,jdbcType=TINYINT},
      </if>
      <if test="recTime != null" >
        #{recTime,jdbcType=TIMESTAMP},
      </if>
      <if test="recUser != null" >
        #{recUser,jdbcType=BIGINT},
      </if>
      <if test="remark != null" >
        #{remark,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="cn.runsa.crmapp.coupon.entity.CouponGrantExample" resultType="java.lang.Integer" >
    select count(*) from crm_coupons_grant
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update crm_coupons_grant
    <set >
      <if test="record.grtId != null" >
        GRT_ID = #{record.grtId,jdbcType=BIGINT},
      </if>
      <if test="record.docCode != null" >
        DOC_CODE = #{record.docCode,jdbcType=VARCHAR},
      </if>
      <if test="record.cplId != null" >
        CPL_ID = #{record.cplId,jdbcType=VARCHAR},
      </if>
      <if test="record.grtTarget != null" >
        GRT_TARGET = #{record.grtTarget,jdbcType=VARCHAR},
      </if>
      <if test="record.perNum != null" >
        PER_NUM = #{record.perNum,jdbcType=INTEGER},
      </if>
      <if test="record.totalNum != null" >
        TOTAL_NUM = #{record.totalNum,jdbcType=BIGINT},
      </if>
      <if test="record.enable != null" >
        ENABLE = #{record.enable,jdbcType=BIT},
      </if>
      <if test="record.grtStat != null" >
        GRT_STAT = #{record.grtStat,jdbcType=TINYINT},
      </if>
      <if test="record.recTime != null" >
        REC_TIME = #{record.recTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.recUser != null" >
        REC_USER = #{record.recUser,jdbcType=BIGINT},
      </if>
      <if test="record.remark != null" >
        REMARK = #{record.remark,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update crm_coupons_grant
    set GRT_ID = #{record.grtId,jdbcType=BIGINT},
      DOC_CODE = #{record.docCode,jdbcType=VARCHAR},
      CPL_ID = #{record.cplId,jdbcType=VARCHAR},
      GRT_TARGET = #{record.grtTarget,jdbcType=VARCHAR},
      PER_NUM = #{record.perNum,jdbcType=INTEGER},
      TOTAL_NUM = #{record.totalNum,jdbcType=BIGINT},
      ENABLE = #{record.enable,jdbcType=BIT},
      GRT_STAT = #{record.grtStat,jdbcType=TINYINT},
      REC_TIME = #{record.recTime,jdbcType=TIMESTAMP},
      REC_USER = #{record.recUser,jdbcType=BIGINT},
      REMARK = #{record.remark,jdbcType=VARCHAR}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="cn.runsa.crmapp.coupon.entity.CouponGrant" >
    update crm_coupons_grant
    <set >
      <if test="docCode != null" >
        DOC_CODE = #{docCode,jdbcType=VARCHAR},
      </if>
      <if test="cplId != null" >
        CPL_ID = #{cplId,jdbcType=VARCHAR},
      </if>
      <if test="grtTarget != null" >
        GRT_TARGET = #{grtTarget,jdbcType=VARCHAR},
      </if>
      <if test="perNum != null" >
        PER_NUM = #{perNum,jdbcType=INTEGER},
      </if>
      <if test="totalNum != null" >
        TOTAL_NUM = #{totalNum,jdbcType=BIGINT},
      </if>
      <if test="enable != null" >
        ENABLE = #{enable,jdbcType=BIT},
      </if>
      <if test="grtStat != null" >
        GRT_STAT = #{grtStat,jdbcType=TINYINT},
      </if>
      <if test="recTime != null" >
        REC_TIME = #{recTime,jdbcType=TIMESTAMP},
      </if>
      <if test="recUser != null" >
        REC_USER = #{recUser,jdbcType=BIGINT},
      </if>
      <if test="remark != null" >
        REMARK = #{remark,jdbcType=VARCHAR},
      </if>
    </set>
    where GRT_ID = #{grtId,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.runsa.crmapp.coupon.entity.CouponGrant" >
    update crm_coupons_grant
    set DOC_CODE = #{docCode,jdbcType=VARCHAR},
      CPL_ID = #{cplId,jdbcType=VARCHAR},
      GRT_TARGET = #{grtTarget,jdbcType=VARCHAR},
      PER_NUM = #{perNum,jdbcType=INTEGER},
      TOTAL_NUM = #{totalNum,jdbcType=BIGINT},
      ENABLE = #{enable,jdbcType=BIT},
      GRT_STAT = #{grtStat,jdbcType=TINYINT},
      REC_TIME = #{recTime,jdbcType=TIMESTAMP},
      REC_USER = #{recUser,jdbcType=BIGINT},
      REMARK = #{remark,jdbcType=VARCHAR}
    where GRT_ID = #{grtId,jdbcType=BIGINT}
  </update>
  <select id="getCouponGrantMaxDocCode" resultType="int" parameterType="java.lang.String">
    SELECT IFNULL(MAX(SUBSTR(T.DOC_CODE,11)), 0) DOC_CODE FROM CRM_COUPONS_GRANT T WHERE LOCATE(#{dcDate},T.DOC_CODE)>0
  </select>
  <select id="selectByDocCode" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from crm_coupons_grant
    where DOC_CODE = #{docCode,jdbcType=VARCHAR}
  </select>
  <update id="updateGrtStatByDocCode" parameterType="cn.runsa.crmapp.coupon.entity.CouponGrant" >
    update crm_coupons_grant
    <set >
      <if test="cplId != null" >
        CPL_ID = #{cplId,jdbcType=VARCHAR},
      </if>
      <if test="grtTarget != null" >
        GRT_TARGET = #{grtTarget,jdbcType=VARCHAR},
      </if>
      <if test="perNum != null" >
        PER_NUM = #{perNum,jdbcType=INTEGER},
      </if>
      <if test="totalNum != null" >
        TOTAL_NUM = #{totalNum,jdbcType=BIGINT},
      </if>
      <if test="enable != null" >
        ENABLE = #{enable,jdbcType=BIT},
      </if>
      <if test="grtStat != null" >
        GRT_STAT = #{grtStat,jdbcType=TINYINT},
      </if>
      <if test="recTime != null" >
        REC_TIME = #{recTime,jdbcType=TIMESTAMP},
      </if>
      <if test="recUser != null" >
        REC_USER = #{recUser,jdbcType=BIGINT},
      </if>
      <if test="remark != null" >
        REMARK = #{remark,jdbcType=VARCHAR},
      </if>
    </set>
    where DOC_CODE = #{docCode,jdbcType=VARCHAR}
  </update>
  <update id="updateCouponQuotaEnableStat" parameterType="cn.runsa.crmapp.coupon.entity.CouponGrant">
    UPDATE crm_coupons_grant t SET t.ENABLE = #{enable} where t.DOC_CODE = #{docCode}
  </update>
</mapper>