<?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.conmany.mapper.OwnCompanyManageMapper">

    <select id="selectInvoiceList" parameterType="map" resultType="map">
        SELECT
        zia_address                     'ziaAddress',
        zia_contacts                    'ziaContacts',
        zia_contacts_phone              'ziaContactsPhone',
        PBAI_BANK_NAME                  'pbaiBankName',
        PBAI_BANKACCOUNT_ID             'pbaiBankaccountId',
        scy_name                        'scyName',
        scy_social_code                 'scySocialCode'
        FROM zc_invoice_address
        LEFT JOIN pay_bank_acc_inf ON zia_company_id = PBAI_CSTNO
        LEFT JOIN sys_company ON zia_company_id = scy_id
        WHERE 1=1
            AND PBAI_STATUS = '0'
            AND PBAI_BASIC = '1'
        <if test="paramMap.companyId != null and paramMap.companyId != '' ">
            AND zia_company_id = #{paramMap.companyId}
        </if>
    </select>

    <select id="selectRelList" parameterType="map" resultType="map">
        SELECT
        r.scr_id                'launchScrId',
        r.scr_launch_company_id 'launchCompanyId',
        r.scr_receive_company_id'launchReceiveScrCompanyId',
        r.scr_status		    'launchScrStatus',
        r.scr_contarct          'launchScrContarct',
        r.scr_contarct_phone    'launchScrContarctPhone',
        r.scr_contarct_email    'launchScrContarctEmail',
        r.scr_launch_type       'launchScrLaunchType',
        r.scr_receive_type      'launchScrReceiveType',
        s.scy_id		        'launchScyId',
        s.scy_social_code	    'launchScySocialCode',
        s.scy_name		        'launchScyName',
        s.scy_type		        'launchScyType',
        s.scy_legal		        'launchScyLegal',
        s.scy_phone		        'launchScyPhone',
        p.scy_id		        'receiveScyId',
        p.scy_social_code	    'receiveScySocialCode',
        p.scy_name		        'receiveScyName',
        p.scy_type		        'receiveScyType',
        p.scy_legal		        'receiveScyLegal',
        p.scy_phone		        'receiveScyPhone'
        FROM sys_company_rel r
        LEFT JOIN sys_company s ON r.scr_launch_company_id = s.scy_id
        LEFT JOIN sys_company p ON r.scr_receive_company_id = p.scy_id
        WHERE 1=1
        <if test="paramMap.companyId != null and paramMap.companyId != '' ">
            AND (r.scr_launch_company_id = #{paramMap.companyId} OR r.scr_receive_company_id = #{paramMap.companyId})
        </if>
            AND r.scr_status != '99'
            ORDER BY r.create_time DESC
    </select>

    <select id="selectUserList" parameterType="map" resultType="map">
        SELECT
        user_id     'userId',
        nick_name   'nickName',
        email       'email',
        user_name   'userName'
        FROM sys_user
        WHERE 1=1
        <if test="paramMap.userId != null and paramMap.userId != '' ">
            AND user_id = #{paramMap.userId}
        </if>
    </select>

    <!--营业执照-->
    <select id="selectLicenseFileList" parameterType="map" resultType="map">
        SELECT
            IFNULL(GROUP_CONCAT(pfi_file_name),'')  AS pfiFileName,
            IFNULL(GROUP_CONCAT(pfi_file_id),'')    AS pfiFileId,
            IFNULL(GROUP_CONCAT(pfi_url),'')        AS pfiUrl
        FROM sys_company s
        LEFT JOIN pub_file_inf
        ON FIND_IN_SET(pfi_file_id, s.scy_license_file)
        WHERE s.scy_id =  #{paramMap.companyId}
    </select>
    <!--法人证件正面-->
    <select id="selectLegalFileList" parameterType="map" resultType="map">
        SELECT
            IFNULL(GROUP_CONCAT(pfi_file_name),'')  AS pfiFileName,
            IFNULL(GROUP_CONCAT(pfi_file_id),'')    AS pfiFileId,
            IFNULL(GROUP_CONCAT(pfi_url),'')        AS pfiUrl
        FROM sys_company s
        LEFT JOIN pub_file_inf
        ON FIND_IN_SET(pfi_file_id, s.scy_legal_file)
        WHERE s.scy_id =  #{paramMap.companyId}
    </select>
    <!--法人证件反面-->
    <select id="selectLegalBackFileList" parameterType="map" resultType="map">
        SELECT
            IFNULL(GROUP_CONCAT(pfi_file_name),'')  AS pfiFileName,
            IFNULL(GROUP_CONCAT(pfi_file_id),'')    AS pfiFileId,
            IFNULL(GROUP_CONCAT(pfi_url),'')        AS pfiUrl
        FROM sys_company s
        LEFT JOIN pub_file_inf
        ON FIND_IN_SET(pfi_file_id, s.scy_legal_back_file)
        WHERE s.scy_id =  #{paramMap.companyId}
    </select>
    <!--法人授权书-->
    <select id="selectAuthorizationFileList" parameterType="map" resultType="map">
        SELECT
            IFNULL(GROUP_CONCAT(pfi_file_name),'')  AS pfiFileName,
            IFNULL(GROUP_CONCAT(pfi_file_id),'')    AS pfiFileId,
            IFNULL(GROUP_CONCAT(pfi_url),'')        AS pfiUrl
        FROM sys_company s
        LEFT JOIN pub_file_inf
        ON FIND_IN_SET(pfi_file_id, s.scy_authorization_file)
        WHERE s.scy_id =  #{paramMap.companyId}
    </select>
    <!--数字证书授权与承诺书-->
    <select id="selectCommitmentFileList" parameterType="map" resultType="map">
        SELECT
            IFNULL(GROUP_CONCAT(pfi_file_name),'')  AS pfiFileName,
            IFNULL(GROUP_CONCAT(pfi_file_id),'')    AS pfiFileId,
            IFNULL(GROUP_CONCAT(pfi_url),'')        AS pfiUrl
        FROM sys_company s
        LEFT JOIN pub_file_inf
        ON FIND_IN_SET(pfi_file_id, s.scy_commitment_file)
        WHERE s.scy_id =  #{paramMap.companyId}
    </select>
    <!--其他附件-->
    <select id="selectAppendixFileList" parameterType="map" resultType="map">
        SELECT
            IFNULL(GROUP_CONCAT(pfi_file_name),'')  AS pfiFileName,
            IFNULL(GROUP_CONCAT(pfi_file_id),'')    AS pfiFileId,
            IFNULL(GROUP_CONCAT(pfi_url),'')        AS pfiUrl
        FROM sys_company s
        LEFT JOIN pub_file_inf
        ON FIND_IN_SET(pfi_file_id, s.scy_appendix_file)
        WHERE s.scy_id =  #{paramMap.companyId}
    </select>
    <!--经办人证件正面信息-->
    <select id="handlerPositiveList" parameterType="map" resultType="map">
        SELECT
            IFNULL(GROUP_CONCAT(pfi_file_name),'')  AS pfiFileName,
            IFNULL(GROUP_CONCAT(pfi_file_id),'')    AS pfiFileId,
            IFNULL(GROUP_CONCAT(pfi_url),'')        AS pfiUrl
        FROM sys_user s
        LEFT JOIN pub_file_inf
        ON FIND_IN_SET(pfi_file_id, s.id_card_file)
        WHERE s.user_id =  #{paramMap.userId}
    </select>
    <!--经办人证件反面信息-->
    <select id="handlerNegativeList" parameterType="map" resultType="map">
        SELECT
            IFNULL(GROUP_CONCAT(pfi_file_name),'')  AS pfiFileName,
            IFNULL(GROUP_CONCAT(pfi_file_id),'')    AS pfiFileId,
            IFNULL(GROUP_CONCAT(pfi_url),'')        AS pfiUrl
        FROM sys_user s
        LEFT JOIN pub_file_inf
        ON FIND_IN_SET(pfi_file_id, s.id_card_back_file)
        WHERE s.user_id =  #{paramMap.userId}
    </select>

</mapper>
