<?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.huyi.service.creditLine.mapper.CreditLineMapper">

    <select id="selectCreditLineList" parameterType="map" resultType="map">
        SELECT
        r.zfpcr_id           		'zfpcrId',
        r.zfpcr_product_id          'zfpcrProductId',
        r.zfpcr_company_id          'zfpcrCompanyId',
        r.zfpcr_amount          	'zfpcrAmount',
        r.zfpcr_rate 			    'zfpcrRate',
        r.zfpcr_division_amount 	'zfpcrDivisionAmount',
        r.zfpcr_start_date 		    'zfpcrStartDate',
        r.zfpcr_end_date 		    'zfpcrEndDate',
        r.zfpcr_status 		        'zfpcrStatus',
        p.zfp_name 			        'zfpName',
        s.scy_name 			        'rzScyName',
        c.scy_name 			        'scyName',
        c.scy_social_code		    'scySocialCode'
        FROM
        zc_finance_pro_com_rel r
        LEFT JOIN zc_finance_product p
        ON p.zfp_id = r.zfpcr_product_id
        LEFT JOIN sys_company s
        ON s.scy_id = p.zfp_management_id
        LEFT JOIN sys_company c
        ON c.scy_id = r.`zfpcr_company_id`
        WHERE 1=1
--         r.zfpcr_status='00'
        <if test="paramMap.scyName != null  and paramMap.scyName != ''">
            and c.scy_name like concat('%', #{paramMap.scyName}, '%')
        </if>
        <if test="paramMap.AmountA != null  and paramMap.AmountA != ''">
            and r.zfpcr_amount &gt;= #{paramMap.AmountA}
        </if>
        <if test="paramMap.AmountB != null  and paramMap.AmountB != ''">
            and r.zfpcr_amount &lt;=  #{paramMap.AmountB}
        </if>
        <if test="paramMap.zfpcrStatus != null  and paramMap.zfpcrStatus != ''">
            and r.zfpcr_status = #{paramMap.zfpcrStatus}
        </if>
        <if test="paramMap.startTimeA != null  and paramMap.startTimeA != ''">
            and r.zfpcr_start_date &gt;= #{paramMap.startTimeA}
        </if>
        <if test="paramMap.startTimeB != null  and paramMap.startTimeB != ''">
            and r.zfpcr_start_date &lt;=  #{paramMap.startTimeB}
        </if>
        <if test="paramMap.endTimeA != null  and paramMap.endTimeA != ''">
            and r.zfpcr_end_date &gt;= #{paramMap.endTimeA}
        </if>
        <if test="paramMap.endTimeB != null  and paramMap.endTimeB != ''">
            and r.zfpcr_end_date &lt;=  #{paramMap.endTimeB}
        </if>
        order by r.create_time desc
    </select>

    <select id="selectCreditLineDetail" parameterType="map" resultType="map">
        SELECT
        r.zfpcr_id           		'zfpcrId',
        r.zfpcr_product_id          'zfpcrProductId',
        r.zfpcr_company_id          'zfpcrCompanyId',
        r.zfpcr_amount          	'zfpcrAmount',
        r.zfpcr_old_amount          'zfpcrOldAmount',
        r.zfpcr_rate 			    'zfpcrRate',
        r.zfpcr_division_amount 	'zfpcrDivisionAmount',
        r.zfpcr_date_type           'zfpcrDateType',
        r.zfpcr_start_date 		    'zfpcrStartDate',
        r.zfpcr_end_date 		    'zfpcrEndDate',
        r.zfpcr_address             'zfpcrAddress',
        r.zfpcr_charge              'zfpcrCharge',
        r.zfpcr_charge_rate         'zfpcrChargeRate',
        r.zfpcr_account             'zfpcrAccount',
        r.zfpcr_loan_type           'zfpcrLoanType',
        r.zfpcr_bookkeeping_type    'zfpcrBookkeepingType',
        r.zfpcr_status 		        'zfpcrStatus',
        p.zfp_name 			        'zfpName',
        p.zfp_management_id         'zfpManagementId',
        s.scy_name 			        'rzScyName',
        c.scy_name 			        'scyName',
        c.scy_social_code		    'scySocialCode'
        FROM
        zc_finance_pro_com_rel r
        LEFT JOIN zc_finance_product p
        ON p.zfp_id = r.zfpcr_product_id
        LEFT JOIN sys_company s
        ON s.scy_id = p.zfp_management_id
        LEFT JOIN sys_company c
        ON c.scy_id = r.`zfpcr_company_id`
        WHERE r.zfpcr_status='00'
        and r.zfpcr_id = #{paramMap.zfpcrId}
        order by r.create_time desc
    </select>
</mapper>