<?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.limap.core.basic.mapper.BasicProfitSharingUserMapper">

    <!-- 查询分润用户基础信息列表，关联用户绑定设备信息 -->
    <select id="selectBasicInfoList" resultType="com.limap.core.basic.vo.SharingUserTaskVo">
        SELECT
            bpsu.user_id as userId,
            su.dept_id as deptId,
            su.user_name as userName,
            su.nick_name as nickName,
            su.phonenumber as tel,
            su.parent_id as parentId,
            bpsu.sharing_code as sharingCode,
            bpsu.om_ratio as omRatio,
            bpsu.control_ratio as controlRatio,
            bibi.device_name as deviceName,
            bibi.type as type
        FROM basic_profit_sharing_user bpsu
        LEFT JOIN sys_user su ON bpsu.user_id = su.user_id
        LEFT JOIN basic_user_bind_info bibi ON bpsu.user_id = bibi.user_id
        WHERE bibi.device_name IS NOT NULL
    </select>

    <!-- 查询缓存用的分润用户列表 -->
    <select id="selectCacheList" resultType="com.limap.core.basic.vo.SharingUserTaskVo">
        SELECT
            bpsu.user_id as userId,
            su.dept_id as deptId,
            su.user_name as userName,
            su.nick_name as nickName,
            su.phonenumber as tel,
            su.parent_id as parentId,
            bpsu.sharing_code as sharingCode,
            bpsu.om_ratio as omRatio,
            bpsu.control_ratio as controlRatio
        FROM basic_profit_sharing_user bpsu
        LEFT JOIN sys_user su ON bpsu.user_id = su.user_id
    </select>

</mapper>
