<?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="org.wfc.system.mapper.UKycMapper">

    <select id="selectKycByUserId" resultType="org.wfc.system.domain.vo.UKycUserVo">
        SELECT
			k.kyc_id,
            k.user_id,
            u.user_name,
            u.full_name as real_name,
            k.birth_date,
            k.id_type,
            k.id_file,
            k.identify_picture,
            k.`status`,
            k.description,
            <!-- u.`kyc_status` as user_kyc_status, -->
            k.create_time,
            k.update_time
        FROM
            u_kyc k
            LEFT JOIN u_user u ON u.user_id = k.user_id
        WHERE    
            u.del_flag = 0
            AND k.del_flag = 0
            <if test="item.status != null and item.status != ''">
                AND k.`status` = #{item.status}
            </if>
            <if test="item.createTimeStart != null and item.createTimeStart != ''">
                AND k.create_time &gt;= #{item.createTimeStart}
            </if>
            <if test="item.createTimeEnd != null and item.createTimeEnd != ''">
                AND k.create_time &lt;= #{item.createTimeEnd}
            </if>            
        ORDER BY
            k.create_time DESC
    </select>

	<update id="updateKycByUserId" parameterType="UKyc">
 		UPDATE u_kyc
 		<set>
			<if test="status != null and status != 0">status = #{status},</if>
 			<if test="description != null and description != ''">description = #{description},</if>
 			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  			update_time = sysdate()
 		</set>
 		WHERE user_id = #{userId}
	</update>

</mapper>
