<?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.dxhy.core.dao.InvoiceDetailDao">

    <resultMap id="BaseResultInvoiceSubjectMap" type="com.dxhy.core.model.CertifiedInvoiceVo">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="invoiceCode" property="invoice_code" jdbcType="VARCHAR"/>
        <result column="invoiceNo" property="invoice_no" jdbcType="VARCHAR"/>
        <result column="invoiceDate" property="invoice_date" jdbcType="DATE"/>
        <result column="invoiceType" property="invoice_type" jdbcType="VARCHAR"/>
        <result column="gfName" property="gf_name" jdbcType="VARCHAR"/>
        <result column="gfAddressAndPhone" property="gf_address_and_phone" jdbcType="VARCHAR"/>
        <result column="gfBankAndNo" property="gf_bank_and_no" jdbcType="VARCHAR"/>
        <result column="gfTaxNo" property="gf_tax_no" jdbcType="VARCHAR"/>
        <result column="xfTaxNo" property="xf_tax_no" jdbcType="VARCHAR"/>
        <result column="xfName" property="xf_name" jdbcType="VARCHAR"/>
        <result column="xfAddressAndPhone" property="xf_address_and_phone" jdbcType="VARCHAR"/>
        <result column="invoiceStatus" property="invoice_status" jdbcType="VARCHAR"/>
        <result column="createDate" property="create_date" jdbcType="VARCHAR"/>
        <result column="rzlx" property="rzlx" jdbcType="VARCHAR"/>
        <result column="sourceSystem" property="source_system" jdbcType="VARCHAR"/>
        <result column="qsDate" property="qs_date" jdbcType="VARCHAR"/>
        <result column="qsType" property="qs_type" jdbcType="VARCHAR"/>
        <result column="qsName" property="qs_name" jdbcType="VARCHAR"/>
        <result column="rzhDate" property="rzh_date" jdbcType="VARCHAR"/>
        <result column="rzhType" property="rzh_type" jdbcType="VARCHAR"/>
        <result column="gxUserName" property="gx_user_name" jdbcType="VARCHAR"/>
        <result column="dqskssq" property="dqskssq" jdbcType="VARCHAR"/>


    </resultMap>

    <resultMap id="BaseResultInvoiceDetailsMap" type="com.dxhy.core.model.InvoiceDetails">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="uuid" property="uuid" jdbcType="VARCHAR"/>
        <result column="invoice_code" property="invoiceCode" jdbcType="VARCHAR"/>
        <result column="invoice_no" property="invoiceNo" jdbcType="VARCHAR"/>
        <result column="detail_no" property="detailNo" jdbcType="INTEGER"/>
        <result column="goods_name" property="goodsName" jdbcType="VARCHAR"/>
        <result column="model" property="model" jdbcType="VARCHAR"/>
        <result column="unit" property="unit" jdbcType="VARCHAR"/>
        <result column="num" property="num" jdbcType="VARCHAR"/>
        <result column="unit_price" property="unitPrice" jdbcType="VARCHAR"/>
        <result column="detail_amount" property="detailAmount" jdbcType="VARCHAR"/>
        <result column="tax_rate" property="taxRate" jdbcType="VARCHAR"/>
        <result column="tax_amount" property="taxAmount" jdbcType="VARCHAR"/>
    </resultMap>
    <select id="queryInvoiceSubject" parameterType="java.util.Map" resultMap="BaseResultInvoiceSubjectMap">
        select invoice_code,
               invoice_no,
               invoice_date,
               invoice_type,
               gf_name,
               gf_address_and_phone,
               gf_bank_and_no,
               gf_tax_no,
               xf_tax_no,
               xf_name,
               xf_address_and_phone,
               xf_bank_and_no,
               invoice_status,
               create_date,
               rzlx,
               source_system,
               qs_date,
               qs_name,
               rzh_date,
               rzh_type,
               gx_user_name,
               rzh_belong_date dqskssq
        from t_dx_record_invoice
        where invoice_code = #{invoiceCode}
          and invoice_no = #{invoiceNo}
    </select>
    <select id="selectInvoiceDetails" parameterType="java.util.Map" resultMap="BaseResultInvoiceDetailsMap">
        SELECT id,
               uuid,
               invoice_code,
               invoice_no,
               detail_no,
               goods_name,
               model,
               unit,
               num,
               unit_price,
               detail_amount,
               tax_rate,
               tax_amount
        from t_dx_record_invoice_detail
        where invoice_code = ${invoiceCode}
          and invoice_no = ${invoiceNo}
    </select>
    <select id="selectInspectionDetails" parameterType="java.lang.String" resultMap="BaseResultInvoiceDetailsMap">
        SELECT id,
               uuid,
               detail_no,
               goods_name,
               model,
               unit,
               num,
               unit_price,
               detail_amount,
               tax_rate,
               tax_amount
        from t_dx_check_invoice_detail
        where uuid = #{uuid}
    </select>
    <select id="selectVehicleSaleInvoice" parameterType="java.lang.String"
            resultType="com.dxhy.core.job.entity.TDxVehicleSaleInvoice">
        select id,
               uuid,
               buyer_id_num,
               vehicle_type,
               factory_model,
               product_place,
               certificate,
               certificate_import,
               inspection_num,
               engine_no,
               vehicle_no,
               phone,
               buyer_bank,
               tax_rate
        from t_dx_vehicle_sale_invoice
        where uuid = #{uuid}
    </select>


    <select id="getSaleInvoiceByUuid" resultType="com.dxhy.core.entity.TDxRecordInvoice">
        select *
        from t_dx_sale_record_invoice
        where uuid = #{uuid}
    </select>
</mapper>
