| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?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="shop.alien.mapper.StorePlatformUserRoleMapper">
- <!-- 根据店铺ID查询子账号列表(连表查询) -->
- <select id="querySubAccounts" resultType="shop.alien.entity.store.vo.SubAccountVo">
- SELECT
- spur.id AS id,
- sur.id AS userId,
- spur.account_name AS accountName,
- sur.phone AS phone,
- spr.role_id AS roleId,
- spr.role_name AS roleName,
- spur.store_id AS storeId,
- 0 AS permissionCount
- FROM store_platform_user_role spur
- INNER JOIN store_user sur ON spur.user_id = sur.id
- LEFT JOIN store_platform_role spr ON spur.role_id = spr.role_id
- WHERE spur.store_id = #{storeId}
- AND sur.delete_flag = 0
- AND spur.delete_flag = 0
- <if test="accountName != null and accountName != ''">
- AND (spur.account_name LIKE CONCAT('%', #{accountName}, '%') )
- </if>
- <if test="phone != null and phone != ''">
- AND sur.phone LIKE CONCAT('%', #{phone}, '%')
- </if>
- <if test="roleName != null and roleName != ''">
- AND spr.role_name LIKE CONCAT('%', #{roleName}, '%')
- </if>
- ORDER BY spur.created_time DESC
- </select>
- <!-- 查询所有子账号信息(包含主账号电话) -->
- <select id="queryAllSubAccounts" resultType="shop.alien.entity.store.vo.SubAccountListVo">
- SELECT
- su_main.id AS mainAccountId,
- su_main.phone AS mainAccountPhone,
- sur.id AS userId,
- sur.phone AS phone,
- spur.id AS subAccountId,
- spur.account_name AS accountName,
- spur.store_id AS storeId,
- spr.role_id AS roleId,
- spr.role_name AS roleName,
- spur.created_time AS createdTime,
- spur.status AS status
- FROM store_platform_user_role spur
- INNER JOIN store_user sur ON spur.user_id = sur.id
- LEFT JOIN store_user su_main ON spur.store_id = su_main.store_id
- AND su_main.account_type = 1
- AND su_main.delete_flag = 0
- LEFT JOIN store_platform_role spr ON spur.role_id = spr.role_id
- WHERE spur.delete_flag = 0
- AND sur.delete_flag = 0
- <if test="accountId != null and accountId != ''">
- AND (sur.id LIKE CONCAT('%', #{accountId}, '%')
- OR su_main.id LIKE CONCAT('%', #{accountId}, '%'))
- </if>
- <if test="phone != null and phone != ''">
- AND sur.phone LIKE CONCAT('%', #{phone}, '%')
- </if>
- <if test="status != null">
- AND spur.status = #{status}
- </if>
- ORDER BY spur.created_time DESC
- </select>
- </mapper>
|