<?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.yiqi.order.mapper.OrderPayInfoMapper">

    <resultMap type="OrderPayInfo" id="OrderPayInfoResult">
        <result property="id" column="id"/>
        <result property="orderNo" column="order_no"/>
        <result property="payOrderNo" column="pay_order_no"/>
        <result property="payAmount" column="pay_amount"/>
        <result property="payMno" column="pay_mno"/>
        <result property="payType" column="pay_type"/>
        <result property="payStatus" column="pay_status"/>
        <result property="msg" column="msg"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <sql id="selectOrderPayInfoVo">
        select id, order_no, pay_order_no, pay_amount, pay_mno, pay_type, pay_status, msg, create_time
        from order_pay_info
    </sql>

    <select id="selectOrderPayInfoList" parameterType="OrderPayInfo" resultMap="OrderPayInfoResult">
        <include refid="selectOrderPayInfoVo"/>
        <where>
            <if test="orderNo != null  and orderNo != ''">
                and order_no = #{orderNo}
            </if>
            <if test="payOrderNo != null  and payOrderNo != ''">
                and pay_order_no = #{payOrderNo}
            </if>
            <if test="payAmount != null ">
                and pay_amount = #{payAmount}
            </if>
            <if test="payMno != null  and payMno != ''">
                and pay_mno = #{payMno}
            </if>
            <if test="payType != null  and payType != ''">
                and pay_type = #{payType}
            </if>
            <if test="payStatus != null  and payStatus != ''">
                and pay_status = #{payStatus}
            </if>
            <if test="msg != null  and msg != ''">
                and msg = #{msg}
            </if>
        </where>
    </select>

    <select id="selectOrderPayInfoById" parameterType="Long"
            resultMap="OrderPayInfoResult">
        <include refid="selectOrderPayInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertOrderPayInfo" parameterType="OrderPayInfo" useGeneratedKeys="true"
            keyProperty="id">
        insert into order_pay_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderNo != null">order_no,
            </if>
            <if test="payOrderNo != null">pay_order_no,
            </if>
            <if test="payAmount != null">pay_amount,
            </if>
            <if test="payMno != null">pay_mno,
            </if>
            <if test="payType != null">pay_type,
            </if>
            <if test="payStatus != null">pay_status,
            </if>
            <if test="msg != null">msg,
            </if>
            <if test="createTime != null">create_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderNo != null">#{orderNo},
            </if>
            <if test="payOrderNo != null">#{payOrderNo},
            </if>
            <if test="payAmount != null">#{payAmount},
            </if>
            <if test="payMno != null">#{payMno},
            </if>
            <if test="payType != null">#{payType},
            </if>
            <if test="payStatus != null">#{payStatus},
            </if>
            <if test="msg != null">#{msg},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
        </trim>
    </insert>

    <update id="updateOrderPayInfo" parameterType="OrderPayInfo">
        update order_pay_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderNo != null">order_no =
                #{orderNo},
            </if>
            <if test="payOrderNo != null">pay_order_no =
                #{payOrderNo},
            </if>
            <if test="payAmount != null">pay_amount =
                #{payAmount},
            </if>
            <if test="payMno != null">pay_mno =
                #{payMno},
            </if>
            <if test="payType != null">pay_type =
                #{payType},
            </if>
            <if test="payStatus != null">pay_status =
                #{payStatus},
            </if>
            <if test="msg != null">msg =
                #{msg},
            </if>
            <if test="createTime != null">create_time =
                #{createTime},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderPayInfoById" parameterType="Long">
        delete from order_pay_info where id = #{id}
    </delete>

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



</mapper>