<?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.ruoyi.mall.mapper.MallMemberMoneyRecordMapper">
    
    <resultMap type="MallMemberMoneyRecord" id="MallMemberMoneyRecordResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="money"    column="money"    />
        <result property="status"    column="status"    />
        <result property="type"    column="type"    />
        <result property="resId"    column="res_id"    />
        <result property="createAt"    column="create_at"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectMallMemberMoneyRecordVo">
        select id, user_id, money, status, type, res_id, create_at, del_flag from mall_member_money_record
    </sql>

    <select id="selectMallMemberMoneyRecordList" parameterType="MallMemberMoneyRecord" resultMap="MallMemberMoneyRecordResult">
        <include refid="selectMallMemberMoneyRecordVo"/>
        <where>  
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
        </where>
    </select>
    
    <select id="selectMallMemberMoneyRecordById" parameterType="Long" resultMap="MallMemberMoneyRecordResult">
        <include refid="selectMallMemberMoneyRecordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertMallMemberMoneyRecord" parameterType="MallMemberMoneyRecord" useGeneratedKeys="true" keyProperty="id">
        insert into mall_member_money_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="money != null">money,</if>
            <if test="status != null">status,</if>
            <if test="type != null">type,</if>
            <if test="resId != null">res_id,</if>
            <if test="createAt != null">create_at,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="money != null">#{money},</if>
            <if test="status != null">#{status},</if>
            <if test="type != null">#{type},</if>
            <if test="resId != null">#{resId},</if>
            <if test="createAt != null">#{createAt},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateMallMemberMoneyRecord" parameterType="MallMemberMoneyRecord">
        update mall_member_money_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="money != null">money = #{money},</if>
            <if test="status != null">status = #{status},</if>
            <if test="type != null">type = #{type},</if>
            <if test="resId != null">res_id = #{resId},</if>
            <if test="createAt != null">create_at = #{createAt},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMallMemberMoneyRecordById" parameterType="Long">
        delete from mall_member_money_record where id = #{id}
    </delete>

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