<?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.financeProduct.mapper.OwnFinanceProductMapper">

    <select id="selectFinanceProductList" parameterType="map" resultType="map">
        select
            z.zfp_id 'zfpId',
            z.zfp_number 'zfpNumber',
            z.zfp_name 'zfpName',
            z.zfp_type 'zfpType',
            z.zfp_auth_type 'zfpAuthType',
            z.zfp_management_id 'zfpManagementId',
            z.zfp_split 'zfpSplit',
            z.zfp_transfer 'zfpTransfer',
            z.zfp_recourse 'zfpRecourse',
            z.zfp_voucher_type 'zfpVoucherType',
            z.zfp_core_account 'zfpCoreAccount',
            z.zfp_supplier_account 'zfpSupplierAccount',
            z.zfp_charge 'zfpCharge',
            z.zfp_status 'zfpStatus',
            z.zfp_minimum_amount 'zfpMinimumAmount',
            z.zfp_shortest_period 'zfpShortestPeriod',
            z.zfp_bookkeeping 'zfpBookkeeping',
            z.zfp_part 'zfpPart',
            z.zfp_expire 'zfpExpire',
            z.zfp_rate 'zfpRate',
            z.zfp_profit 'zfpProfit',
            z.zfp_profit_type 'zfpProfitType',
            z.zfp_profit_rate 'zfpProfitRate',
            z.zfp_platform 'zfpPlatform',
            z.create_by 'createBy',
            z.create_time 'createTime',
            s.scy_name 'scyName'
            from zc_finance_product z
            left join sys_company s
            on z.zfp_management_id = s.scy_id
            where 1=1
            <if test="paramMap.zfpName != null  and paramMap.zfpName != ''">
                AND z.zfp_name LIKE concat('%', #{paramMap.zfpName}, '%')
            </if>
            <if test="paramMap.scyName != null  and paramMap.scyName != ''">
                AND s.scy_name LIKE concat('%', #{paramMap.scyName}, '%')
            </if>
            <if test="paramMap.begin != null  and paramMap.begin != ''">
                and z.zfp_shortest_period >= #{paramMap.begin}
            </if>
            <if test="paramMap.end != null  and paramMap.end != ''">
                <![CDATA[
                        and z.zfp_shortest_period <= #{paramMap.end}
                        ]]>
            </if>
            order by z.create_time desc
    </select>
    <select id="selectUserName" parameterType="map" resultType="map">
        select
            nick_name 'nickName'
        from zc_finance_product z
        left join sys_user s
        on z.create_by = s.user_id
        where 1=1
        and z.zfp_id = #{zfpId}
    </select>

</mapper>
