<?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.platform.mapper.InvoiceDeliveryMapper">
    
    <resultMap type="InvoiceDelivery" id="InvoiceDeliveryResult">
        <result property="id"    column="id"    />
        <result property="bsrysfzjhm"    column="bsrysfzjhm"    />
        <result property="dqbm"    column="dqbm"    />
        <result property="jflx"    column="jflx"    />
        <result property="fphm"    column="fphm"    />
        <result property="gmflxdh"    column="gmflxdh"    />
        <result property="gmfyx"    column="gmfyx"    />
        <result property="nsrsbh"    column="nsrsbh"    />
        <result property="status"    column="status"    />
        <result property="type"    column="type"    />
        <result property="clerk"    column="clerk"    />
        <result property="createTime"    column="create_time"    />
        <result property="remark"    column="remark"    />
        <result property="source"    column="source"    />
    </resultMap>

    <sql id="selectInvoiceDeliveryVo">
        select id, bsrysfzjhm, dqbm, jflx, fphm, gmflxdh, gmfyx, nsrsbh, status, type, clerk, create_time, remark, source from invoice_delivery
    </sql>

    <select id="selectInvoiceDeliveryList" parameterType="InvoiceDelivery" resultMap="InvoiceDeliveryResult">
        <include refid="selectInvoiceDeliveryVo"/>
        <where>  
            <if test="bsrysfzjhm != null  and bsrysfzjhm != ''"> and bsrysfzjhm = #{bsrysfzjhm}</if>
            <if test="dqbm != null  and dqbm != ''"> and dqbm = #{dqbm}</if>
            <if test="jflx != null  and jflx != ''"> and jflx = #{jflx}</if>
            <if test="fphm != null  and fphm != ''"> and fphm = #{fphm}</if>
            <if test="gmflxdh != null  and gmflxdh != ''"> and gmflxdh = #{gmflxdh}</if>
            <if test="gmfyx != null  and gmfyx != ''"> and gmfyx = #{gmfyx}</if>
            <if test="nsrsbh != null  and nsrsbh != ''"> and nsrsbh = #{nsrsbh}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="clerk != null "> and clerk = #{clerk}</if>
            <if test="source != null  and source != ''"> and source = #{source}</if>
        </where>
    </select>
    
    <select id="selectInvoiceDeliveryById" parameterType="Long" resultMap="InvoiceDeliveryResult">
        <include refid="selectInvoiceDeliveryVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertInvoiceDelivery" parameterType="InvoiceDelivery" useGeneratedKeys="true" keyProperty="id">
        insert into invoice_delivery
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="bsrysfzjhm != null and bsrysfzjhm != ''">bsrysfzjhm,</if>
            <if test="dqbm != null and dqbm != ''">dqbm,</if>
            <if test="jflx != null and jflx != ''">jflx,</if>
            <if test="fphm != null and fphm != ''">fphm,</if>
            <if test="gmflxdh != null and gmflxdh != ''">gmflxdh,</if>
            <if test="gmfyx != null and gmfyx != ''">gmfyx,</if>
            <if test="nsrsbh != null and nsrsbh != ''">nsrsbh,</if>
            <if test="status != null and status != ''">status,</if>
            <if test="type != null">type,</if>
            <if test="clerk != null">clerk,</if>
            <if test="createTime != null">create_time,</if>
            <if test="remark != null">remark,</if>
            <if test="source != null and source != ''">source,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="bsrysfzjhm != null and bsrysfzjhm != ''">#{bsrysfzjhm},</if>
            <if test="dqbm != null and dqbm != ''">#{dqbm},</if>
            <if test="jflx != null and jflx != ''">#{jflx},</if>
            <if test="fphm != null and fphm != ''">#{fphm},</if>
            <if test="gmflxdh != null and gmflxdh != ''">#{gmflxdh},</if>
            <if test="gmfyx != null and gmfyx != ''">#{gmfyx},</if>
            <if test="nsrsbh != null and nsrsbh != ''">#{nsrsbh},</if>
            <if test="status != null and status != ''">#{status},</if>
            <if test="type != null">#{type},</if>
            <if test="clerk != null">#{clerk},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="source != null and source != ''">#{source},</if>
         </trim>
    </insert>

    <update id="updateInvoiceDelivery" parameterType="InvoiceDelivery">
        update invoice_delivery
        <trim prefix="SET" suffixOverrides=",">
            <if test="bsrysfzjhm != null and bsrysfzjhm != ''">bsrysfzjhm = #{bsrysfzjhm},</if>
            <if test="dqbm != null and dqbm != ''">dqbm = #{dqbm},</if>
            <if test="jflx != null and jflx != ''">jflx = #{jflx},</if>
            <if test="fphm != null and fphm != ''">fphm = #{fphm},</if>
            <if test="gmflxdh != null and gmflxdh != ''">gmflxdh = #{gmflxdh},</if>
            <if test="gmfyx != null and gmfyx != ''">gmfyx = #{gmfyx},</if>
            <if test="nsrsbh != null and nsrsbh != ''">nsrsbh = #{nsrsbh},</if>
            <if test="status != null and status != ''">status = #{status},</if>
            <if test="type != null">type = #{type},</if>
            <if test="clerk != null">clerk = #{clerk},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="source != null and source != ''">source = #{source},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteInvoiceDeliveryById" parameterType="Long">
        delete from invoice_delivery where id = #{id}
    </delete>

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