<?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="cn.superdesk.uniorder.dao.mapper.thirdpart.szhtxx.electronicInvoice.SzhtxxElectronicInvoiceFptxxXmxxMapperEx">

    <!-- cn.superdesk.uniorder.dao.entity.base.UnifiedOrderGoods -->
    <insert id="insertBatch" parameterType="java.util.List">
        <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
            SELECT LAST_INSERT_ID()
        </selectKey>
        insert into szhtxx_electronic_invoice_fptxx_xmxx (
        fpqqlsh,
        xmmc,
        xmdw,
        ggxh,
        xmsl,
        hsbz,
        xmdj,
        fphxz,
        spbm,
        yhzcbs,
        lslbs,
        zzstsgl,
        kce,
        xmje,
        sl,
        se,
        deleted,
        batch_id
        )
        values
        <foreach collection="list" item="item" index="index" separator=",">
        (
        #{item.fpqqlsh,jdbcType=VARCHAR},
        #{item.xmmc,jdbcType=VARCHAR},
        #{item.xmdw,jdbcType=VARCHAR},
        #{item.ggxh,jdbcType=VARCHAR},
        #{item.xmsl,jdbcType=DECIMAL},
        #{item.hsbz,jdbcType=VARCHAR},
        #{item.xmdj,jdbcType=DECIMAL},
        #{item.fphxz,jdbcType=CHAR},
        #{item.spbm,jdbcType=VARCHAR},
        #{item.yhzcbs,jdbcType=VARCHAR},
        #{item.lslbs,jdbcType=VARCHAR},
        #{item.zzstsgl,jdbcType=VARCHAR},
        #{item.kce,jdbcType=DECIMAL},
        #{item.xmje,jdbcType=DECIMAL},
        #{item.sl,jdbcType=VARCHAR},
        #{item.se,jdbcType=DECIMAL},
        #{item.deleted,jdbcType=TINYINT},
        #{item.batchId,jdbcType=VARCHAR}
        )
        </foreach>
    </insert>

    <resultMap id="SzhtxxElectronicInvoiceFptxxXmxxListItemVoResultMap"
               type="cn.superdesk.uniorder.dto.vo.thirdpart.szhtxx.electronicInvoice.SzhtxxElectronicInvoiceFptxxXmxxListItemVo">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="fpqqlsh" jdbcType="VARCHAR" property="fpqqlsh"/>
        <result column="xmmc" jdbcType="VARCHAR" property="xmmc"/>
        <result column="xmdw" jdbcType="VARCHAR" property="xmdw"/>
        <result column="ggxh" jdbcType="VARCHAR" property="ggxh"/>
        <result column="xmsl" jdbcType="DECIMAL" property="xmsl"/>
        <result column="hsbz" jdbcType="VARCHAR" property="hsbz"/>
        <result column="xmdj" jdbcType="DECIMAL" property="xmdj"/>
        <result column="fphxz" jdbcType="CHAR" property="fphxz"/>
        <result column="spbm" jdbcType="VARCHAR" property="spbm"/>
        <result column="yhzcbs" jdbcType="VARCHAR" property="yhzcbs"/>
        <result column="lslbs" jdbcType="VARCHAR" property="lslbs"/>
        <result column="zzstsgl" jdbcType="VARCHAR" property="zzstsgl"/>
        <result column="kce" jdbcType="DECIMAL" property="kce"/>
        <result column="xmje" jdbcType="DECIMAL" property="xmje"/>
        <result column="sl" jdbcType="VARCHAR" property="sl"/>
        <result column="se" jdbcType="DECIMAL" property="se"/>
    </resultMap>


    <select id="queryGenericParam" resultMap="SzhtxxElectronicInvoiceFptxxXmxxListItemVoResultMap">
        select
            szhteifx.id,
            szhteifx.fpqqlsh,
            szhteifx.xmmc,
            szhteifx.xmdw,
            szhteifx.ggxh,
            szhteifx.xmsl,
            szhteifx.hsbz,
            szhteifx.xmdj,
            szhteifx.fphxz,
            szhteifx.spbm,
            szhteifx.yhzcbs,
            szhteifx.lslbs,
            szhteifx.zzstsgl,
            szhteifx.kce,
            szhteifx.xmje,
            szhteifx.sl,
            szhteifx.se
        from
            szhtxx_electronic_invoice_fptxx_xmxx szhteifx
        <where>
            and szhteifx.deleted = 0
        <if test="fpqqlsh != null and fpqqlsh != ''">
            and szhteifx.fpqqlsh = #{fpqqlsh,jdbcType=VARCHAR}
        </if>
        </where>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
    </select>
</mapper>
