<?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.contract.mapper.OwnContractMapper">

    <select id="selectContractList" parameterType="map" resultType="map">
        select
            z.zfc_id 'zfcId',
            z.zfc_name 'zfcName',
            z.zfc_type 'zfcType',
            z.zfc_management_id 'zfcManagementId',
            z.zfc_subject 'zfcSubject',
            z.zfc_node 'zfcNode',
            z.zfc_desc 'zfcDesc',
            z.zfc_file 'zfcFile',
            z.zfc_status 'zfcStatus',
            z.create_by 'createBy',
            date_format( z.create_time,   '%Y-%m-%d %T') 'createTime',
            s.scy_name 'scyName',
            u.nick_name 'nickName'
            from zc_finance_contract z
            left join sys_company s
            on z.zfc_management_id = s.scy_id
            left join sys_user u
            on z.create_by = u.user_id
            where 1=1
            and z.zfc_status != '02'
            <if test="paramMap.zfcName != null  and paramMap.zfcName != ''">
                AND z.zfc_name LIKE concat('%', #{paramMap.zfcName}, '%')
            </if>
            <if test="paramMap.scyName != null  and paramMap.scyName != ''">
                AND s.scy_name LIKE concat('%', #{paramMap.scyName}, '%')
            </if>
            <if test="paramMap.zfcStatus != null  and paramMap.zfcStatus != ''">
                and z.zfc_status = #{paramMap.zfcStatus}
            </if>
            <if test="paramMap.zfcSubject != null  and paramMap.zfcSubject != ''">
                and z.zfc_subject = #{paramMap.zfcSubject}
            </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>
