<?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.frequency.klkaccount.mapper.KlkAccountMapper">

    <resultMap type="com.ruoyi.frequency.klkaccount.entity.KlkAccount" id="KlkAccountResult">
        <result property="id"    column="id"    />
        <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="receiverNo"    column="receiver_no"    />
        <result property="bindStatus"    column="bind_status"    />
        <result property="userId"    column="user_id"    />
        <result property="createOrderNo"    column="create_order_no"    />
        <result property="receiverName"    column="receiver_name"    />
        <result property="contactMobile"    column="contact_mobile"    />
        <result property="licenseNo"    column="license_no"    />
        <result property="licenseName"    column="license_name"    />
        <result property="legalPersonName"    column="legal_person_name"    />
        <result property="legalPersonCertificateType"    column="legal_person_certificate_type"    />
        <result property="legalPersonCertificateNo"    column="legal_person_certificate_no"    />
        <result property="acctNo"    column="acct_no"    />
        <result property="acctName"    column="acct_name"    />
        <result property="acctTypeCode"    column="acct_type_code"    />
        <result property="acctCertificateType"    column="acct_certificate_type"    />
        <result property="acctCertificateNo"    column="acct_certificate_no"    />
        <result property="acctOpenBankCode"    column="acct_open_bank_code"    />
        <result property="acctOpenBankName"    column="acct_open_bank_name"    />
        <result property="acctClearBankCode"    column="acct_clear_bank_code"    />
        <result property="bindOrderNo"    column="bind_order_no"    />
        <association property="userInfo"    column="user_id" javaType="com.ruoyi.vo.UserInfo" resultMap="userInfo" />
    </resultMap>

    <resultMap id="userInfo" type="com.ruoyi.vo.UserInfo">
        <id     property="userId"    column="user_id"     />
        <result property="userType"  column="user_type"   />
        <result property="idNo"  column="id_no"   />
        <result property="nickname"  column="nickname"   />
        <result property="avatar" column="avatar"   />
        <result property="mobile" column="mobile"   />
    </resultMap>
    
    
    <sql id="selectKlkAccountVo">
        select
            t.id ,
            t.del_flag ,
            t.create_by ,
            t.create_time ,
            t.update_by ,
            t.update_time ,
            t.receiver_no ,
            t.bind_status ,
            t.user_id ,
            t.create_order_no ,
            t.receiver_name ,
            t.contact_mobile ,
            t.license_no ,
            t.license_name ,
            t.legal_person_name ,
            t.legal_person_certificate_type ,
            t.legal_person_certificate_no ,
            t.acct_no ,
            t.acct_name ,
            t.acct_type_code ,
            t.acct_certificate_type ,
            t.acct_certificate_no ,
            t.acct_open_bank_code ,
            t.acct_open_bank_name ,
            t.acct_clear_bank_code ,
            t.bind_order_no ,
            u.user_type,
            u.id_no,
            u.mobile,
            u.avatar,
            u.nickname
        from t_klk_account AS t
                LEFT JOIN t_user AS u ON t.user_id = u.id
    </sql>

    <select id="selectKlkAccountList" parameterType="com.ruoyi.frequency.klkaccount.entity.KlkAccount" resultMap="KlkAccountResult">
        <include refid="selectKlkAccountVo"/>
        <where> AND t.del_flag != 2
            <if test="receiverNo != null  and receiverNo != ''"> and t.receiver_no = #{receiverNo}</if>
            <if test="bindStatus != null "> and t.bind_status = #{bindStatus}</if>
            <if test="userId != null "> and t.user_id = #{userId}</if>
            <if test="createOrderNo != null  and createOrderNo != ''"> and t.create_order_no = #{createOrderNo}</if>
            <if test="receiverName != null  and receiverName != ''"> and t.receiver_name like concat('%', #{receiverName}, '%')</if>
            <if test="contactMobile != null  and contactMobile != ''"> and t.contact_mobile = #{contactMobile}</if>
            <if test="licenseNo != null  and licenseNo != ''"> and t.license_no = #{licenseNo}</if>
            <if test="licenseName != null  and licenseName != ''"> and t.license_name like concat('%', #{licenseName}, '%')</if>
            <if test="legalPersonName != null  and legalPersonName != ''"> and t.legal_person_name like concat('%', #{legalPersonName}, '%')</if>
            <if test="legalPersonCertificateType != null  and legalPersonCertificateType != ''"> and t.legal_person_certificate_type = #{legalPersonCertificateType}</if>
            <if test="legalPersonCertificateNo != null  and legalPersonCertificateNo != ''"> and t.legal_person_certificate_no = #{legalPersonCertificateNo}</if>
            <if test="acctNo != null  and acctNo != ''"> and t.acct_no = #{acctNo}</if>
            <if test="acctName != null  and acctName != ''"> and t.acct_name like concat('%', #{acctName}, '%')</if>
            <if test="acctTypeCode != null  and acctTypeCode != ''"> and t.acct_type_code = #{acctTypeCode}</if>
            <if test="acctCertificateType != null  and acctCertificateType != ''"> and t.acct_certificate_type = #{acctCertificateType}</if>
            <if test="acctCertificateNo != null  and acctCertificateNo != ''"> and t.acct_certificate_no = #{acctCertificateNo}</if>
            <if test="acctOpenBankCode != null  and acctOpenBankCode != ''"> and t.acct_open_bank_code = #{acctOpenBankCode}</if>
            <if test="acctOpenBankName != null  and acctOpenBankName != ''"> and t.acct_open_bank_name like concat('%', #{acctOpenBankName}, '%')</if>
            <if test="acctClearBankCode != null  and acctClearBankCode != ''"> and t.acct_clear_bank_code = #{acctClearBankCode}</if>
            <if test="bindOrderNo != null  and bindOrderNo != ''"> and t.bind_order_no = #{bindOrderNo}</if>
            <if test="delFlag != null and delFlag != ''"> and t.del_flag = #{delFlag}</if>
        </where>
        order by t.create_time desc
    </select>

    <select id="selectKlkAccountById" parameterType="Long" resultMap="KlkAccountResult">
        <include refid="selectKlkAccountVo"/>
        where t.id = #{id}
    </select>

    <insert id="insertKlkAccount" parameterType="com.ruoyi.frequency.klkaccount.entity.KlkAccount">
        insert into t_klk_account
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</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="receiverNo != null">receiver_no,</if>
            <if test="bindStatus != null">bind_status,</if>
            <if test="userId != null">user_id,</if>
            <if test="createOrderNo != null">create_order_no,</if>
            <if test="receiverName != null">receiver_name,</if>
            <if test="contactMobile != null">contact_mobile,</if>
            <if test="licenseNo != null">license_no,</if>
            <if test="licenseName != null">license_name,</if>
            <if test="legalPersonName != null">legal_person_name,</if>
            <if test="legalPersonCertificateType != null">legal_person_certificate_type,</if>
            <if test="legalPersonCertificateNo != null">legal_person_certificate_no,</if>
            <if test="acctNo != null">acct_no,</if>
            <if test="acctName != null">acct_name,</if>
            <if test="acctTypeCode != null">acct_type_code,</if>
            <if test="acctCertificateType != null">acct_certificate_type,</if>
            <if test="acctCertificateNo != null">acct_certificate_no,</if>
            <if test="acctOpenBankCode != null">acct_open_bank_code,</if>
            <if test="acctOpenBankName != null">acct_open_bank_name,</if>
            <if test="acctClearBankCode != null">acct_clear_bank_code,</if>
            <if test="bindOrderNo != null">bind_order_no,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</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="receiverNo != null">#{receiverNo},</if>
            <if test="bindStatus != null">#{bindStatus},</if>
            <if test="userId != null">#{userId},</if>
            <if test="createOrderNo != null">#{createOrderNo},</if>
            <if test="receiverName != null">#{receiverName},</if>
            <if test="contactMobile != null">#{contactMobile},</if>
            <if test="licenseNo != null">#{licenseNo},</if>
            <if test="licenseName != null">#{licenseName},</if>
            <if test="legalPersonName != null">#{legalPersonName},</if>
            <if test="legalPersonCertificateType != null">#{legalPersonCertificateType},</if>
            <if test="legalPersonCertificateNo != null">#{legalPersonCertificateNo},</if>
            <if test="acctNo != null">#{acctNo},</if>
            <if test="acctName != null">#{acctName},</if>
            <if test="acctTypeCode != null">#{acctTypeCode},</if>
            <if test="acctCertificateType != null">#{acctCertificateType},</if>
            <if test="acctCertificateNo != null">#{acctCertificateNo},</if>
            <if test="acctOpenBankCode != null">#{acctOpenBankCode},</if>
            <if test="acctOpenBankName != null">#{acctOpenBankName},</if>
            <if test="acctClearBankCode != null">#{acctClearBankCode},</if>
            <if test="bindOrderNo != null">#{bindOrderNo},</if>
        </trim>
    </insert>

    <update id="updateKlkAccount" parameterType="com.ruoyi.frequency.klkaccount.entity.KlkAccount">
        update t_klk_account
        <trim prefix="SET" suffixOverrides=",">
            <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="receiverNo != null">receiver_no = #{receiverNo},</if>
            <if test="bindStatus != null">bind_status = #{bindStatus},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="createOrderNo != null">create_order_no = #{createOrderNo},</if>
            <if test="receiverName != null">receiver_name = #{receiverName},</if>
            <if test="contactMobile != null">contact_mobile = #{contactMobile},</if>
            <if test="licenseNo != null">license_no = #{licenseNo},</if>
            <if test="licenseName != null">license_name = #{licenseName},</if>
            <if test="legalPersonName != null">legal_person_name = #{legalPersonName},</if>
            <if test="legalPersonCertificateType != null">legal_person_certificate_type = #{legalPersonCertificateType},</if>
            <if test="legalPersonCertificateNo != null">legal_person_certificate_no = #{legalPersonCertificateNo},</if>
            <if test="acctNo != null">acct_no = #{acctNo},</if>
            <if test="acctName != null">acct_name = #{acctName},</if>
            <if test="acctTypeCode != null">acct_type_code = #{acctTypeCode},</if>
            <if test="acctCertificateType != null">acct_certificate_type = #{acctCertificateType},</if>
            <if test="acctCertificateNo != null">acct_certificate_no = #{acctCertificateNo},</if>
            <if test="acctOpenBankCode != null">acct_open_bank_code = #{acctOpenBankCode},</if>
            <if test="acctOpenBankName != null">acct_open_bank_name = #{acctOpenBankName},</if>
            <if test="acctClearBankCode != null">acct_clear_bank_code = #{acctClearBankCode},</if>
            <if test="bindOrderNo != null">bind_order_no = #{bindOrderNo},</if>
        </trim>
        where id = #{id}
    </update>
                                                                                                                        </mapper>