<?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.ruoyi.basicData.mapper.TCorpsMapper">

    <resultMap type="TCorps" id="TCorpsResult">
        <result property="fId"    column="f_id"    />
        <result property="fPid"    column="f_pid"    />
        <result property="fTypeid"    column="f_typeid"    />
        <result property="fNo"    column="f_no"    />
        <result property="fName"    column="f_name"    />
        <result property="fCname"    column="f_cname"    />
        <result property="fEname"    column="f_ename"    />
        <result property="fTel"    column="f_tel"    />
        <result property="fFax"    column="f_fax"    />
        <result property="fEmail"    column="f_email"    />
        <result property="fManage"    column="f_manage"    />
        <result property="fAddr"    column="f_addr"    />
        <result property="fEaddr"    column="f_eaddr"    />
        <result property="fScale"    column="f_scale"    />
        <result property="fProvince"    column="f_province"    />
        <result property="fCity"    column="f_city"    />
        <result property="fStltypeid"    column="f_stltypeid"    />
        <result property="fStldays"    column="f_stldays"    />
        <result property="fContractno"    column="f_contractno"    />
        <result property="fContractb"    column="f_contractb"    />
        <result property="fContracte"    column="f_contracte"    />
        <result property="fTax"    column="f_tax"    />
        <result property="fInvtel"    column="f_invtel"    />
        <result property="fInvaddr"    column="f_invaddr"    />
        <result property="fBankno"    column="f_bankno"    />
        <result property="fBankname"    column="f_bankname"    />
        <result property="fUbankno"    column="f_ubankno"    />
        <result property="fUbankname"    column="f_ubankname"    />
        <result property="fStatus"    column="f_status"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="fTypename"    column="f_typename"    />
        <result property="loginAccount"    column="login_account"    />
        <result property="creditLv"    column="credit_lv"    />
        <result property="paymentDays"    column="payment_days"    />
        <result property="carNum"    column="car_num"    />
        <result property="headOffice"    column="head_office"    />
        <result property="registerdCapital"    column="registerd_capital"    />
        <result property="legalPerson"    column="legal_person"    />
        <result property="insdustry"    column="insdustry"    />
        <result property="creditNum"    column="credit_num"    />
        <result property="taxpayerNum"    column="taxpayer_num"    />
        <result property="industryCommerceNum"    column="industry_commerce_num"    />
        <result property="organizationNum"    column="organization_num"    />
        <result property="registerOrganization"    column="register_organization"    />
        <result property="dateOfEstablishment"    column="date_of_establishment"    />
        <result property="companyType"    column="company_type"    />
        <result property="businessDeadline"    column="business_deadline"    />
        <result property="businessArea"    column="business_area"    />
        <result property="annualDate"    column="annual_date"    />
        <result property="registerdAddress"    column="registerd_address"    />
        <result property="manageScope"    column="manage_scope"    />
        <result property="deptId"    column="dept_id"    />
    </resultMap>

    <sql id="selectTCorpsVo">
        select f_id, f_pid, f_typeid, f_no, f_name, f_cname, f_ename, f_tel, f_fax, f_email, f_manage, f_addr, f_eaddr, f_scale, f_province,
         f_city, f_stltypeid, f_stldays, f_contractno, f_contractb, f_contracte, f_tax, f_invtel, f_invaddr, f_bankno, f_bankname, f_ubankno,
          f_ubankname, f_status, del_flag, create_by, create_time, update_by, update_time, remark, f_typename, login_account, credit_lv,
           payment_days, car_num, head_office, registerd_capital, legal_person, insdustry, credit_num, taxpayer_num, industry_commerce_num,
            organization_num, register_organization, date_of_establishment, company_type, business_deadline, business_area, annual_date,
             registerd_address, manage_scope, dept_id from t_corps
    </sql>

    <select id="selectTCorpsList" parameterType="TCorps" resultMap="TCorpsResult">
        <include refid="selectTCorpsVo"/>
        <where>
            <if test="fTypeid != null  and fTypeid != ''"> and JSON_CONTAINS( f_typeid -> '$[*]', #{fTypeid}, '$')</if>
            <if test="fTypeid == null and fTypeid == ''"> and f_typeid != '[\"100\"]' and f_typeid != '[\"102\"]'</if>
            <if test="fPid != null  and fPid != ''"> and f_pid = #{fPid}</if>
            <if test="fNo != null  and fNo != ''"> and f_no = #{fNo}</if>
            <if test="fName != null  and fName != ''"> and f_name like concat('%', #{fName}, '%')</if>
            <if test="fCname != null  and fCname != ''"> and f_cname like concat('%', #{fCname}, '%')</if>
            <if test="fEname != null  and fEname != ''"> and f_ename like concat('%', #{fEname}, '%')</if>
            <if test="fTel != null  and fTel != ''"> and f_tel = #{fTel}</if>
            <if test="fFax != null  and fFax != ''"> and f_fax = #{fFax}</if>
            <if test="fEmail != null  and fEmail != ''"> and f_email = #{fEmail}</if>
            <if test="fManage != null  and fManage != ''"> and f_manage = #{fManage}</if>
            <if test="fAddr != null  and fAddr != ''"> and f_addr = #{fAddr}</if>
            <if test="fEaddr != null  and fEaddr != ''"> and f_eaddr = #{fEaddr}</if>
            <if test="fScale != null  and fScale != ''"> and f_scale = #{fScale}</if>
            <if test="fProvince != null  and fProvince != ''"> and f_province = #{fProvince}</if>
            <if test="fCity != null  and fCity != ''"> and f_city = #{fCity}</if>
            <if test="fStltypeid != null "> and f_stltypeid = #{fStltypeid}</if>
            <if test="fStldays != null "> and f_stldays = #{fStldays}</if>
            <if test="fContractno != null  and fContractno != ''"> and f_contractno = #{fContractno}</if>
            <if test="fContractb != null "> and f_contractb = #{fContractb}</if>
            <if test="fContracte != null "> and f_contracte = #{fContracte}</if>
            <if test="fTax != null  and fTax != ''"> and f_tax = #{fTax}</if>
            <if test="fInvtel != null  and fInvtel != ''"> and f_invtel = #{fInvtel}</if>
            <if test="fInvaddr != null  and fInvaddr != ''"> and f_invaddr = #{fInvaddr}</if>
            <if test="fBankno != null  and fBankno != ''"> and f_bankno = #{fBankno}</if>
            <if test="fBankname != null  and fBankname != ''"> and f_bankname like concat('%', #{fBankname}, '%')</if>
            <if test="fUbankno != null  and fUbankno != ''"> and f_ubankno = #{fUbankno}</if>
            <if test="fUbankname != null  and fUbankname != ''"> and f_ubankname like concat('%', #{fUbankname}, '%')</if>
            <if test="fStatus != null  and fStatus != ''"> and f_status = #{fStatus}</if>
            <if test="fTypename != null  and fTypename != ''"> and f_typename like concat('%', #{fTypename}, '%')</if>
            <if test="loginAccount != null  and loginAccount != ''"> and login_account = #{loginAccount}</if>
            <if test="creditLv != null  and creditLv != ''"> and credit_lv = #{creditLv}</if>
            <if test="paymentDays != null "> and payment_days = #{paymentDays}</if>
            <if test="carNum != null "> and car_num = #{carNum}</if>
            <if test="headOffice != null  and headOffice != ''"> and head_office = #{headOffice}</if>
            <if test="registerdCapital != null  and registerdCapital != ''"> and registerd_capital = #{registerdCapital}</if>
            <if test="legalPerson != null  and legalPerson != ''"> and legal_person = #{legalPerson}</if>
            <if test="insdustry != null  and insdustry != ''"> and insdustry = #{insdustry}</if>
            <if test="creditNum != null  and creditNum != ''"> and credit_num = #{creditNum}</if>
            <if test="taxpayerNum != null  and taxpayerNum != ''"> and taxpayer_num = #{taxpayerNum}</if>
            <if test="industryCommerceNum != null  and industryCommerceNum != ''"> and industry_commerce_num = #{industryCommerceNum}</if>
            <if test="organizationNum != null  and organizationNum != ''"> and organization_num = #{organizationNum}</if>
            <if test="registerOrganization != null  and registerOrganization != ''"> and register_organization = #{registerOrganization}</if>
            <if test="dateOfEstablishment != null "> and date_of_establishment = #{dateOfEstablishment}</if>
            <if test="companyType != null  and companyType != ''"> and company_type = #{companyType}</if>
            <if test="businessDeadline != null "> and business_deadline = #{businessDeadline}</if>
            <if test="businessArea != null  and businessArea != ''"> and business_area = #{businessArea}</if>
            <if test="annualDate != null "> and annual_date = #{annualDate}</if>
            <if test="registerdAddress != null  and registerdAddress != ''"> and registerd_address = #{registerdAddress}</if>
            <if test="manageScope != null  and manageScope != ''"> and manage_scope = #{manageScope}</if>
        </where>
            ORDER BY CONVERT(f_name USING gbk) asc
    </select>

    <select id="selectTCorpsById" parameterType="Long" resultMap="TCorpsResult">
        <include refid="selectTCorpsVo"/>
        where f_id = #{fId}
    </select>

    <select id="selectCorpList" parameterType="long" resultMap="TCorpsResult">
        SELECT
            c.f_id,
            c.f_pid,
            c.f_typeid,
            c.f_no,
            c.f_name
        FROM
            t_corps c
            LEFT JOIN F_TMSORDERBILLSCARS car ON car.driver_tel = c.f_tel OR car.corp_id = c.f_id
        WHERE
            c.f_typeid != '[\"102\"]'
            OR car.id = #{fId}
    </select>

    <select id="selectCustomerDriverList" parameterType="TCorps" resultMap="TCorpsResult">
        SELECT DISTINCT
            c.f_id,
            c.f_pid,
            c.f_typeid,
            c.f_no,
            c.f_name
        FROM
            t_corps c
            LEFT JOIN F_TMSORDERBILLSCARS car ON car.driver_tel = c.f_tel
        <where>
            c.f_status = '0'
            <if test="fName != null  and fName != ''"> and c.f_name like concat('%', #{fName}, '%')</if>
        </where>
    </select>

    <select id="selectFleetDriverMsgListMap" parameterType="TCorps" resultType="Map">
        SELECT
            c.f_id AS id,
            t.f_name AS companyName,
            c.f_name AS name,
            c.f_fax AS fFax,
            c.f_contractb AS fContractb,
            c.f_eaddr AS fEaddr,
            c.f_contracte AS fContracte,
            c.f_scale AS fScale,
            c.f_tel AS fTel,
            c.f_addr AS fAddr,
            c.registerd_address AS registerdAddress,
            c.manage_scope AS manageScope,
            c.create_time AS creatTime,
            c.update_time AS updateTime,
            c.f_status AS fStatus,
            c.del_flag AS delFlag,
            c.create_by AS createBy,
            c.update_by AS updateBy,
            c.update_time AS updateTime,
            c.remark AS remark
        FROM
            t_corps c
            LEFT JOIN t_corps t ON t.f_id = c.f_pid
        <where>
            <if test="fTypeid != null  and fTypeid != ''"> and c.f_typeid = #{fTypeid}</if>
            <if test="fPid != null  and fPid != ''"> and c.f_pid = #{fPid}</if>
            <if test="fNo != null  and fNo != ''"> and c.f_no = #{fNo}</if>
            <if test="fName != null  and fName != ''"> and c.f_name like concat('%', #{fName}, '%')</if>
            <if test="fCname != null  and fCname != ''"> and c.f_cname like concat('%', #{fCname}, '%')</if>
            <if test="fEname != null  and fEname != ''"> and c.f_ename like concat('%', #{fEname}, '%')</if>
            <if test="fTel != null  and fTel != ''"> and c.f_tel like concat('%', #{fTel}, '%')</if>
            <if test="fFax != null  and fFax != ''"> and c.f_fax = #{fFax}</if>
            <if test="fEmail != null  and fEmail != ''"> and c.f_email = #{fEmail}</if>
            <if test="fManage != null  and fManage != ''"> and c.f_manage = #{fManage}</if>
            <if test="fAddr != null  and fAddr != ''"> and c.f_addr = #{fAddr}</if>
            <if test="fEaddr != null  and fEaddr != ''"> and c.f_eaddr = #{fEaddr}</if>
            <if test="fScale != null  and fScale != ''"> and c.f_scale = #{fScale}</if>
            <if test="fProvince != null  and fProvince != ''"> and c.f_province = #{fProvince}</if>
            <if test="fCity != null  and fCity != ''"> and c.f_city = #{fCity}</if>
            <if test="registerdAddress != null  and registerdAddress != ''"> and c.registerd_address = #{registerdAddress}</if>
            <if test="manageScope != null  and manageScope != ''"> and c.manage_scope = #{manageScope}</if>
        </where>
    </select>

    <select id="selectTCorpsByFTel" parameterType="String" resultMap="TCorpsResult">
        select f_id, f_pid, f_typeid, f_no, f_name from t_corps where f_tel = #{phonenumber}
    </select>

    <insert id="insertTCorps" parameterType="TCorps" useGeneratedKeys="true" keyProperty="fId">
        insert into t_corps
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fPid != null and fPid != ''">f_pid,</if>
            <if test="fTypeid != null and fTypeid != ''">f_typeid,</if>
            <if test="fNo != null and fNo != ''">f_no,</if>
            <if test="fName != null and fName != ''">f_name,</if>
            <if test="fCname != null">f_cname,</if>
            <if test="fEname != null">f_ename,</if>
            <if test="fTel != null">f_tel,</if>
            <if test="fFax != null">f_fax,</if>
            <if test="fEmail != null">f_email,</if>
            <if test="fManage != null">f_manage,</if>
            <if test="fAddr != null">f_addr,</if>
            <if test="fEaddr != null">f_eaddr,</if>
            <if test="fScale != null">f_scale,</if>
            <if test="fProvince != null">f_province,</if>
            <if test="fCity != null">f_city,</if>
            <if test="fStltypeid != null">f_stltypeid,</if>
            <if test="fStldays != null">f_stldays,</if>
            <if test="fContractno != null">f_contractno,</if>
            <if test="fContractb != null">f_contractb,</if>
            <if test="fContracte != null">f_contracte,</if>
            <if test="fTax != null">f_tax,</if>
            <if test="fInvtel != null">f_invtel,</if>
            <if test="fInvaddr != null">f_invaddr,</if>
            <if test="fBankno != null">f_bankno,</if>
            <if test="fBankname != null">f_bankname,</if>
            <if test="fUbankno != null">f_ubankno,</if>
            <if test="fUbankname != null">f_ubankname,</if>
            <if test="fStatus != null and fStatus != ''">f_status,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="fTypename != null">f_typename,</if>
            <if test="loginAccount != null">login_account,</if>
            <if test="creditLv != null">credit_lv,</if>
            <if test="paymentDays != null">payment_days,</if>
            <if test="carNum != null">car_num,</if>
            <if test="headOffice != null">head_office,</if>
            <if test="registerdCapital != null">registerd_capital,</if>
            <if test="legalPerson != null">legal_person,</if>
            <if test="insdustry != null">insdustry,</if>
            <if test="creditNum != null">credit_num,</if>
            <if test="taxpayerNum != null">taxpayer_num,</if>
            <if test="industryCommerceNum != null">industry_commerce_num,</if>
            <if test="organizationNum != null">organization_num,</if>
            <if test="registerOrganization != null">register_organization,</if>
            <if test="dateOfEstablishment != null">date_of_establishment,</if>
            <if test="companyType != null">company_type,</if>
            <if test="businessDeadline != null">business_deadline,</if>
            <if test="businessArea != null">business_area,</if>
            <if test="annualDate != null">annual_date,</if>
            <if test="registerdAddress != null">registerd_address,</if>
            <if test="manageScope != null">manage_scope,</if>
            <if test="deptId != null">dept_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fPid != null and fPid != ''">#{fPid},</if>
            <if test="fTypeid != null and fTypeid != ''">#{fTypeid},</if>
            <if test="fNo != null and fNo != ''">#{fNo},</if>
            <if test="fName != null and fName != ''">#{fName},</if>
            <if test="fCname != null">#{fCname},</if>
            <if test="fEname != null">#{fEname},</if>
            <if test="fTel != null">#{fTel},</if>
            <if test="fFax != null">#{fFax},</if>
            <if test="fEmail != null">#{fEmail},</if>
            <if test="fManage != null">#{fManage},</if>
            <if test="fAddr != null">#{fAddr},</if>
            <if test="fEaddr != null">#{fEaddr},</if>
            <if test="fScale != null">#{fScale},</if>
            <if test="fProvince != null">#{fProvince},</if>
            <if test="fCity != null">#{fCity},</if>
            <if test="fStltypeid != null">#{fStltypeid},</if>
            <if test="fStldays != null">#{fStldays},</if>
            <if test="fContractno != null">#{fContractno},</if>
            <if test="fContractb != null">#{fContractb},</if>
            <if test="fContracte != null">#{fContracte},</if>
            <if test="fTax != null">#{fTax},</if>
            <if test="fInvtel != null">#{fInvtel},</if>
            <if test="fInvaddr != null">#{fInvaddr},</if>
            <if test="fBankno != null">#{fBankno},</if>
            <if test="fBankname != null">#{fBankname},</if>
            <if test="fUbankno != null">#{fUbankno},</if>
            <if test="fUbankname != null">#{fUbankname},</if>
            <if test="fStatus != null and fStatus != ''">#{fStatus},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="fTypename != null">#{fTypename},</if>
            <if test="loginAccount != null">#{loginAccount},</if>
            <if test="creditLv != null">#{creditLv},</if>
            <if test="paymentDays != null">#{paymentDays},</if>
            <if test="carNum != null">#{carNum},</if>
            <if test="headOffice != null">#{headOffice},</if>
            <if test="registerdCapital != null">#{registerdCapital},</if>
            <if test="legalPerson != null">#{legalPerson},</if>
            <if test="insdustry != null">#{insdustry},</if>
            <if test="creditNum != null">#{creditNum},</if>
            <if test="taxpayerNum != null">#{taxpayerNum},</if>
            <if test="industryCommerceNum != null">#{industryCommerceNum},</if>
            <if test="organizationNum != null">#{organizationNum},</if>
            <if test="registerOrganization != null">#{registerOrganization},</if>
            <if test="dateOfEstablishment != null">#{dateOfEstablishment},</if>
            <if test="companyType != null">#{companyType},</if>
            <if test="businessDeadline != null">#{businessDeadline},</if>
            <if test="businessArea != null">#{businessArea},</if>
            <if test="annualDate != null">#{annualDate},</if>
            <if test="registerdAddress != null">#{registerdAddress},</if>
            <if test="manageScope != null">#{manageScope},</if>
            <if test="deptId != null">#{deptId},</if>
        </trim>
    </insert>

    <update id="updateTCorps" parameterType="TCorps">
        update t_corps
        <trim prefix="SET" suffixOverrides=",">
            <if test="fPid != null">f_pid = #{fPid},</if>
            <if test="fTypeid != null">f_typeid = #{fTypeid},</if>
            <if test="fNo != null and fNo != ''">f_no = #{fNo},</if>
            <if test="fName != null and fName != ''">f_name = #{fName},</if>
            <if test="fCname != null">f_cname = #{fCname},</if>
            <if test="fEname != null">f_ename = #{fEname},</if>
            <if test="fTel != null">f_tel = #{fTel},</if>
            <if test="fFax != null">f_fax = #{fFax},</if>
            <if test="fEmail != null">f_email = #{fEmail},</if>
            <if test="fManage != null">f_manage = #{fManage},</if>
            <if test="fAddr != null">f_addr = #{fAddr},</if>
            <if test="fEaddr != null">f_eaddr = #{fEaddr},</if>
            <if test="fScale != null">f_scale = #{fScale},</if>
            <if test="fProvince != null">f_province = #{fProvince},</if>
            <if test="fCity != null">f_city = #{fCity},</if>
            <if test="fStltypeid != null">f_stltypeid = #{fStltypeid},</if>
            <if test="fStldays != null">f_stldays = #{fStldays},</if>
            <if test="fContractno != null">f_contractno = #{fContractno},</if>
            <if test="fContractb != null">f_contractb = #{fContractb},</if>
            <if test="fContracte != null">f_contracte = #{fContracte},</if>
            <if test="fTax != null">f_tax = #{fTax},</if>
            <if test="fInvtel != null">f_invtel = #{fInvtel},</if>
            <if test="fInvaddr != null">f_invaddr = #{fInvaddr},</if>
            <if test="fBankno != null">f_bankno = #{fBankno},</if>
            <if test="fBankname != null">f_bankname = #{fBankname},</if>
            <if test="fUbankno != null">f_ubankno = #{fUbankno},</if>
            <if test="fUbankname != null">f_ubankname = #{fUbankname},</if>
            <if test="fStatus != null and fStatus != ''">f_status = #{fStatus},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="fTypename != null">f_typename = #{fTypename},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
        </trim>
        where f_id = #{fId}
    </update>

    <delete id="deleteTCorpsById" parameterType="Long">
        delete from t_corps where f_id = #{fId}
    </delete>

    <delete id="deleteTCorpsByIds" parameterType="String">
        delete from t_corps where f_id in
        <foreach item="fId" collection="array" open="(" separator="," close=")">
            #{fId}
        </foreach>
    </delete>

    <select id="checkFNoUnique" parameterType="String" resultMap="TCorpsResult">
	    select f_id,f_no from t_corps where f_no = #{fNo} limit 1
    </select>

    <select id="checkUFNnameUnique" parameterType="String" resultMap="TCorpsResult">
        select f_id,f_name from t_corps where f_name = #{fAame} limit 1
    </select>

    <select id="checkUFCnameUnique" parameterType="String" resultMap="TCorpsResult">
        select f_id,f_addr from t_corps where f_cname = #{fCname} limit 1
    </select>

    <select id="checkULoginAccountUnique" parameterType="String" resultMap="TCorpsResult">
        select f_id,f_addr from t_corps where login_account = #{loginAccount} limit 1
    </select>
    <select id="getClientName" parameterType="TCorps" resultType="map">
        SELECT
	        tc.f_id fId,
	        tc.f_name fName
        FROM
	        t_corps tc
	    WHERE
	    tc.f_status = '0'
        <if test="fName != null  and fName != ''"> and c.f_name like concat('%', #{fName}, '%')</if>
    </select>
    <select id="getClientFid" parameterType="string" resultType="long">
        SELECT
            tc.f_id
        FROM
            t_corps tc
                LEFT JOIN t_customer_contact ta
                          ON tc.f_id = ta.f_pid
        WHERE ta.f_tel = #{tel}
    </select>

    <select id="selectTCorpsListLimit200" parameterType="TCorps" resultMap="TCorpsResult">
        SELECT
            f_id,
            f_name
        FROM
            t_corps
        WHERE
            JSON_CONTAINS( f_typeid -> '$[*]', #{fTypeid}, '$')
            AND f_status = #{fStatus}
        ORDER BY CONVERT(f_name USING gbk) asc
        limit 1, 200
    </select>
    <select id="getClientMessage" parameterType="TCorps" resultMap="TCorpsResult">
        SELECT
            tc.*
        FROM
            t_corps tc
                LEFT JOIN t_customer_contact ta
                          ON tc.f_id = ta.f_pid
        WHERE ta.f_tel = #{fTel}
    </select>
    <select id="selectByIds" resultMap="TCorpsResult">
        select
            f_id, f_pid, f_typeid, f_no, f_name
        from
            t_corps
        where
            f_id in
            <foreach item="id" collection="ids" open="(" separator="," close=")">
                #{id}
            </foreach>
    </select>

</mapper>