<?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.game.business.mapper.FinTranRecordMapper">
    
    <resultMap type="com.game.business.domain.FinTranRecord" id="FinTranRecordResult">
        <result property="id"    column="id"    />
        <result property="afterCoin"    column="after_coin"    />
        <result property="afterMoney"    column="after_money"    />
        <result property="afterTicket"    column="after_ticket"    />
        <result property="afterDiamondCoin"    column="after_diamond_coin"    />
        <result property="agentId"    column="agent_id"    />
        <result property="coinChange"    column="coin_change"    />
        <result property="diamondCoinChange"    column="diamond_coin_change"    />
        <result property="commissionRelatedUid"    column="commission_related_uid"    />
        <result property="consumptionCoin"    column="consumption_coin"    />
        <result property="consumptionMoney"    column="consumption_money"    />
        <result property="createTime"    column="create_time"    />
        <result property="currencyType"    column="currency_type"    />
        <result property="fromUid"    column="from_uid"    />
        <result property="goodsId"    column="goods_id"    />
        <result property="guildId"    column="guild_id"    />
        <result property="managerCoId"    column="manager_co_id"    />
        <result property="managerId"    column="manager_id"    />
        <result property="moneyChange"    column="money_change"    />
        <result property="orderId"    column="order_id"    />
        <result property="perc"    column="perc"    />
        <result property="proCount"    column="pro_count"    />
        <result property="proId"    column="pro_id"    />
        <result property="remarks"    column="remarks"    />
        <result property="sceneId1"    column="scene_id1"    />
        <result property="sceneId2"    column="scene_id2"    />
        <result property="sceneType"    column="scene_type"    />
        <result property="ticketChange"    column="ticket_change"    />
        <result property="toUid"    column="to_uid"    />
        <result property="tranGroupId"    column="tran_group_id"    />
        <result property="tranType1"    column="tran_type1"    />
        <result property="tranType2"    column="tran_type2"    />
        <result property="tranType3"    column="tran_type3"    />
        <result property="uid"    column="uid"    />
    </resultMap>

    <sql id="selectFinTranRecordVo">
        select id, after_coin, after_money, after_ticket, after_diamond_coin, agent_id, coin_change, diamond_coin_change, commission_related_uid, consumption_coin, consumption_money, create_time, currency_type, from_uid, goods_id, guild_id, manager_co_id, manager_id, money_change, order_id, perc, pro_count, pro_id, remarks, scene_id1, scene_id2, scene_type, ticket_change, to_uid, tran_group_id, tran_type1, tran_type2, tran_type3, uid from fin_tran_record
    </sql>

    <select id="selectFinTranRecordList" parameterType="com.game.business.domain.FinTranRecord" resultMap="FinTranRecordResult">
        <include refid="selectFinTranRecordVo"/>
        <where>  
            <if test="afterCoin != null "> and after_coin = #{afterCoin}</if>
            <if test="afterMoney != null "> and after_money = #{afterMoney}</if>
            <if test="afterTicket != null "> and after_ticket = #{afterTicket}</if>
            <if test="afterDiamondCoin != null "> and after_diamond_coin = #{afterDiamondCoin}</if>
            <if test="agentId != null "> and agent_id = #{agentId}</if>
            <if test="coinChange != null "> and coin_change = #{coinChange}</if>
            <if test="diamondCoinChange != null "> and diamond_coin_change = #{diamondCoinChange}</if>
            <if test="commissionRelatedUid != null "> and commission_related_uid = #{commissionRelatedUid}</if>
            <if test="consumptionCoin != null "> and consumption_coin = #{consumptionCoin}</if>
            <if test="consumptionMoney != null "> and consumption_money = #{consumptionMoney}</if>
            <if test="currencyType != null "> and currency_type = #{currencyType}</if>
            <if test="fromUid != null "> and from_uid = #{fromUid}</if>
            <if test="goodsId != null "> and goods_id = #{goodsId}</if>
            <if test="guildId != null "> and guild_id = #{guildId}</if>
            <if test="managerCoId != null "> and manager_co_id = #{managerCoId}</if>
            <if test="managerId != null "> and manager_id = #{managerId}</if>
            <if test="moneyChange != null "> and money_change = #{moneyChange}</if>
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="perc != null "> and perc = #{perc}</if>
            <if test="proCount != null "> and pro_count = #{proCount}</if>
            <if test="proId != null "> and pro_id = #{proId}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="sceneId1 != null "> and scene_id1 = #{sceneId1}</if>
            <if test="sceneId2 != null  and sceneId2 != ''"> and scene_id2 = #{sceneId2}</if>
            <if test="sceneType != null "> and scene_type = #{sceneType}</if>
            <if test="ticketChange != null "> and ticket_change = #{ticketChange}</if>
            <if test="toUid != null "> and to_uid = #{toUid}</if>
            <if test="tranGroupId != null "> and tran_group_id = #{tranGroupId}</if>
            <if test="tranType1 != null "> and tran_type1 = #{tranType1}</if>
            <if test="tranType2 != null "> and tran_type2 = #{tranType2}</if>
            <if test="tranType3 != null "> and tran_type3 = #{tranType3}</if>
            <if test="uid != null "> and uid = #{uid}</if>
        </where>
    </select>
    
    <select id="selectFinTranRecordById" parameterType="Long" resultMap="FinTranRecordResult">
        <include refid="selectFinTranRecordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFinTranRecord" parameterType="com.game.business.domain.FinTranRecord">
        insert into fin_tran_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="afterCoin != null">after_coin,</if>
            <if test="afterMoney != null">after_money,</if>
            <if test="afterTicket != null">after_ticket,</if>
            <if test="afterDiamondCoin != null">after_diamond_coin,</if>
            <if test="agentId != null">agent_id,</if>
            <if test="coinChange != null">coin_change,</if>
            <if test="diamondCoinChange != null">diamond_coin_change,</if>
            <if test="commissionRelatedUid != null">commission_related_uid,</if>
            <if test="consumptionCoin != null">consumption_coin,</if>
            <if test="consumptionMoney != null">consumption_money,</if>
            <if test="createTime != null">create_time,</if>
            <if test="currencyType != null">currency_type,</if>
            <if test="fromUid != null">from_uid,</if>
            <if test="goodsId != null">goods_id,</if>
            <if test="guildId != null">guild_id,</if>
            <if test="managerCoId != null">manager_co_id,</if>
            <if test="managerId != null">manager_id,</if>
            <if test="moneyChange != null">money_change,</if>
            <if test="orderId != null">order_id,</if>
            <if test="perc != null">perc,</if>
            <if test="proCount != null">pro_count,</if>
            <if test="proId != null">pro_id,</if>
            <if test="remarks != null">remarks,</if>
            <if test="sceneId1 != null">scene_id1,</if>
            <if test="sceneId2 != null">scene_id2,</if>
            <if test="sceneType != null">scene_type,</if>
            <if test="ticketChange != null">ticket_change,</if>
            <if test="toUid != null">to_uid,</if>
            <if test="tranGroupId != null">tran_group_id,</if>
            <if test="tranType1 != null">tran_type1,</if>
            <if test="tranType2 != null">tran_type2,</if>
            <if test="tranType3 != null">tran_type3,</if>
            <if test="uid != null">uid,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="afterCoin != null">#{afterCoin},</if>
            <if test="afterMoney != null">#{afterMoney},</if>
            <if test="afterTicket != null">#{afterTicket},</if>
            <if test="afterDiamondCoin != null">#{afterDiamondCoin},</if>
            <if test="agentId != null">#{agentId},</if>
            <if test="coinChange != null">#{coinChange},</if>
            <if test="diamondCoinChange != null">#{diamondCoinChange},</if>
            <if test="commissionRelatedUid != null">#{commissionRelatedUid},</if>
            <if test="consumptionCoin != null">#{consumptionCoin},</if>
            <if test="consumptionMoney != null">#{consumptionMoney},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="currencyType != null">#{currencyType},</if>
            <if test="fromUid != null">#{fromUid},</if>
            <if test="goodsId != null">#{goodsId},</if>
            <if test="guildId != null">#{guildId},</if>
            <if test="managerCoId != null">#{managerCoId},</if>
            <if test="managerId != null">#{managerId},</if>
            <if test="moneyChange != null">#{moneyChange},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="perc != null">#{perc},</if>
            <if test="proCount != null">#{proCount},</if>
            <if test="proId != null">#{proId},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="sceneId1 != null">#{sceneId1},</if>
            <if test="sceneId2 != null">#{sceneId2},</if>
            <if test="sceneType != null">#{sceneType},</if>
            <if test="ticketChange != null">#{ticketChange},</if>
            <if test="toUid != null">#{toUid},</if>
            <if test="tranGroupId != null">#{tranGroupId},</if>
            <if test="tranType1 != null">#{tranType1},</if>
            <if test="tranType2 != null">#{tranType2},</if>
            <if test="tranType3 != null">#{tranType3},</if>
            <if test="uid != null">#{uid},</if>
         </trim>
    </insert>

    <update id="updateFinTranRecord" parameterType="com.game.business.domain.FinTranRecord">
        update fin_tran_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="afterCoin != null">after_coin = #{afterCoin},</if>
            <if test="afterMoney != null">after_money = #{afterMoney},</if>
            <if test="afterTicket != null">after_ticket = #{afterTicket},</if>
            <if test="afterDiamondCoin != null">after_diamond_coin = #{afterDiamondCoin},</if>
            <if test="agentId != null">agent_id = #{agentId},</if>
            <if test="coinChange != null">coin_change = #{coinChange},</if>
            <if test="diamondCoinChange != null">diamond_coin_change = #{diamondCoinChange},</if>
            <if test="commissionRelatedUid != null">commission_related_uid = #{commissionRelatedUid},</if>
            <if test="consumptionCoin != null">consumption_coin = #{consumptionCoin},</if>
            <if test="consumptionMoney != null">consumption_money = #{consumptionMoney},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="currencyType != null">currency_type = #{currencyType},</if>
            <if test="fromUid != null">from_uid = #{fromUid},</if>
            <if test="goodsId != null">goods_id = #{goodsId},</if>
            <if test="guildId != null">guild_id = #{guildId},</if>
            <if test="managerCoId != null">manager_co_id = #{managerCoId},</if>
            <if test="managerId != null">manager_id = #{managerId},</if>
            <if test="moneyChange != null">money_change = #{moneyChange},</if>
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="perc != null">perc = #{perc},</if>
            <if test="proCount != null">pro_count = #{proCount},</if>
            <if test="proId != null">pro_id = #{proId},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="sceneId1 != null">scene_id1 = #{sceneId1},</if>
            <if test="sceneId2 != null">scene_id2 = #{sceneId2},</if>
            <if test="sceneType != null">scene_type = #{sceneType},</if>
            <if test="ticketChange != null">ticket_change = #{ticketChange},</if>
            <if test="toUid != null">to_uid = #{toUid},</if>
            <if test="tranGroupId != null">tran_group_id = #{tranGroupId},</if>
            <if test="tranType1 != null">tran_type1 = #{tranType1},</if>
            <if test="tranType2 != null">tran_type2 = #{tranType2},</if>
            <if test="tranType3 != null">tran_type3 = #{tranType3},</if>
            <if test="uid != null">uid = #{uid},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFinTranRecordById" parameterType="Long">
        delete from fin_tran_record where id = #{id}
    </delete>

    <delete id="deleteFinTranRecordByIds" parameterType="String">
        delete from fin_tran_record where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>