<?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.mmc.iuav.user.dao.fdd.UserFddAuthDao">
    <resultMap id="appUserFddResultMap" type="com.mmc.iuav.user.entity.fdd.UserFddDO">
        <id property="id" column="id"/>
        <result property="unionId" column="union_id"/>
        <result property="customerId" column="customer_id"/>
        <result property="personVerifyStatus" column="person_verify_status"/>
        <result property="entVerifyStatus" column="ent_verify_status"/>
        <result property="accountType" column="account_type"/>
        <result property="updateTime" column="update_time"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <insert id="insertAppUserFdd" parameterType="com.mmc.iuav.user.entity.fdd.UserFddDO"
            keyProperty="id" useGeneratedKeys="true">
        insert into user_fdd
        (union_id, customer_id, person_verify_status, ent_verify_status, account_type, create_time)
        values (#{unionId}, #{customerId}, #{personVerifyStatus}, #{entVerifyStatus}, #{accountType}, NOW())
    </insert>
    <insert id="insertVerifyInfo" useGeneratedKeys="true" keyProperty="id"
            parameterType="com.mmc.iuav.user.entity.fdd.FddVerifyInfoDO">
        insert into fdd_verify_info
            (user_fdd_id, customer_id, transaction_no, url, create_time)
        values (#{userFddId}, #{customerId}, #{transactionNo}, #{url}, NOW())
    </insert>
    <update id="updateCompanyCertStatus">
        update user_fdd
        set ent_verify_status = #{status}
        where customer_id = #{customerId}
    </update>
    <update id="updatePersonCertStatus">
        update user_fdd
        set person_verify_status = #{status}
        where customer_id = #{customerId}
    </update>
    <select id="checkRegisterFdd" resultType="com.mmc.iuav.user.entity.fdd.UserFddDO">
        select id,
               union_id,
               customer_id,
               person_verify_status,
               ent_verify_status,
               account_type,
               create_time,
               update_time
        from user_fdd
        where union_id = #{unionId}
          and account_type = #{flag}
          and is_deleted = 0
    </select>
    <select id="getVerifyUrl" resultType="com.mmc.iuav.user.entity.fdd.FddVerifyInfoDO">
        select id, user_fdd_id, customer_id, transaction_no, url, create_time, update_time
        from fdd_verify_info
        where customer_id = #{customerId}
    </select>
    <select id="getAppUserFddInfo" resultType="com.mmc.iuav.user.entity.fdd.UserFddDO">
        select id,
               customer_id,
               union_id,
               person_verify_status,
               ent_verify_status,
               account_type,
               create_time,
               update_time
        from user_fdd
        where union_id = #{unionId}
    </select>
    <select id="getAppUserFddInfoByCustomerId" resultType="com.mmc.iuav.user.entity.fdd.UserFddDO">
        select id,
               customer_id,
               union_id,
               person_verify_status,
               ent_verify_status,
               account_type,
               create_time,
               update_time
        from user_fdd
        where customer_id = #{customerId}
    </select>

</mapper>