<?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.MerchantStaffConnMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.pluss.platform.entity.MerchantStaffConn">
        <id column="id" property="id" />
        <result column="userId" property="userId" />
        <result column="merchantCode" property="merchantCode" />
        <result column="createTime" property="createTime" />
        <result column="updateTime" property="updateTime" />
    </resultMap>

    <select id="selectByUserId" resultType="cn.pluss.platform.vo.MerchantStaffConnVO">
        SELECT msc.*, mbi.alias, mi.picUrl imgUrl, mbi.address, IFNULL(sp.permissionBill, "1") permissionBill FROM tb_pluss_merchant_staff_conn msc
            LEFT JOIN tb_pluss_merchant_base_info mbi ON msc.merchantCode = mbi.merchantCode
            LEFT JOIN tb_pluss_merchant_image mi ON mi.merchantCode = mbi.merchantCode
            LEFT JOIN tb_pluss_staff_permission sp ON sp.userId = msc.userId AND sp.merchantCOde = msc.merchantCode
            WHERE msc.userId = #{userId} AND mi.photoType = '06'
    </select>

    <select id="getMercInfoByStaffId" resultType="cn.pluss.platform.entity.MerchantBaseInfo">
        SELECT mbi.alias,mbi.merchantCode,msc.isPushWxMessage as 'isPushWxMessage'
        from tb_pluss_merchant_staff_conn msc
        left join tb_pluss_merchant_base_info mbi on  msc.merchantCode = mbi.merchantCode
        where msc.userId = #{id} order by mbi.createDt asc
    </select>
</mapper>
