<?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.sunxung.factoring.mapper.financing.contract.SysCustomerMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.sunxung.factoring.entity.financing.contract.SysCustomer">
        <result column="id" property="id" />
        <result column="user_create" property="userCreate" />
        <result column="user_modified" property="userModified" />
        <result column="gmt_create" property="gmtCreate" />
        <result column="gmt_modified" property="gmtModified" />
        <result column="ent_business_id" property="entBusinessId" />
        <result column="auth_status" property="authStatus" />
        <result column="auto_sign_status" property="autoSignStatus" />
        <result column="auth_url" property="authUrl" />
        <result column="auto_sign_url" property="autoSignUrl" />
        <result column="fdd_customer_id" property="fddCustomerId" />
        <result column="certificate_sign_url" property="certificateSignUrl" />
        <result column="certificate_short_sign_url" property="certificateShortSignUrl"/>
        <result column="certificate_short_sign_url_create" property="certificateShortSignUrlCreate" />
        <result column="certificate_transaction_id" property="certificateTransactionId" />
        <result column="certificate_sign_status" property="certificateSignStatus" />
        <result column="certificate_file_id" property="certificateFileId" />
        <result column="certificate_supplement_report_file" property="certificateSupplementReportFile" />
    </resultMap>

    <select id="getByName" parameterType="java.lang.String" resultMap="BaseResultMap">
        SELECT
            t1.*
        FROM sys_customer t1
        LEFT JOIN c_enterprise t2 ON t1.ent_business_id = t2.id
        WHERE
            t2.corporate_name = #{value} AND t1.account_type = 2
    </select>
    <select id="getCustomerIdBySocialCreditCode" resultMap="BaseResultMap">
        SELECT
            t1.*
        FROM
            sys_customer t1
        LEFT JOIN c_enterprise t2 ON t1.ent_business_id = t2.id
        WHERE
            t2.social_credit_code = #{value} AND t1.account_type = 2
    </select>
    <select id="getCustomerPersonBySocialCreditCode" resultMap="BaseResultMap">
        SELECT
            t1.*
        FROM
            sys_customer t1
        LEFT JOIN electronic_person_info t2 ON t1.ent_business_id = t2.id
        WHERE
            t2.socialCreditCode = #{value} AND t1.account_type = 1
    </select>
</mapper>
