<?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.kmall.admin.dao.mk.store.MkStoreCampMinusLevelDao">

    <resultMap type="com.kmall.admin.entity.mk.store.MkStoreCampMinusLevelEntity" id="mkStoreCampMinusLevelMap">
        <result property="campMinusLevelId" column="camp_minus_level_id"/>
        <result property="campMinusType" column="camp_minus_type"/>
        <result property="campMinusId" column="camp_minus_id"/>
        <result property="minusMode" column="minus_mode"/>
        <result property="yuanMinusCond" column="yuan_minus_cond"/>
        <result property="yuanMinusPref" column="yuan_minus_pref"/>
        <result property="pieceMinusConf" column="piece_minus_conf"/>
        <result property="pieceMinusPref" column="piece_minus_pref"/>
        <result property="pieceMinusEachDisc" column="piece_minus_each_disc"/>
        <result property="yuanDiscCond" column="yuan_disc_cond"/>
        <result property="yuanDiscPref" column="yuan_disc_pref"/>
        <result property="pieceDiscConf" column="piece_disc_conf"/>
        <result property="pieceDiscPref" column="piece_disc_pref"/>
        <result property="isValid" column="is_valid"/>
        <result property="note" column="note"/>
        <result property="createrSn" column="creater_sn"/>
        <result property="createTime" column="create_time"/>
        <result property="moderSn" column="moder_sn"/>
        <result property="modTime" column="mod_time"/>
        <result property="tstm" column="tstm"/>
    </resultMap>

	<select id="queryObject" resultType="com.kmall.admin.entity.mk.store.MkStoreCampMinusLevelEntity">
		select
			`camp_minus_level_id`,
			`camp_minus_type`,
			`camp_minus_id`,
			`minus_mode`,
			`yuan_minus_cond`,
			`yuan_minus_pref`,
			`piece_minus_conf`,
			`piece_minus_pref`,
			`piece_minus_each_disc`,
			`yuan_disc_cond`,
			`yuan_disc_pref`,
			`piece_disc_conf`,
			`piece_disc_pref`,
			`is_valid`,
			`note`,
			`creater_sn`,
			`create_time`,
			`moder_sn`,
			`mod_time`,
			`tstm`
		from mk_store_camp_minus_level
		where camp_minus_level_id = #{id}
	</select>

	<select id="queryLevelByCampMinusId" resultType="com.kmall.admin.entity.mk.store.MkStoreCampMinusLevelEntity">
		select
		`camp_minus_level_id`,
		`camp_minus_type`,
		`camp_minus_id`,
		`minus_mode`,
		`yuan_minus_cond`,
		`yuan_minus_pref`,
		`piece_minus_conf`,
		`piece_minus_pref`,
		`piece_minus_each_disc`,
		`yuan_disc_cond`,
		`yuan_disc_pref`,
		`piece_disc_conf`,
		`piece_disc_pref`,
		`is_valid`,
		`note`,
		`creater_sn`,
		`create_time`,
		`moder_sn`,
		`mod_time`,
		`tstm`
		from mk_store_camp_minus_level
		where camp_minus_id = #{campMinusId}
	</select>

	<select id="queryList" resultType="com.kmall.admin.entity.mk.store.MkStoreCampMinusLevelEntity">
		select
    		`camp_minus_level_id`,
    		`camp_minus_type`,
    		`camp_minus_id`,
    		`minus_mode`,
    		`yuan_minus_cond`,
    		`yuan_minus_pref`,
    		`piece_minus_conf`,
    		`piece_minus_pref`,
    		`piece_minus_each_disc`,
    		`yuan_disc_cond`,
    		`yuan_disc_pref`,
    		`piece_disc_conf`,
    		`piece_disc_pref`,
    		`is_valid`,
    		`note`,
    		`creater_sn`,
    		`create_time`,
    		`moder_sn`,
    		`mod_time`,
    		`tstm`
		from mk_store_camp_minus_level
		WHERE 1=1
		<if test="name != null and name.trim() != ''">
			AND name LIKE concat('%',#{name},'%')
		</if>
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by ${sidx} ${order}
            </when>
			<otherwise>
                order by camp_minus_level_id desc
			</otherwise>
        </choose>
		<if test="offset != null and limit != null">
			limit #{offset}, #{limit}
		</if>
	</select>
	
 	<select id="queryTotal" resultType="int">
		select count(*) from mk_store_camp_minus_level
		WHERE 1=1
        <if test="name != null and name.trim() != ''">
            AND name LIKE concat('%',#{name},'%')
        </if>
	</select>
	 
	<insert id="save" parameterType="com.kmall.admin.entity.mk.store.MkStoreCampMinusLevelEntity" useGeneratedKeys="true" keyProperty="campMinusId">
		insert into mk_store_camp_minus_level(
			`camp_minus_id`,
			`camp_minus_type`,
			`minus_mode`,
			`yuan_minus_cond`,
			`yuan_minus_pref`,
			`piece_minus_conf`,
			`piece_minus_pref`,
			`piece_minus_each_disc`,
			`yuan_disc_cond`,
			`yuan_disc_pref`,
			`piece_disc_conf`,
			`piece_disc_pref`,
			`is_valid`,
			`note`,
			`creater_sn`,
			`create_time`,
			`moder_sn`,
			`mod_time`,
			`tstm`)
		values(
			#{campMinusId},
			#{campMinusType},
			#{minusMode},
			#{yuanMinusCond},
			#{yuanMinusPref},
			#{pieceMinusConf},
			#{pieceMinusPref},
			#{pieceMinusEachDisc},
			#{yuanDiscCond},
			#{yuanDiscPref},
			#{pieceDiscConf},
			#{pieceDiscPref},
			#{isValid},
			#{note},
			#{createrSn},
			#{createTime},
			#{moderSn},
			#{modTime},
			#{tstm})
	</insert>
	 
	<update id="update" parameterType="com.kmall.admin.entity.mk.store.MkStoreCampMinusLevelEntity">
		update mk_store_camp_minus_level 
		<set>
			<if test="campMinusId != null">`camp_minus_id` = #{campMinusId}, </if>
			<if test="campMinusType != null">`camp_minus_type` = #{campMinusType}, </if>
			<if test="minusMode != null">`minus_mode` = #{minusMode}, </if>
			<if test="yuanMinusCond != null">`yuan_minus_cond` = #{yuanMinusCond}, </if>
			<if test="yuanMinusPref != null">`yuan_minus_pref` = #{yuanMinusPref}, </if>
			<if test="pieceMinusConf != null">`piece_minus_conf` = #{pieceMinusConf}, </if>
			<if test="pieceMinusPref != null">`piece_minus_pref` = #{pieceMinusPref}, </if>
			<if test="pieceMinusEachDisc != null">`piece_minus_each_disc` = #{pieceMinusEachDisc}, </if>
			<if test="yuanDiscCond != null">`yuan_disc_cond` = #{yuanDiscCond}, </if>
			<if test="yuanDiscPref != null">`yuan_disc_pref` = #{yuanDiscPref}, </if>
			<if test="pieceDiscConf != null">`piece_disc_conf` = #{pieceDiscConf}, </if>
			<if test="pieceDiscPref != null">`piece_disc_pref` = #{pieceDiscPref}, </if>
			<if test="isValid != null">`is_valid` = #{isValid}, </if>
			<if test="note != null">`note` = #{note}, </if>
			<if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
			<if test="createTime != null">`create_time` = #{createTime}, </if>
			<if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
			<if test="modTime != null">`mod_time` = #{modTime}, </if>
			<if test="tstm != null">`tstm` = #{tstm}</if>
		</set>
		where camp_minus_level_id = #{campMinusLevelId}
	</update>
	
	<delete id="delete">
		delete from mk_store_camp_minus_level where camp_minus_level_id = #{value}
	</delete>

	<delete id="deleteByCampMinusId">
		delete from mk_store_camp_minus_level where camp_minus_id = #{campMinusId}
	</delete>
	
	<delete id="deleteBatch">
		delete from mk_store_camp_minus_level where camp_minus_level_id in
		<foreach item="campMinusLevelId" collection="array" open="(" separator="," close=")">
			#{campMinusLevelId}
		</foreach>
	</delete>

	<insert id="saveBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
		insert into mk_store_camp_minus_level(
		`camp_minus_id`,
		`camp_minus_type`,
		`minus_mode`,
		`yuan_minus_cond`,
		`yuan_minus_pref`,
		`piece_minus_conf`,
		`piece_minus_pref`,
		`piece_minus_each_disc`,
		`yuan_disc_cond`,
		`yuan_disc_pref`,
		`piece_disc_conf`,
		`piece_disc_pref`,
		`is_valid`,
		`note`,
		`creater_sn`,
		`create_time`,
		`moder_sn`,
		`mod_time`,
		`tstm`)
		values
		<foreach collection="list" index="index" item="storeCampMinusLevel" separator=",">
			(
			#{storeCampMinusLevel.campMinusId},
			#{storeCampMinusLevel.campMinusType},
			#{storeCampMinusLevel.minusMode},
			#{storeCampMinusLevel.yuanMinusCond},
			#{storeCampMinusLevel.yuanMinusPref},
			#{storeCampMinusLevel.pieceMinusConf},
			#{storeCampMinusLevel.pieceMinusPref},
			#{storeCampMinusLevel.pieceMinusEachDisc},
			#{storeCampMinusLevel.yuanDiscCond},
			#{storeCampMinusLevel.yuanDiscPref},
			#{storeCampMinusLevel.pieceDiscConf},
			#{storeCampMinusLevel.pieceDiscPref},
			#{storeCampMinusLevel.isValid},
			#{storeCampMinusLevel.note},
			#{storeCampMinusLevel.createrSn},
			#{storeCampMinusLevel.createTime},
			#{storeCampMinusLevel.moderSn},
			#{storeCampMinusLevel.modTime},
			#{storeCampMinusLevel.tstm,jdbcType=TIMESTAMP})
		</foreach>
	</insert>

</mapper>