<?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.MryxInterfaceDao">

    <sql id="sql_fields_added">
        d.invoice_code,
		d.invoice_no,
		d.invoice_type,
		d.invoice_date,
		d.gf_tax_no,
		d.gf_name,
		d.gf_address_and_phone,
		d.gf_bank_and_no,
		d.xf_tax_no,
		d.xf_name,
		d.xf_address_and_phone,
		d.xf_bank_and_no,
		d.invoice_amount,
		d.tax_amount,
		d.total_amount,
		d.remark,
		d.invoice_status,
		d.rzh_yesorno,
		d.rzh_date,
		d.dqskssq,
		d.gxjzr,
		d.gxfwq,
		d.gxfwz,
		d.rzh_type,
		d.rzh_belong_date,
		d.sfygx,
		d.sfdbts,
		d.rzlx,
		d.check_code,
		d.txfbz,
		d.lslbz,
		d.rzh_type
    </sql>

    <!--根据税号、类型、号码批量获取发票信息 -->
    <select id="getInvoiceList"
            resultType="com.dxhy.erp.entity.TdxRecordInvoice">
        select
        <include refid="sql_fields_added"/>
        from t_dx_record_invoice d
        where d.invoice_type = #{invoiceType} and
        d.gf_tax_no = #{buyerTaxNo} and d.uuid in
        <foreach item="item" index="index" collection="invoiceList"
                 open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

    <!-- 根据税号、发票号码查询签收状态 -->
    <select id="getSignState"
            resultType="com.dxhy.erp.entity.InvoiceElectron">
        select
        invoice_code invoiceCode,
        invoice_no invoiceNo,
        gf_tax_no gfTaxNo,
        qs_status qsStatus,
        qs_type qsType,
        user_name userName,
        qs_date qsDate
        from t_dx_invoice where gf_tax_no = #{buyerTaxNo} and
        uuid in
        <foreach item="item" index="index" collection="invoiceList"
                 open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

    <!-- 同步付款信息 -->
    <update id="updatePay">
        update t_dx_record_invoice
        set payment_status = #{paymentStatus},
            payment_date   = #{paymentDate},
            voucher_number = #{voucherNumber},
            payment_sum    = #{paymentSum}
        where uuid = #{uuid}
    </update>

</mapper>
