<?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.kxs.user.biz.mapper.KxsUserAmountLogMapper">

    <resultMap type="com.kxs.user.api.model.KxsUserAmountLog" id="KxsUserAmountLogMap">
        <result column="id" property="id" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="del_flag" property="delFlag" />
        <result column="version" property="version" />
        <result column="user_id" property="userId" />
        <result column="before_amount" property="beforeAmount" />
        <result column="before_amount" property="beforeAmount" />
        <result column="before_total_amount" property="beforeTotalAmount" />
        <result column="after_amount" property="afterAmount" />
        <result column="after_total_amount" property="afterTotalAmount" />
        <result column="amount" property="amount" />
        <result column="variation_type" property="variationType" />
        <result column="variation_cause" property="variationCause" />
        <result column="kind" property="kind" />
        <result column="remark" property="remark" />
        <result column="brand_id" property="brandId" />

    </resultMap>
    <update id="automaticTableCreationTasks" parameterType="String">
        CREATE  TABLE IF NOT EXISTS `${tableName}` LIKE kxs_user_amount_log;
    </update>
    <select id="getByPage" resultType="com.kxs.user.api.vo.kxsapp.userAccount.UserAmountVariationListVO">
        SELECT * from kxs_user_amount_log
        <where>
            and del_flag = 0
            and user_id = #{query.userId}
            <if test="query.brandId != null">
                and brand_id = #{query.brandId}
            </if>
            <if test="query.kind != null and query.kind != ''">
                and kind = #{query.kind}
            </if>
            <if test="query.variationType != null">
                and variation_type = #{query.variationType}
            </if>
        </where>
    </select>

</mapper>
