<?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.jianshui.invoice.mapper.InvoiceBackMapper">
    
    <resultMap type="com.jianshui.invoice.domain.InvoiceBack" id="InvoiceBackResult">
        <result property="id"    column="id"    />
        <result property="systemOrderno"    column="system_orderno"    />
        <result property="status"    column="status"    />
        <result property="backUrl"    column="back_url"    />
        <result property="identity"    column="identity"    />
        <result property="createTime"    column="create_time"    />
        <result property="backMsg"    column="back_msg"    />
        <result property="resultMsg"    column="result_msg"    />
        <result property="resultCode"    column="result_code"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectInvoiceBackVo">
        select id, system_orderno, status, back_url, identity, create_time, back_msg,result_msg,result_code,update_time from invoice_back
    </sql>

    <select id="selectInvoiceBackList" parameterType="com.jianshui.invoice.domain.InvoiceBack" resultMap="InvoiceBackResult">
        <include refid="selectInvoiceBackVo"/>
        <where>  
            <if test="systemOrderno != null  and systemOrderno != ''"> and system_orderno = #{systemOrderno}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="backUrl != null  and backUrl != ''"> and back_url = #{backUrl}</if>
            <if test="identity != null  and identity != ''"> and identity = #{identity}</if>
            <if test="backMsg != null  and backMsg != ''"> and back_msg = #{backMsg}</if>
            <if test="resultMsg != null  and resultMsg != ''"> and result_msg = #{resultMsg}</if>
            <if test="resultCode != null  and resultCode != ''"> and result_code = #{resultCode}</if>
            <if test="updateTime != null  and updateTime != ''"> and update_time = #{updateTime}</if>
        </where>
    </select>
    
    <select id="selectInvoiceBackById" parameterType="String" resultMap="InvoiceBackResult">
        <include refid="selectInvoiceBackVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertInvoiceBack" parameterType="com.jianshui.invoice.domain.InvoiceBack">
        insert into invoice_back
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="systemOrderno != null">system_orderno,</if>
            <if test="status != null">status,</if>
            <if test="backUrl != null">back_url,</if>
            <if test="identity != null">identity,</if>
            <if test="createTime != null">create_time,</if>
            <if test="backMsg != null">back_msg,</if>
            <if test="resultMsg != null">result_msg,</if>
            <if test="resultCode != null">result_code,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="systemOrderno != null">#{systemOrderno},</if>
            <if test="status != null">#{status},</if>
            <if test="backUrl != null">#{backUrl},</if>
            <if test="identity != null">#{identity},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="backMsg != null">#{backMsg},</if>
            <if test="resultMsg != null">#{resultMsg},</if>
            <if test="resultCode != null">#{resultCode},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateInvoiceBack" parameterType="com.jianshui.invoice.domain.InvoiceBack">
        update invoice_back
        <trim prefix="SET" suffixOverrides=",">
            <if test="systemOrderno != null">system_orderno = #{systemOrderno},</if>
            <if test="status != null">status = #{status},</if>
            <if test="backUrl != null">back_url = #{backUrl},</if>
            <if test="identity != null">identity = #{identity},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="backMsg != null">back_msg = #{backMsg},</if>
            <if test="resultMsg != null">result_msg = #{resultMsg},</if>
            <if test="resultCode != null">result_code = #{resultCode},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteInvoiceBackById" parameterType="String">
        delete from invoice_back where id = #{id}
    </delete>

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