<?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.iamberry.wechat.service.mapper.BalanceLogMapper">
    <resultMap  id="BaseResultMap" type="BalanceLog" >
        <result    column="balance_log_id"    property="balanceLogId" />
        <result    column="balance_log_channel_id"    property="balanceLogChannelId" />
        <result    column="balance_log_channel_type"    property="balanceLogChannelType" />
        <result    column="balance_log_before_amount"    property="balanceLogBeforeAmount" />
        <result    column="balance_log_after_amount"    property="balanceLogAfterAmount" />
        <result    column="balance_log_type"    property="balanceLogType" />
        <result    column="balance_log_amount"    property="balanceLogAmount" />
        <result    column="balance_log_create_time"    property="balanceLogCreateTime" />
        <result    column="balance_log_update_time"    property="balanceLogUpdateTime" />
    </resultMap>
    <sql    id="Base_List" >
        t.balance_log_id,
        t.balance_log_channel_id,
        t.balance_log_channel_type,
        t.balance_log_before_amount,
        t.balance_log_after_amount,
        t.balance_log_type,
        t.balance_log_amount,
        t.balance_log_create_time,
        t.balance_log_update_time
    </sql>
    <select id="getBalanceLogList" resultMap="BaseResultMap" parameterType="BalanceLog" >
        select
        <include refid="Base_List" />
        from tb_iamberry_channel_balance_log t
        <where>
            <if test="balanceLogId != null ">
                AND t.balance_log_id = #{balanceLogId}
            </if >
            <if test="balanceLogChannelId != null ">
                AND t.balance_log_channel_id = #{balanceLogChannelId}
            </if >
            <if test="balanceLogChannelType != null ">
                AND t.balance_log_channel_type = #{balanceLogChannelType}
            </if >
            <if test="balanceLogType != null ">
                AND t.balance_log_type = #{balanceLogType}
            </if >
        </where>
    </select>
    <select id="getBalanceLogById" resultMap="BaseResultMap" parameterType="Integer" >
        select
        <include refid="Base_List" />
        from tb_iamberry_channel_balance_log t
        where t.balance_log_id= #{balanceLogId}
    </select>
    <insert id="save" parameterType="BalanceLog" >
        insert into
        tb_iamberry_channel_balance_log
        (
        balance_log_channel_id,
        balance_log_channel_type,
        balance_log_before_amount,
        balance_log_after_amount,
        balance_log_type,
        balance_log_amount
        )
        values
        (
        #{balanceLogChannelId},
        #{balanceLogChannelType},
        #{balanceLogBeforeAmount},
        #{balanceLogAfterAmount},
        #{balanceLogType},
        #{balanceLogAmount}
        )
    </insert>
    <update id="update" parameterType="BalanceLog" >
        update
        tb_iamberry_channel_balance_log
        <set >
            <if test="balanceLogChannelId != null ">
                balance_log_channel_id = #{balanceLogChannelId},
            </if >
            <if test="balanceLogChannelType != null ">
                balance_log_channel_type = #{balanceLogChannelType},
            </if >
            <if test="balanceLogBeforeAmount != null ">
                balance_log_before_amount = #{balanceLogBeforeAmount},
            </if >
            <if test="balanceLogAfterAmount != null ">
                balance_log_after_amount = #{balanceLogAfterAmount},
            </if >
            <if test="balanceLogType != null ">
                balance_log_type = #{balanceLogType},
            </if >
            <if test="balanceLogAmount != null ">
                balance_log_amount = #{balanceLogAmount},
            </if >
        </set >
        where balance_log_id= #{balanceLogId}
    </update>
</mapper>