<?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.neusoft.smart.pos.promotion.persistent.mapper.PromotionPayChannelMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.promotion.persistent.domain.PromotionPayChannel">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="pay_channel" jdbcType="INTEGER" property="payChannel" />
    <result column="store_id" jdbcType="INTEGER" property="storeId" />
    <result column="org_id" jdbcType="INTEGER" property="orgId" />
    <result column="discount" jdbcType="DECIMAL" property="discount" />
    <result column="purchase_money" jdbcType="INTEGER" property="purchaseMoney" />
    <result column="money_off" jdbcType="INTEGER" property="moneyOff" />
    <result column="off_type" jdbcType="INTEGER" property="offType" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_by" jdbcType="INTEGER" property="createBy" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <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 close=")" collection="criterion.value" item="listItem" open="(" 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="(" prefixOverrides="and" suffix=")">
            <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 close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, pay_channel, store_id, org_id, discount, purchase_money, money_off, off_type, 
    create_time, create_by
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.promotion.persistent.domain.PromotionPayChannelExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from promotion_pay_channel
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
    <if test="offset != null and limit != null">
      limit ${offset}, ${limit}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from promotion_pay_channel
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from promotion_pay_channel
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.promotion.persistent.domain.PromotionPayChannelExample">
    delete from promotion_pay_channel
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.promotion.persistent.domain.PromotionPayChannel" useGeneratedKeys="true">
    insert into promotion_pay_channel (pay_channel, store_id, org_id, 
      discount, purchase_money, money_off, 
      off_type, create_time, create_by
      )
    values (#{payChannel,jdbcType=INTEGER}, #{storeId,jdbcType=INTEGER}, #{orgId,jdbcType=INTEGER}, 
      #{discount,jdbcType=DECIMAL}, #{purchaseMoney,jdbcType=INTEGER}, #{moneyOff,jdbcType=INTEGER}, 
      #{offType,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.promotion.persistent.domain.PromotionPayChannel" useGeneratedKeys="true">
    insert into promotion_pay_channel
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="payChannel != null">
        pay_channel,
      </if>
      <if test="storeId != null">
        store_id,
      </if>
      <if test="orgId != null">
        org_id,
      </if>
      <if test="discount != null">
        discount,
      </if>
      <if test="purchaseMoney != null">
        purchase_money,
      </if>
      <if test="moneyOff != null">
        money_off,
      </if>
      <if test="offType != null">
        off_type,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="payChannel != null">
        #{payChannel,jdbcType=INTEGER},
      </if>
      <if test="storeId != null">
        #{storeId,jdbcType=INTEGER},
      </if>
      <if test="orgId != null">
        #{orgId,jdbcType=INTEGER},
      </if>
      <if test="discount != null">
        #{discount,jdbcType=DECIMAL},
      </if>
      <if test="purchaseMoney != null">
        #{purchaseMoney,jdbcType=INTEGER},
      </if>
      <if test="moneyOff != null">
        #{moneyOff,jdbcType=INTEGER},
      </if>
      <if test="offType != null">
        #{offType,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.promotion.persistent.domain.PromotionPayChannelExample" resultType="java.lang.Integer">
    select count(*) from promotion_pay_channel
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update promotion_pay_channel
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.payChannel != null">
        pay_channel = #{record.payChannel,jdbcType=INTEGER},
      </if>
      <if test="record.storeId != null">
        store_id = #{record.storeId,jdbcType=INTEGER},
      </if>
      <if test="record.orgId != null">
        org_id = #{record.orgId,jdbcType=INTEGER},
      </if>
      <if test="record.discount != null">
        discount = #{record.discount,jdbcType=DECIMAL},
      </if>
      <if test="record.purchaseMoney != null">
        purchase_money = #{record.purchaseMoney,jdbcType=INTEGER},
      </if>
      <if test="record.moneyOff != null">
        money_off = #{record.moneyOff,jdbcType=INTEGER},
      </if>
      <if test="record.offType != null">
        off_type = #{record.offType,jdbcType=INTEGER},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createBy != null">
        create_by = #{record.createBy,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update promotion_pay_channel
    set id = #{record.id,jdbcType=INTEGER},
      pay_channel = #{record.payChannel,jdbcType=INTEGER},
      store_id = #{record.storeId,jdbcType=INTEGER},
      org_id = #{record.orgId,jdbcType=INTEGER},
      discount = #{record.discount,jdbcType=DECIMAL},
      purchase_money = #{record.purchaseMoney,jdbcType=INTEGER},
      money_off = #{record.moneyOff,jdbcType=INTEGER},
      off_type = #{record.offType,jdbcType=INTEGER},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      create_by = #{record.createBy,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.promotion.persistent.domain.PromotionPayChannel">
    update promotion_pay_channel
    <set>
      <if test="payChannel != null">
        pay_channel = #{payChannel,jdbcType=INTEGER},
      </if>
      <if test="storeId != null">
        store_id = #{storeId,jdbcType=INTEGER},
      </if>
      <if test="orgId != null">
        org_id = #{orgId,jdbcType=INTEGER},
      </if>
      <if test="discount != null">
        discount = #{discount,jdbcType=DECIMAL},
      </if>
      <if test="purchaseMoney != null">
        purchase_money = #{purchaseMoney,jdbcType=INTEGER},
      </if>
      <if test="moneyOff != null">
        money_off = #{moneyOff,jdbcType=INTEGER},
      </if>
      <if test="offType != null">
        off_type = #{offType,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.promotion.persistent.domain.PromotionPayChannel">
    update promotion_pay_channel
    set pay_channel = #{payChannel,jdbcType=INTEGER},
      store_id = #{storeId,jdbcType=INTEGER},
      org_id = #{orgId,jdbcType=INTEGER},
      discount = #{discount,jdbcType=DECIMAL},
      purchase_money = #{purchaseMoney,jdbcType=INTEGER},
      money_off = #{moneyOff,jdbcType=INTEGER},
      off_type = #{offType,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_by = #{createBy,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into promotion_pay_channel  (pay_channel, store_id, org_id, 
        discount, purchase_money, money_off, 
        off_type, create_time, create_by
        )
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.payChannel,jdbcType=INTEGER}, #{item.storeId,jdbcType=INTEGER}, #{item.orgId,jdbcType=INTEGER}, 
        #{item.discount,jdbcType=DECIMAL}, #{item.purchaseMoney,jdbcType=INTEGER}, #{item.moneyOff,jdbcType=INTEGER}, 
        #{item.offType,jdbcType=INTEGER}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.createBy,jdbcType=INTEGER}
        )
      </foreach>
    </if>
  </insert>
</mapper>