<?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.paperInvoice.SzhtxxPaperInvoiceRedTaxInfoMapperEx">


    <resultMap id="SzhtxxPaperInvoiceRedTaxInfoListItemResultMap" type="cn.superdesk.uniorder.dto.vo.thirdpart.szhtxx.paperInvoice.SzhtxxPaperInvoiceRedTaxInfoListItemVo">
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="batch_id" jdbcType="VARCHAR" property="batchId" />
        <result column="deleted" jdbcType="TINYINT" property="deleted" />
        <result column="return_code" jdbcType="VARCHAR" property="returnCode" />
        <result column="return_msg" jdbcType="VARCHAR" property="returnMsg" />
        <result column="red_tax_info_lsh" jdbcType="VARCHAR" property="redTaxInfoLsh" />
        <result column="red_tax_info_sn" jdbcType="VARCHAR" property="redTaxInfoSn" />
        <result column="red_tax_info_status" jdbcType="VARCHAR" property="redTaxInfoStatus" />
        <result column="red_tax_info_desc" jdbcType="VARCHAR" property="redTaxInfoDesc" />
        <result column="used" jdbcType="TINYINT" property="used" />
        <result column="fpdm" jdbcType="VARCHAR" property="fpdm" />
        <result column="fphm" jdbcType="VARCHAR" property="fphm" />
        <result column="fjh" jdbcType="VARCHAR" property="fjh" />
        <result column="ghf_nsrsbh" jdbcType="VARCHAR" property="ghfNsrsbh" />
        <result column="ghfmc" jdbcType="VARCHAR" property="ghfmc" />
        <result column="xhf_nsrsbh" jdbcType="VARCHAR" property="xhfNsrsbh" />
        <result column="xhfmc" jdbcType="VARCHAR" property="xhfmc" />
        <result column="ssyf" jdbcType="VARCHAR" property="ssyf" />
        <result column="kphjje" jdbcType="DECIMAL" property="kphjje" />
        <result column="hjbhsje" jdbcType="DECIMAL" property="hjbhsje" />
        <result column="sl" jdbcType="DECIMAL" property="sl" />
        <result column="hjse" jdbcType="DECIMAL" property="hjse" />
        <result column="reqf_code" jdbcType="VARCHAR" property="reqfCode" />
        <result column="reqf_name" jdbcType="VARCHAR" property="reqfName" />
        <result column="req_explain" jdbcType="VARCHAR" property="reqExplain" />
        <result column="golden_tax_plate_no" jdbcType="VARCHAR" property="goldenTaxPlateNo" />
        <result column="req_nsrsbh" jdbcType="VARCHAR" property="reqNsrsbh" />
        <result column="backend_memo" jdbcType="VARCHAR" property="backendMemo" />
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
        <result column="create_user_id" jdbcType="BIGINT" property="createUserId" />
        <result column="create_user_name" jdbcType="VARCHAR" property="createUserName" />
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
        <result column="update_user_id" jdbcType="BIGINT" property="updateUserId" />
        <result column="update_user_name" jdbcType="VARCHAR" property="updateUserName" />
    </resultMap>

    <select id="pageQueryGenericParam" resultMap="SzhtxxPaperInvoiceRedTaxInfoListItemResultMap">

        SELECT
            id, batch_id, deleted, return_code, return_msg, red_tax_info_lsh, red_tax_info_sn,
            red_tax_info_status, red_tax_info_desc, used, fpdm, fphm, fjh, ghf_nsrsbh, ghfmc,
            xhf_nsrsbh, xhfmc, ssyf, kphjje, hjbhsje, sl, hjse, reqf_code, reqf_name, req_explain,
            golden_tax_plate_no, req_nsrsbh, backend_memo, create_time, create_user_id, create_user_name,
            update_time, update_user_id, update_user_name

        FROM
        szhtxx_paper_invoice_red_tax_info szhtpirti

        <where>
            and 1 = 1
            and red_tax_info_lsh is not null
            <include refid="whereIf"></include>

            <choose>
                <when test="orderByClause != null and orderByClause != '' ">
                    order by ${orderByClause}
                </when>
                <otherwise>
                    order by szhtpirti.create_time desc
                </otherwise>
            </choose>
        </where>
    </select>

    <sql id="whereIf">
        and szhtpirti.deleted = 0


        <if test="redTaxInfoLsh != null and redTaxInfoLsh != ''">
            and szhtpirti.red_tax_info_lsh = #{redTaxInfoLsh,jdbcType=VARCHAR}
        </if>
        <if test="redTaxInfoSn != null and redTaxInfoSn != ''">
            and szhtpirti.red_tax_info_sn = #{redTaxInfoSn,jdbcType=VARCHAR}
        </if>
        <if test="redTaxInfoStatus != null and redTaxInfoStatus != ''">
            and szhtpirti.red_tax_info_status = #{redTaxInfoStatus,jdbcType=VARCHAR}
        </if>
        <if test="redTaxInfoDesc != null and redTaxInfoDesc != ''">
            and szhtpirti.red_tax_info_desc = #{redTaxInfoDesc,jdbcType=VARCHAR}
        </if>


        <if test="used != null and used != ''">
            and szhtpirti.used = #{used,jdbcType=TINYINT}
        </if>

        <if test="fpdm != null and fpdm != ''">
            and szhtpirti.fpdm = #{fpdm,jdbcType=VARCHAR}
        </if>

        <if test="fphm != null and fphm != ''">
            and szhtpirti.fphm = #{fphm,jdbcType=VARCHAR}
        </if>


        <if test="ghfNsrsbh != null and ghfNsrsbh != ''">
            and szhtpirti.ghf_nsrsbh = #{ghfNsrsbh,jdbcType=VARCHAR}
        </if>
        <if test="xhfNsrsbh != null and xhfNsrsbh != ''">
            and szhtpirti.xhf_nsrsbh = #{xhfNsrsbh,jdbcType=VARCHAR}
        </if>
        <if test="ghfmc != null and ghfmc != ''">
            and szhtpirti.ghfmc like CONCAT('%',#{ghfmc},'%')
        </if>
        <if test="xhfmc != null and xhfmc != ''">
            and szhtpirti.xhfmc like CONCAT('%',#{xhfmc},'%')
        </if>

        <if test="goldenTaxPlateNo != null and goldenTaxPlateNo != ''">
            and szhtpirti.golden_tax_plate_no = #{goldenTaxPlateNo,jdbcType=VARCHAR}
        </if>


        <if test="startTime != null and startTime != ''">
            and DATE_FORMAT(szhtpirti.create_time,'%Y-%m-%d') &gt;= #{startTime,jdbcType=VARCHAR}
        </if>
        <if test="endTime != null and endTime != ''">
            and DATE_FORMAT(szhtpirti.create_time,'%Y-%m-%d') &lt;= #{endTime,jdbcType=VARCHAR}
        </if>

        <if test="createUserId != null and createUserId != ''">
            and szhtpirti.create_user_id = #{createUserId,jdbcType=BIGINT}
        </if>



<!--        &lt;!&ndash; 2.7.3.5 开票方式;-单选 &ndash;&gt;-->
<!--        <if test="invoiceMode != null and invoiceMode != ''">-->
<!--            and inva.invoice_mode = #{invoiceMode,jdbcType=VARCHAR}-->
<!--        </if>-->
<!--        &lt;!&ndash; 2.7.3.5 开票方式;-多选 &ndash;&gt;-->
<!--        <if test="invoiceModeSelected != null and invoiceModeSelected.size > 0">-->
<!--            and inva.invoice_mode in-->
<!--            <foreach collection="invoiceModeSelected" index="index" item="invoiceMode" open="(" close=")" separator=",">-->
<!--                #{invoiceMode,jdbcType=VARCHAR}-->
<!--            </foreach>-->
<!--        </if>-->



<!--        <if test="sourceFromsSelected != null and sourceFromsSelected != '' and sourceFromsSelected.size > 0">-->
<!--            and inva.source_from in-->
<!--            <foreach collection="sourceFromsSelected" index="index" item="source_from" open="(" close=")" separator=",">-->
<!--                #{source_from}-->
<!--            </foreach>-->
<!--        </if>-->

<!--        <if test="serviceNosSelected != null and serviceNosSelected != '' and serviceNosSelected.size > 0">-->
<!--            and inva.service_no in-->
<!--            <foreach collection="serviceNosSelected" index="index" item="service_no" open="(" close=")" separator=",">-->
<!--                #{service_no}-->
<!--            </foreach>-->
<!--        </if>-->

<!--        &lt;!&ndash; 2.7.3.6 开票类型^_^开票类型(1-正常发票;2-红冲发票;10-特殊冲红) 引用 enum SzhtxxElectronicInvoiceFptxxKplxEnum &ndash;&gt;-->
<!--        <if test="kplx != null and kplx != ''">-->
<!--            and szhteif.kplx = #{kplx,jdbcType=VARCHAR}-->
<!--        </if>-->

<!--        &lt;!&ndash; 2.7.3.7 是否红冲:0-否;1-是; &ndash;&gt;-->
<!--        <if test="isRedWriteOff != null">-->
<!--            and szhteifei.is_red_write_off = #{isRedWriteOff,jdbcType=TINYINT}-->
<!--        </if>-->

<!--        &lt;!&ndash; 作废标志 &ndash;&gt;-->
<!--        <if test="flagVoidSign != null">-->
<!--            and szhteifei.flag_void_sign = #{flagVoidSign,jdbcType=TINYINT}-->
<!--        </if>-->



<!--        &lt;!&ndash; 2.7.3.7 报送状态[新增]:0-未报送;1-已报送;-1报送失败 &ndash;&gt;-->
<!--        <if test="pushedOutStatus != null">-->
<!--            and szhteifei.pushed_out_status = #{pushedOutStatus,jdbcType=TINYINT}-->
<!--        </if>-->
<!--        &lt;!&ndash; 2.7.3.7 邮件状态[新增]-20220427:0-未发送;1-已发送;send过去分词 sent  &ndash;&gt;-->
<!--        <if test="sentEmailStatus != null">-->
<!--            and szhteifei.sent_email_status = #{sentEmailStatus,jdbcType=TINYINT}-->
<!--        </if>-->



<!--        &lt;!&ndash; 2.7.3.8 回款状态; &ndash;&gt;-->
<!--        <if test="backAccountStatus != null">-->
<!--            and inva.back_account_status = #{backAccountStatus,jdbcType=TINYINT}-->
<!--        </if>-->

<!--        <if test="backAccountStatusSelected != null and backAccountStatusSelected.size > 0">-->
<!--            and inva.back_account_status in-->
<!--            <foreach collection="backAccountStatusSelected" index="index" item="backAccountStatus" open="(" close=")" separator=",">-->
<!--                #{backAccountStatus}-->
<!--            </foreach>-->
<!--        </if>-->


<!--        &lt;!&ndash; 2.7.3.9 开票日期; &ndash;&gt;-->
<!--        <if test="makeInvoiceTimeStart != null and makeInvoiceTimeStart != '' and makeInvoiceTimeEnd != null and makeInvoiceTimeEnd !=''">-->
<!--            and TO_DAYS(inva.make_invoice_time) &gt;= TO_DAYS(#{makeInvoiceTimeStart,jdbcType=VARCHAR})-->
<!--            and TO_DAYS(inva.make_invoice_time) &lt;= TO_DAYS(#{makeInvoiceTimeEnd,jdbcType=VARCHAR})-->
<!--        </if>-->

<!--        &lt;!&ndash; 2.7.3.9 回款日期; &ndash;&gt;-->
<!--        <if test="backAccountTimeStart != null and backAccountTimeStart != '' and backAccountTimeEnd != null and backAccountTimeEnd !=''">-->
<!--            and TO_DAYS(inva.back_account_time) &gt;= TO_DAYS(#{backAccountTimeStart,jdbcType=VARCHAR})-->
<!--            and TO_DAYS(inva.back_account_time) &lt;= TO_DAYS(#{backAccountTimeEnd,jdbcType=VARCHAR})-->
<!--        </if>-->

    </sql>
</mapper>