<?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="org.jeecg.modules.clinical.budget.mapper.FdClinicalBudgetMapper">
    <select id="getQuotationList" resultType="org.jeecg.modules.clinical.budget.entity.FdClinicalBudget">
        SELECT
            pq.id AS projectQuotationId,
            pq.CODE AS projectQuotationCode,
            pf.project_file_no as projectFileNo,
            pf.id as projectFileId
        FROM
            fd_project_file pf
            LEFT JOIN fd_contract c ON c.id = pf.contract_id
             LEFT JOIN fd_project_quotation pq ON pq.id = c.quotation_id
        WHERE
            pf.status='1' AND pf.del_flag='0' and c.quotation_id is not null
        ORDER BY
            pf.create_time DESC
    </select>

    <select id="getByQuotationId" resultType="org.jeecg.modules.clinical.budget.entity.FdClinicalBudget">
        SELECT
            pq.id AS projectQuotationId,
            pq.CODE AS projectQuotationCode,
            pf.clinical_code,
            pf.project_name,
            pf.customer_id,
            pf.customer_name,
            pf.contract_party AS contractPartyId,
            pf.sign_date AS contractSignDate,
            c.tax_rate,
            c.id as contractId,
            pf.project_file_no,
            pf.id as projectFileId
        FROM
            fd_project_file pf
            LEFT JOIN fd_contract c ON c.id = pf.contract_id
            LEFT JOIN fd_project_quotation pq ON pq.id = c.quotation_id
        WHERE
            pf.id = #{0}
    </select>

    <update id="auditBatch" parameterType="java.util.List">
        update fd_clinical_budget set status = '0' where id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>


    <update id="reviewBatch" parameterType="java.util.List">
        update fd_clinical_budget set status = '1' where id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>
</mapper>