-- 检查主播统计数据
-- 查看所有主播的统计信息

SELECT 
    u.uid as userId,
    u.nickname,
    u.phone,
    u.streamer_level as streamerLevel,
    -- 粉丝数
    (SELECT COUNT(*) 
     FROM eb_follow_record f 
     WHERE f.followed_id = u.uid 
     AND f.follow_status IN ('1', '关注') 
     AND f.is_deleted = 0) as fansCount,
    -- 直播间数
    (SELECT COUNT(*) 
     FROM eb_live_room r 
     WHERE r.uid = u.uid) as roomCount,
    -- 总点赞数
    (SELECT COALESCE(SUM(r.like_count), 0) 
     FROM eb_live_room r 
     WHERE r.uid = u.uid) as totalLikeCount,
    -- 本月直播次数
    (SELECT COUNT(*) 
     FROM eb_live_room r 
     WHERE r.uid = u.uid 
     AND DATE_FORMAT(r.create_time, '%Y-%m') = DATE_FORMAT(NOW(), '%Y-%m')) as monthRooms
FROM eb_user u 
WHERE u.is_streamer = 1
ORDER BY u.uid;

-- 查看具体某个主播的详细信息（以uid=43为例）
SELECT 
    '粉丝记录' as type,
    COUNT(*) as count
FROM eb_follow_record 
WHERE followed_id = 43 
AND follow_status IN ('1', '关注') 
AND is_deleted = 0

UNION ALL

SELECT 
    '直播间' as type,
    COUNT(*) as count
FROM eb_live_room 
WHERE uid = 43

UNION ALL

SELECT 
    '总点赞数' as type,
    COALESCE(SUM(like_count), 0) as count
FROM eb_live_room 
WHERE uid = 43;
