<?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.card.persistent.mapper.CardCapitalChangeMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.card.persistent.domain.CardCapitalChange">
    <id column="amount_change_id" jdbcType="INTEGER" property="amountChangeId" />
    <result column="card_id" jdbcType="INTEGER" property="cardId" />
    <result column="card_num" jdbcType="VARCHAR" property="cardNum" />
    <result column="change_order_id" jdbcType="VARCHAR" property="changeOrderId" />
    <result column="amount_change" jdbcType="DECIMAL" property="amountChange" />
    <result column="amount_before" jdbcType="DECIMAL" property="amountBefore" />
    <result column="amount_after" jdbcType="DECIMAL" property="amountAfter" />
    <result column="point_change" jdbcType="INTEGER" property="pointChange" />
    <result column="point_before" jdbcType="INTEGER" property="pointBefore" />
    <result column="point_after" jdbcType="INTEGER" property="pointAfter" />
    <result column="change_type" jdbcType="INTEGER" property="changeType" />
    <result column="change_time" jdbcType="TIMESTAMP" property="changeTime" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <result column="content" jdbcType="VARCHAR" property="content" />
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
    <result column="created_by" jdbcType="VARCHAR" property="createdBy" />
  </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">
    amount_change_id, card_id, card_num, change_order_id, amount_change, amount_before, 
    amount_after, point_change, point_before, point_after, change_type, change_time, 
    is_active, content, created_time, created_by
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.card.persistent.domain.CardCapitalChangeExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from card_capital_change
    <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 card_capital_change
    where amount_change_id = #{amountChangeId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from card_capital_change
    where amount_change_id = #{amountChangeId,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.card.persistent.domain.CardCapitalChangeExample">
    delete from card_capital_change
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="amount_change_id" keyProperty="amountChangeId" parameterType="com.neusoft.smart.pos.card.persistent.domain.CardCapitalChange" useGeneratedKeys="true">
    insert into card_capital_change (card_id, card_num, change_order_id, 
      amount_change, amount_before, amount_after, 
      point_change, point_before, point_after, 
      change_type, change_time, is_active, 
      content, created_time, created_by
      )
    values (#{cardId,jdbcType=INTEGER}, #{cardNum,jdbcType=VARCHAR}, #{changeOrderId,jdbcType=VARCHAR}, 
      #{amountChange,jdbcType=DECIMAL}, #{amountBefore,jdbcType=DECIMAL}, #{amountAfter,jdbcType=DECIMAL}, 
      #{pointChange,jdbcType=INTEGER}, #{pointBefore,jdbcType=INTEGER}, #{pointAfter,jdbcType=INTEGER}, 
      #{changeType,jdbcType=INTEGER}, #{changeTime,jdbcType=TIMESTAMP}, #{isActive,jdbcType=INTEGER}, 
      #{content,jdbcType=VARCHAR}, #{createdTime,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" keyColumn="amount_change_id" keyProperty="amountChangeId" parameterType="com.neusoft.smart.pos.card.persistent.domain.CardCapitalChange" useGeneratedKeys="true">
    insert into card_capital_change
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="cardId != null">
        card_id,
      </if>
      <if test="cardNum != null">
        card_num,
      </if>
      <if test="changeOrderId != null">
        change_order_id,
      </if>
      <if test="amountChange != null">
        amount_change,
      </if>
      <if test="amountBefore != null">
        amount_before,
      </if>
      <if test="amountAfter != null">
        amount_after,
      </if>
      <if test="pointChange != null">
        point_change,
      </if>
      <if test="pointBefore != null">
        point_before,
      </if>
      <if test="pointAfter != null">
        point_after,
      </if>
      <if test="changeType != null">
        change_type,
      </if>
      <if test="changeTime != null">
        change_time,
      </if>
      <if test="isActive != null">
        is_active,
      </if>
      <if test="content != null">
        content,
      </if>
      <if test="createdTime != null">
        created_time,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="cardId != null">
        #{cardId,jdbcType=INTEGER},
      </if>
      <if test="cardNum != null">
        #{cardNum,jdbcType=VARCHAR},
      </if>
      <if test="changeOrderId != null">
        #{changeOrderId,jdbcType=VARCHAR},
      </if>
      <if test="amountChange != null">
        #{amountChange,jdbcType=DECIMAL},
      </if>
      <if test="amountBefore != null">
        #{amountBefore,jdbcType=DECIMAL},
      </if>
      <if test="amountAfter != null">
        #{amountAfter,jdbcType=DECIMAL},
      </if>
      <if test="pointChange != null">
        #{pointChange,jdbcType=INTEGER},
      </if>
      <if test="pointBefore != null">
        #{pointBefore,jdbcType=INTEGER},
      </if>
      <if test="pointAfter != null">
        #{pointAfter,jdbcType=INTEGER},
      </if>
      <if test="changeType != null">
        #{changeType,jdbcType=INTEGER},
      </if>
      <if test="changeTime != null">
        #{changeTime,jdbcType=TIMESTAMP},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </if>
      <if test="content != null">
        #{content,jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
        #{createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.card.persistent.domain.CardCapitalChangeExample" resultType="java.lang.Integer">
    select count(*) from card_capital_change
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update card_capital_change
    <set>
      <if test="record.amountChangeId != null">
        amount_change_id = #{record.amountChangeId,jdbcType=INTEGER},
      </if>
      <if test="record.cardId != null">
        card_id = #{record.cardId,jdbcType=INTEGER},
      </if>
      <if test="record.cardNum != null">
        card_num = #{record.cardNum,jdbcType=VARCHAR},
      </if>
      <if test="record.changeOrderId != null">
        change_order_id = #{record.changeOrderId,jdbcType=VARCHAR},
      </if>
      <if test="record.amountChange != null">
        amount_change = #{record.amountChange,jdbcType=DECIMAL},
      </if>
      <if test="record.amountBefore != null">
        amount_before = #{record.amountBefore,jdbcType=DECIMAL},
      </if>
      <if test="record.amountAfter != null">
        amount_after = #{record.amountAfter,jdbcType=DECIMAL},
      </if>
      <if test="record.pointChange != null">
        point_change = #{record.pointChange,jdbcType=INTEGER},
      </if>
      <if test="record.pointBefore != null">
        point_before = #{record.pointBefore,jdbcType=INTEGER},
      </if>
      <if test="record.pointAfter != null">
        point_after = #{record.pointAfter,jdbcType=INTEGER},
      </if>
      <if test="record.changeType != null">
        change_type = #{record.changeType,jdbcType=INTEGER},
      </if>
      <if test="record.changeTime != null">
        change_time = #{record.changeTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.isActive != null">
        is_active = #{record.isActive,jdbcType=INTEGER},
      </if>
      <if test="record.content != null">
        content = #{record.content,jdbcType=VARCHAR},
      </if>
      <if test="record.createdTime != null">
        created_time = #{record.createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update card_capital_change
    set amount_change_id = #{record.amountChangeId,jdbcType=INTEGER},
      card_id = #{record.cardId,jdbcType=INTEGER},
      card_num = #{record.cardNum,jdbcType=VARCHAR},
      change_order_id = #{record.changeOrderId,jdbcType=VARCHAR},
      amount_change = #{record.amountChange,jdbcType=DECIMAL},
      amount_before = #{record.amountBefore,jdbcType=DECIMAL},
      amount_after = #{record.amountAfter,jdbcType=DECIMAL},
      point_change = #{record.pointChange,jdbcType=INTEGER},
      point_before = #{record.pointBefore,jdbcType=INTEGER},
      point_after = #{record.pointAfter,jdbcType=INTEGER},
      change_type = #{record.changeType,jdbcType=INTEGER},
      change_time = #{record.changeTime,jdbcType=TIMESTAMP},
      is_active = #{record.isActive,jdbcType=INTEGER},
      content = #{record.content,jdbcType=VARCHAR},
      created_time = #{record.createdTime,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.card.persistent.domain.CardCapitalChange">
    update card_capital_change
    <set>
      <if test="cardId != null">
        card_id = #{cardId,jdbcType=INTEGER},
      </if>
      <if test="cardNum != null">
        card_num = #{cardNum,jdbcType=VARCHAR},
      </if>
      <if test="changeOrderId != null">
        change_order_id = #{changeOrderId,jdbcType=VARCHAR},
      </if>
      <if test="amountChange != null">
        amount_change = #{amountChange,jdbcType=DECIMAL},
      </if>
      <if test="amountBefore != null">
        amount_before = #{amountBefore,jdbcType=DECIMAL},
      </if>
      <if test="amountAfter != null">
        amount_after = #{amountAfter,jdbcType=DECIMAL},
      </if>
      <if test="pointChange != null">
        point_change = #{pointChange,jdbcType=INTEGER},
      </if>
      <if test="pointBefore != null">
        point_before = #{pointBefore,jdbcType=INTEGER},
      </if>
      <if test="pointAfter != null">
        point_after = #{pointAfter,jdbcType=INTEGER},
      </if>
      <if test="changeType != null">
        change_type = #{changeType,jdbcType=INTEGER},
      </if>
      <if test="changeTime != null">
        change_time = #{changeTime,jdbcType=TIMESTAMP},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </if>
      <if test="content != null">
        content = #{content,jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=VARCHAR},
      </if>
    </set>
    where amount_change_id = #{amountChangeId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.card.persistent.domain.CardCapitalChange">
    update card_capital_change
    set card_id = #{cardId,jdbcType=INTEGER},
      card_num = #{cardNum,jdbcType=VARCHAR},
      change_order_id = #{changeOrderId,jdbcType=VARCHAR},
      amount_change = #{amountChange,jdbcType=DECIMAL},
      amount_before = #{amountBefore,jdbcType=DECIMAL},
      amount_after = #{amountAfter,jdbcType=DECIMAL},
      point_change = #{pointChange,jdbcType=INTEGER},
      point_before = #{pointBefore,jdbcType=INTEGER},
      point_after = #{pointAfter,jdbcType=INTEGER},
      change_type = #{changeType,jdbcType=INTEGER},
      change_time = #{changeTime,jdbcType=TIMESTAMP},
      is_active = #{isActive,jdbcType=INTEGER},
      content = #{content,jdbcType=VARCHAR},
      created_time = #{createdTime,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=VARCHAR}
    where amount_change_id = #{amountChangeId,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into card_capital_change  (card_id, card_num, change_order_id, 
        amount_change, amount_before, amount_after, 
        point_change, point_before, point_after, 
        change_type, change_time, is_active, 
        content, created_time, created_by
        )
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.cardId,jdbcType=INTEGER}, #{item.cardNum,jdbcType=VARCHAR}, #{item.changeOrderId,jdbcType=VARCHAR}, 
        #{item.amountChange,jdbcType=DECIMAL}, #{item.amountBefore,jdbcType=DECIMAL}, #{item.amountAfter,jdbcType=DECIMAL}, 
        #{item.pointChange,jdbcType=INTEGER}, #{item.pointBefore,jdbcType=INTEGER}, #{item.pointAfter,jdbcType=INTEGER}, 
        #{item.changeType,jdbcType=INTEGER}, #{item.changeTime,jdbcType=TIMESTAMP}, #{item.isActive,jdbcType=INTEGER}, 
        #{item.content,jdbcType=VARCHAR}, #{item.createdTime,jdbcType=TIMESTAMP}, #{item.createdBy,jdbcType=VARCHAR}
        )
      </foreach>
    </if>
  </insert>
</mapper>