<?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.inkasso.factoring.financingmanagement.dao.ContractSignConfirmMapper">


    <select id="getByFinancingApplyId" resultType="com.inkasso.factoring.financingmanagement.entity.ContractSignConfirm">
        SELECT DISTINCT
            t4.*
        FROM
            c_financing_basic_info t1,
            review_quota_disburse t2,
            contract_info t3,
            contract_sign_confirm t4
        WHERE
            t1.id = t2.c_financing_basic_info_id
          AND t2.id = t3.review_quota_disburse_id
          AND t3.id = t4.contract_info_id
          AND t1.id = #{financingApplyId}
          AND t4.visible = #{visible}
    </select>
    <select id="getContractInfoIdByFinancingApplyId" resultType="java.lang.Long">
        SELECT DISTINCT
            t3.id
        FROM
            c_financing_basic_info t1,
            review_quota_disburse t2,
            contract_info t3
        WHERE
            t1.id = t2.c_financing_basic_info_id
          AND t2.id = t3.review_quota_disburse_id
          AND t1.id = #{financingApplyId}
        ORDER BY t3.id DESC LIMIT 1
    </select>
</mapper>
