<?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.fzm.mall.server.admin.home_page.dao.MerchantMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.fzm.mall.server.admin.home_page.model.Merchant">
        <id column="id" property="id"/>
        <result column="merchant_id" property="merchantId"/>
        <result column="prefix" property="prefix"/>
        <result column="register_phone" property="registerPhone"/>
        <result column="register_area" property="registerArea"/>
        <result column="apply_phone" property="applyPhone"/>
        <result column="apply_name" property="applyName"/>
        <result column="id_card" property="idCard"/>
        <result column="front_card_img" property="frontCardImg"/>
        <result column="after_card_img" property="afterCardImg"/>
        <result column="post_address" property="postAddress"/>
        <result column="type" property="type"/>
        <result column="enterprise_name" property="enterpriseName"/>
        <result column="credit_code" property="creditCode"/>
        <result column="business_license" property="businessLicense"/>
        <result column="token_issue_addr" property="tokenIssueAddr"/>
        <result column="token_recover_addr" property="tokenRecoverAddr"/>
        <result column="external_token_addr" property="externalTokenAddr"/>
        <result column="qr_url" property="qrUrl"/>
        <result column="nft_addr" property="nftAddr"/>
        <result column="issue_addr_key" property="issueAddrKey"/>
        <result column="status" property="status"/>
        <result column="is_delete" property="del"/>
        <result column="delay_delivery" property="delayDelivery"/>
        <result column="reason" property="reason"/>
        <result column="last_login" property="lastLogin"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <select id="page" resultType="com.fzm.mall.server.admin.home_page.entity.vo.MerchantVO">
        SELECT
        merchant_id,register_phone,apply_name AS linkMan,level,id_card,type,status,enterprise_name,
        credit_code,front_card_img,after_card_img,business_license,create_time AS
        registerTime,last_login AS
        lastLoginTime
        FROM
        merchant
        <where>
            is_delete != 1
            <if test="merchantId!=null and merchantId!=''">
                merchant_id = #{merchantId}
            </if>
            <if test="account!=null and account!=''">
                AND
                register_phone = #{account}
            </if>
            <if test="linkMan!=null and linkMan!=''">
                <bind name="linkMan" value="'%' + linkMan + '%'"/>
                AND
                apply_name LIKE #{linkMan}
            </if>
            <if test="type != null">
                AND
                status = #{type}
            </if>
            <!--<if test="type == null">
                AND
                status = 0
                OR
                status = 1
            </if>-->
        </where>
        ORDER BY
        create_time
        DESC
    </select>

    <select id="read" resultType="com.fzm.mall.server.admin.goods_center.entity.vo.ExternalTokenVO">
        SELECT token_issue_addr AS externalTokenAddr, qr_url
        FROM merchant
        where merchant_id = #{merchantId}
    </select>
</mapper>
