<?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.fjhx.sale.mapper.intermediate.IntermediateContractMapper">
    <select id="getPage" resultType="com.fjhx.sale.entity.intermediate.vo.IntermediateContractVo">
        SELECT c.CODE,
               c.amount,
               c.currency,
               c.sell_corporation_id oldSellCorporationId,
               c.buy_corporation_id  oldBuyCorporationId,
               d.id                  documentsId,
               ic.sell_corporation_id,
               ic.sell_contact_name,
               ic.sell_contact_number,
               ic.buy_corporation_id,
               ic.buy_contact_name,
               ic.buy_contact_number,
               ic.create_user,
               ic.create_time,
               ic.update_user,
               ic.update_time
        FROM documents d
                 LEFT JOIN contract c ON d.contract_id = c.id
                 LEFT JOIN documents_transport dp ON d.id = dp.documents_id
                 LEFT JOIN intermediate_contract ic ON ic.documents_id = d.id
            ${ew.customSqlSegment}
    </select>

    <select id="contactList" resultType="com.fjhx.sale.entity.intermediate.vo.IntermediateContractVo">
        SELECT ic.sell_contact_name,
               ic.sell_contact_number,
               ic.buy_contact_name,
               ic.buy_contact_number
        FROM intermediate_contract ic
            ${ew.customSqlSegment}
    </select>

</mapper>
