<?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.ff.game.mapper.GameExchangeMoneyMapper">

    <resultMap type="GameExchangeMoney" id="GameExchangeMoneyResult">
        <result property="id"    column="id"    />
        <result property="tenantKey"    column="tenant_key"    />
        <result property="currencyCode"    column="currency_code"    />
        <result property="transactionId"    column="transaction_id"    />
        <result property="memberId"    column="member_id"    />
        <result property="platformCode"    column="platform_code"    />
        <result property="balance"    column="balance"    />
        <result property="quota"    column="quota"    />
        <result property="coinBefore"    column="coin_before"    />
        <result property="coinAfter"    column="coin_after"    />
        <result property="currencyBefore"    column="currency_before"    />
        <result property="currencyAfter"    column="currency_after"    />
        <result property="orderId"    column="order_id"    />
        <result property="exchangeType"    column="exchange_type"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectGameExchangeMoneyVo">
        select id, tenant_key, currency_code, transaction_id, member_id, platform_code, balance, quota, coin_before, coin_after, currency_before, currency_after, order_id, exchange_type, status, create_by, create_time, update_by, update_time from ff_game_exchange_money
    </sql>

    <select id="selectGameExchangeMoneyList" parameterType="GameExchangeMoney" resultMap="GameExchangeMoneyResult">
        <include refid="selectGameExchangeMoneyVo"/>
        <where>
            <if test="tenantKey != null  and tenantKey != ''"> and tenant_key = #{tenantKey}</if>
            <if test="currencyCode != null  and currencyCode != ''"> and currency_code = #{currencyCode}</if>
            <if test="transactionId != null  and transactionId != ''"> and transaction_id = #{transactionId}</if>
            <if test="memberId != null "> and member_id = #{memberId}</if>
            <if test="platformCode != null  and platformCode != ''"> and platform_code = #{platformCode}</if>
            <if test="balance != null "> and balance = #{balance}</if>
            <if test="quota != null "> and quota = #{quota}</if>
            <if test="coinBefore != null "> and coin_before = #{coinBefore}</if>
            <if test="coinAfter != null "> and coin_after = #{coinAfter}</if>
            <if test="currencyBefore != null "> and currency_before = #{currencyBefore}</if>
            <if test="currencyAfter != null "> and currency_after = #{currencyAfter}</if>
            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
            <if test="exchangeType != null "> and exchange_type = #{exchangeType}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>

    <select id="selectGameExchangeMoneyById" parameterType="Long" resultMap="GameExchangeMoneyResult">
        <include refid="selectGameExchangeMoneyVo"/>
        where id = #{id}
    </select>

    <insert id="insertGameExchangeMoney" parameterType="GameExchangeMoney" useGeneratedKeys="true" keyProperty="id">
        insert into ff_game_exchange_money
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tenantKey != null">tenant_key,</if>
            <if test="currencyCode != null">currency_code,</if>
            <if test="transactionId != null">transaction_id,</if>
            <if test="memberId != null">member_id,</if>
            <if test="platformCode != null">platform_code,</if>
            <if test="balance != null">balance,</if>
            <if test="quota != null">quota,</if>
            <if test="coinBefore != null">coin_before,</if>
            <if test="coinAfter != null">coin_after,</if>
            <if test="currencyBefore != null">currency_before,</if>
            <if test="currencyAfter != null">currency_after,</if>
            <if test="orderId != null">order_id,</if>
            <if test="exchangeType != null">exchange_type,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tenantKey != null">#{tenantKey},</if>
            <if test="currencyCode != null">#{currencyCode},</if>
            <if test="transactionId != null">#{transactionId},</if>
            <if test="memberId != null">#{memberId},</if>
            <if test="platformCode != null">#{platformCode},</if>
            <if test="balance != null">#{balance},</if>
            <if test="quota != null">#{quota},</if>
            <if test="coinBefore != null">#{coinBefore},</if>
            <if test="coinAfter != null">#{coinAfter},</if>
            <if test="currencyBefore != null">#{currencyBefore},</if>
            <if test="currencyAfter != null">#{currencyAfter},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="exchangeType != null">#{exchangeType},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateGameExchangeMoney" parameterType="GameExchangeMoney">
        update ff_game_exchange_money
        <trim prefix="SET" suffixOverrides=",">
            <if test="tenantKey != null">tenant_key = #{tenantKey},</if>
            <if test="currencyCode != null">currency_code = #{currencyCode},</if>
            <if test="transactionId != null">transaction_id = #{transactionId},</if>
            <if test="memberId != null">member_id = #{memberId},</if>
            <if test="platformCode != null">platform_code = #{platformCode},</if>
            <if test="balance != null">balance = #{balance},</if>
            <if test="quota != null">quota = #{quota},</if>
            <if test="coinBefore != null">coin_before = #{coinBefore},</if>
            <if test="coinAfter != null">coin_after = #{coinAfter},</if>
            <if test="currencyBefore != null">currency_before = #{currencyBefore},</if>
            <if test="currencyAfter != null">currency_after = #{currencyAfter},</if>
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="exchangeType != null">exchange_type = #{exchangeType},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteGameExchangeMoneyById" parameterType="Long">
        delete from ff_game_exchange_money where id = #{id}
    </delete>

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