<?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.MallPayLogMapper">
    
    <resultMap type="MallPayLog" id="MallPayLogResult">
        <result property="id"    column="id"    />
        <result property="outTradeNo"    column="out_trade_no"    />
        <result property="status"    column="status"    />
        <result property="resId"    column="res_id"    />
        <result property="type"    column="type"    />
        <result property="userId"    column="user_id"    />
        <result property="price"    column="price"    />
        <result property="createAt"    column="create_at"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectMallPayLogVo">
        select id, out_trade_no, status, res_id, type, user_id, price, create_at, del_flag from mall_pay_log
    </sql>

    <select id="selectMallPayLogList" parameterType="MallPayLog" resultMap="MallPayLogResult">
        <include refid="selectMallPayLogVo"/>
        <where>  
            <if test="outTradeNo != null  and outTradeNo != ''"> and out_trade_no = #{outTradeNo}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectMallPayLogById" parameterType="String" resultMap="MallPayLogResult">
        <include refid="selectMallPayLogVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertMallPayLog" parameterType="MallPayLog">
        insert into mall_pay_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="outTradeNo != null">out_trade_no,</if>
            <if test="status != null">status,</if>
            <if test="resId != null">res_id,</if>
            <if test="type != null">type,</if>
            <if test="userId != null">user_id,</if>
            <if test="price != null">price,</if>
            <if test="createAt != null">create_at,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="outTradeNo != null">#{outTradeNo},</if>
            <if test="status != null">#{status},</if>
            <if test="resId != null">#{resId},</if>
            <if test="type != null">#{type},</if>
            <if test="userId != null">#{userId},</if>
            <if test="price != null">#{price},</if>
            <if test="createAt != null">#{createAt},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateMallPayLog" parameterType="MallPayLog">
        update mall_pay_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="outTradeNo != null">out_trade_no = #{outTradeNo},</if>
            <if test="status != null">status = #{status},</if>
            <if test="resId != null">res_id = #{resId},</if>
            <if test="type != null">type = #{type},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="price != null">price = #{price},</if>
            <if test="createAt != null">create_at = #{createAt},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMallPayLogById" parameterType="String">
        delete from mall_pay_log where id = #{id}
    </delete>

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