<?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.system.mapper.PayMoneyLogMapper">
    
    <resultMap type="PayMoneyLog" id="PayMoneyLogResult">
        <result property="id"    column="id"    />
        <result property="oid"    column="oid"    />
        <result property="orderId"    column="order_id"    />
        <result property="uid"    column="uid"    />
        <result property="price"    column="price"    />
        <result property="mark"    column="mark"    />
        <result property="payTime"    column="pay_time"    />
        <result property="createdAt"    column="created_at"    />
        <result property="updatedAt"    column="updated_at"    />
    </resultMap>

    <sql id="selectPayMoneyLogVo">
        select id, oid, order_id, uid, price, mark, pay_time, created_at, updated_at from pay_money_log
    </sql>

    <select id="selectPayMoneyLogList" parameterType="PayMoneyLog" resultMap="PayMoneyLogResult">
        <include refid="selectPayMoneyLogVo"/>
        <where>  

            <if test="orderId != null  and orderId != ''"> and order_id like concat('%',#{orderId},'%')</if>
            <if test="uid != null "> and uid = #{uid}</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="mark != null  and mark != ''"> and mark = #{mark}</if>
            <if test="payTime != null "> and pay_time = #{payTime}</if>
        </where>
    </select>
    
    <select id="selectPayMoneyLogById" parameterType="Long" resultMap="PayMoneyLogResult">
        <include refid="selectPayMoneyLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertPayMoneyLog" parameterType="PayMoneyLog" useGeneratedKeys="true" keyProperty="id">
        insert into pay_money_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="oid != null">oid,</if>
            <if test="orderId != null and orderId != ''">order_id,</if>
            <if test="uid != null">uid,</if>
            <if test="price != null">price,</if>
            <if test="mark != null and mark != ''">mark,</if>
            <if test="payTime != null">pay_time,</if>
            <if test="createdAt != null">created_at,</if>
            <if test="updatedAt != null">updated_at,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="oid != null">#{oid},</if>
            <if test="orderId != null and orderId != ''">#{orderId},</if>
            <if test="uid != null">#{uid},</if>
            <if test="price != null">#{price},</if>
            <if test="mark != null and mark != ''">#{mark},</if>
            <if test="payTime != null">#{payTime},</if>
            <if test="createdAt != null">#{createdAt},</if>
            <if test="updatedAt != null">#{updatedAt},</if>
         </trim>
    </insert>

    <update id="updatePayMoneyLog" parameterType="PayMoneyLog">
        update pay_money_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="oid != null">oid = #{oid},</if>
            <if test="orderId != null and orderId != ''">order_id = #{orderId},</if>
            <if test="uid != null">uid = #{uid},</if>
            <if test="price != null">price = #{price},</if>
            <if test="mark != null and mark != ''">mark = #{mark},</if>
            <if test="payTime != null">pay_time = #{payTime},</if>
            <if test="createdAt != null">created_at = #{createdAt},</if>
            <if test="updatedAt != null">updated_at = #{updatedAt},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePayMoneyLogById" parameterType="Long">
        delete from pay_money_log where id = #{id}
    </delete>

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