<?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.erp.dao.SignedDao">
    <select id="selectByCollect" resultType="com.dxhy.erp.entity.RecordInvoice">
        select ri.invoice_code,
               ri.invoice_no,
               ri.invoice_type,
               ri.invoice_date,
               ri.gf_tax_no,
               ri.gf_name,
               ri.gf_address_and_phone,
               ri.gf_bank_and_no,
               ri.xf_tax_no,
               ri.xf_name,
               ri.xf_address_and_phone,
               ri.xf_bank_and_no,
               ri.invoice_amount,
               ri.tax_amount,
               ri.total_amount,
               ri.remark,
               ri.invoice_status,
               ri.rzh_yesorno,
               ri.confirm_date,
               ri.qs_date,
               d.vendor_id,
               d.request_id,
               d.user_name,
               d.create_date
        from t_dx_record_invoice ri
                 left join t_dx_invoice d on d.uuid = ri.uuid
                 LEFT JOIN ${dxhyAdmin}.sys_user u on d.user_account = u.user_id
        where u.push_yesorno = '1'
          and ri.qs_status = '1'
          and <![CDATA[ri.qs_date >= #{startDate}]]>
          and <![CDATA[ri.qs_date < #{endDate}]]>
          and ri.gf_tax_no = #{gfTaxNo}
    </select>
    <select id="selectByCount" resultType="java.lang.Integer">
        select count(*) from t_dx_record_invoice ri left join t_dx_invoice d on d.uuid = ri.uuid
        LEFT JOIN ${dxhyAdmin}.sys_user u on d.user_account = u.user_id
        where u.push_yesorno=1 and ri.qs_status=1 and <![CDATA[ri.qs_date>=#{startDate}]]> and
        <![CDATA[ri.qs_date<#{endDate}]]>
        <if test="gfTaxNo != null and gfTaxNo!= ''">
            and ri.gf_tax_no=#{gfTaxNo}
        </if>
    </select>
    <select id="selectByRecordInvoice" resultType="com.dxhy.erp.entity.RecordInvoice">
        select ri.invoice_code,
               ri.invoice_no,
               ri.invoice_type,
               ri.invoice_date,
               ri.gf_tax_no,
               ri.gf_name,
               ri.gf_address_and_phone,
               ri.gf_bank_and_no,
               ri.xf_tax_no,
               ri.xf_name,
               ri.xf_address_and_phone,
               ri.xf_bank_and_no,
               ri.invoice_amount,
               ri.tax_amount,
               ri.total_amount,
               ri.remark,
               ri.invoice_status,
               ri.rzh_yesorno,
               ri.confirm_date,
               ri.qs_date,
               d.user_name,
               d.create_date
        from t_dx_record_invoice ri
                 left join t_dx_invoice d on d.uuid = ri.uuid
                 LEFT JOIN ${dxhyAdmin}.sys_user u on d.user_account = u.user_id
        where u.push_yesorno = '1'
          and ri.qs_status = '1'
          and ri.invoice_no = #{invoiceNo}
          and ri.invoice_code = #{invoiceCode}
    </select>

    <select id="selectDetails" resultType="com.dxhy.erp.entity.RecordInvoiceDetail">
        select *
        from t_dx_record_invoice_detail
        where uuid = #{uuid}
    </select>
</mapper>
