<?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.settlement.dao.SettlementGoodsInfoMapper">


    <select id="settlementGoods" resultType="com.inkasso.factoring.settlement.entity.SettlementGoodsInfo">
        select * from
            settlement_goods_info t1
                left join c_settlement_basic_info t2 on t1.settlement_basic_info_id = t2.id
        where t2.id in (select id from c_settlement_basic_info a where a.business_number = #{business_number} and a.supplier_id = #{supplier_id} and a.settlement_status = 'bill_approval')
    </select>

    <select id="getSettledGodds" resultType="com.inkasso.factoring.settlement.entity.SettlementGoodsInfo">
        select * from
            c_settlement_goods_info t1
                left join c_settlement_basic_info t2 on t1.c_settlement_basic_info_id = t2.id
        where t2.supplier_id = #{supplierId} and t2.business_number = #{businessNumber}
    </select>
    <select id="listByAcceptanceId" resultType="com.inkasso.factoring.settlement.entity.SettlementGoodsInfo">
        select * from
            c_settlement_goods_info t1
        left join c_settlement_basic_info t2 on t1.c_settlement_basic_info_id = t2.id
        where t1.c_acceptance_basic_info_id = #{acceptanceBasicId}
          and t2.settlement_status in (select id from t_dictionary where code in ('bill_create','bill_sign','bill_need_sign'))
    </select>
</mapper>
