<?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.ghy.payment.mapper.OrderFineRecordMapper">

    <resultMap id="OrderFineRecordResult" type="com.ghy.payment.domain.OrderFineRecord">
        <id property="id"                   column="id"/>
        <result property="orderDetailId"    column="order_detail_id"/>
        <result property="fineType"         column="fine_type"/>
        <result property="orderStatus"      column="order_status"/>
        <result property="createTime"       column="create_time"/>
    </resultMap>

    <sql id="selectOrderFineRecord">
        SELECT id, order_detail_id, fine_type, order_status, create_time
        FROM order_fine_record
    </sql>

    <select id="selectList" parameterType="com.ghy.payment.domain.OrderFineRecord"
            resultMap="OrderFineRecordResult">
        <include refid="selectOrderFineRecord"/>
        <where>
            <if test="orderDetailId != null">
                AND order_detail_id = #{orderDetailId}
            </if>
            <if test="orderStatus != null">
                AND order_status = #{orderStatus}
            </if>
        </where>
    </select>

    <insert id="insert" parameterType="com.ghy.payment.domain.OrderFineRecord" useGeneratedKeys="true"
            keyProperty="id">
        INSERT INTO order_fine_record (order_detail_id, fine_type, order_status)
        VALUES (#{orderDetailId}, #{fineType}, #{orderStatus})
    </insert>
</mapper>