<?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.yeejoin.amos.boot.module.hygf.api.mapper.FinancingInfoHistoryMapper">



    <select id="selectDataInfo" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.FinancingInfoHistoryDto">
        SELECT
            hfi.*
        FROM
            `hygf_financing_info_history` hfi
        WHERE
            hfi.peasant_household_id = #{peasantHouseholdId}
    </select>

    <select id="getFinancingList" resultType="java.util.Map">
       select sta.* from (  select
        hhpf.owners_name ownersName,
        hhpf.peasant_household_no peasantHouseholdNo,
        hhpf.province,
        hhpf.sequence_nbr as sequenceNbr,
        hhpf.house_address houseAddress,
        hhpf.basic_grid_capacity basicGridCapacity,
        hfih.status status,
        hfih.disbursement_money disbursementMoney,
        hfih.financing_companies_name financingCompaniesName,
        hfih.regional_companies_seq regionalCompaniesSeq
        from
        hygf_history_peasant_household hhpf
        LEFT JOIN hygf_financing_info_history hfih on hhpf.sequence_nbr = hfih.peasant_household_id
        <where>
        <if test="ownersName != null and ownersName != ''">
            and   hhpf.owners_name like concat('',#{ownersName},'%')
        </if>
        <if test="province != null and province != ''">
            and   hhpf.province =#{province}
        </if>
        </where>
       ORDER BY
        hhpf.sequence_nbr DESC)  as sta
        <where>
            <if test="status != null and status.size() > 0">
                and sta.status in
                <foreach collection="status" item="item" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
</mapper>
