<?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="cn.pluss.platform.mapper.MerchantPluginMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.pluss.platform.entity.MerchantPlugin">
        <id column="id" property="id" />
        <result column="channel" property="channel" />
        <result column="userId" property="userId" />
        <result column="pluginId" property="pluginId" />
        <result column="status" property="status" />
        <result column="thirdStatus" property="thirdStatus" />
        <result column="applicationId" property="applicationId" />
        <result column="remark" property="remark" />
        <result column="createTime" property="createTime" />
        <result column="updateTime" property="updateTime" />
        <result column="extra" property="extra" />
    </resultMap>
    
    <select id="selectValidMerchantPlugin" resultType="cn.pluss.platform.entity.MerchantPlugin">
        SELECT * FROM tb_pluss_merchant_plugin t WHERE userId = #{userId}
    </select>

    <select id="getRyxNoCertMerchant" resultType="cn.pluss.platform.entity.MerchantPlugin">
        SELECT t1.* FROM tb_pluss_merchant_plugin t1
            LEFT JOIN tb_pluss_user_app ua ON t1.userId = ua.userId
            LEFT JOIN tb_pluss_sub_merchant_apply_order t2 ON ua.merchantCode = t2.merchantCode
            AND t1.channel = t2.channelId
        WHERE t1.channel = 31 AND t1.`status` = 3 AND t2.infoQrcode IS NULL
    </select>
</mapper>
