<?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.ezhizao.project.business.receiveTicket.mapper.BizFinancialReceiveTicketDetailMapper">

    <resultMap type="cn.ezhizao.project.business.receiveTicket.domain.BizFinancialReceiveTicketDetail"
               id="BizFinancialReceiveTicketDetailResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizFinancialReceiveTicketDetail"
            resultMap="BizFinancialReceiveTicketDetailResult">
        SELECT
        t1.*, t2.name as company_name, t2.social_credit_code
        from
        biz_financial_receive_ticket_detail t1
        left join biz_company t2 on t2.id = t1.company_id
        WHERE
        t1.deleted = 0
        <if test="id != null">
            AND t1.id = #{id}
        </if>
        <if test="financialReceiveTicketId != null">
            AND t1.financial_receive_ticket_id = ${financialReceiveTicketId}
        </if>
        <if test="year != null and year != ''">
            AND t1.year = #{year}
        </if>
        <if test="month != null and month != ''">
            AND t1.month = #{month}
        </if>
        <if test="companyName != null and companyName != '' ">
            AND t2.name like concat('%', #{companyName}, '%')
        </if>
        <if test="currentMonth != null and currentMonth != '' ">
            AND concat(t1.year, '-', t1.month) = #{currentMonth}
        </if>
        <if test="mainIds != null and mainIds.size > 0">
            AND t1.financial_receive_ticket_id in
            <foreach collection="mainIds" index="index" item="item" separator="," open="(" close=")">
                #{item,jdbcType=BIGINT}
            </foreach>
        </if>
        <if test="inputInvoice != null ">AND input_invoice = #{inputInvoice}</if>
        <if test="inputDeduction != null ">AND input_deduction = #{inputDeduction}</if>
        <if test="revenueBookkeeping != null ">AND revenue_bookkeeping = #{revenueBookkeeping}</if>
        <if test="hasIncomeTicket != null ">AND has_income_ticket = #{hasIncomeTicket}</if>
        <if test="hasCostTicket != null ">AND has_cost_ticket = #{hasCostTicket}</if>
        <if test="bankCopy != null ">AND bank_copy = #{bankCopy}</if>
        <if test="others != null ">AND others = #{others}</if>
        <if test="hasSsafTicket != null ">AND has_ssaf_ticket = #{hasSsafTicket}</if>
        <if test="bankSlips != null ">AND bank_slips = #{bankSlips}</if>
        <if test="payroll != null ">AND payroll = #{payroll}</if>
        <if test="feeTicket != null ">AND fee_ticket = #{feeTicket}</if>
        <if test="receiveDate != null ">AND receive_date = #{receiveDate}</if>
        <if test="saveStatus != null ">AND save_status = #{saveStatus}</if>
        <if test="postDate != null ">AND post_date = #{postDate}</if>
        <if test="postNo != null  and postNo != ''">AND post_no = #{postNo}</if>
        <if test="status != null ">AND status = #{status}</if>
        <if test="content != null  and content != ''">AND content = #{content}</if>
        <if test="verifyContent != null  and verifyContent != ''">AND verify_content = #{verifyContent}</if>
        <if test="incomeTicket != null ">AND income_ticket = #{incomeTicket}</if>
        <if test="costTicket != null ">AND cost_ticket = #{costTicket}</if>
        <if test="feeTicketNumber != null ">AND fee_ticket_number = #{feeTicketNumber}</if>
        <if test="ssafTicket != null ">AND ssaf_ticket = #{ssafTicket}</if>
        <if test="salaryTicket != null ">AND salary_ticket = #{salaryTicket}</if>
        <if test="bankSlipsNumber != null ">AND bank_slips_number = #{bankSlipsNumber}</if>
        <if test="bankCopyNumber != null ">AND bank_copy_number = #{bankCopyNumber}</if>
        <if test="otherTicket != null ">AND other_ticket = #{otherTicket}</if>
        <if test="sumNumber != null ">AND sum_number = #{sumNumber}</if>
        <if test="lackTicket != null ">AND lack_ticket = #{lackTicket}</if>
        <if test="feedbackContent != null  and feedbackContent != ''">AND feedback_content = #{feedbackContent}</if>
        <if test="feedbackStatus != null ">AND feedback_status = #{feedbackStatus}</if>

    </select>

    <delete id="physicalDelete">
        DELETE FROM biz_financial_receive_ticket_detail
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            <if test="id != null">
                id = #{id} AND
            </if>
            <!-- 删除条件为其他外键可以在这里加 -->
        </trim>
    </delete>
</mapper>
