-- 检查积分记录数据

-- 查看最近的积分记录
SELECT 
    id,
    user_id,
    type as '类型',
    points as '积分数量',
    balance as '余额',
    source as '来源',
    description as '描述',
    create_time as '创建时间'
FROM points_record 
ORDER BY id DESC 
LIMIT 20;

-- 统计各类型的积分记录
SELECT 
    type as '类型',
    COUNT(*) as '记录数',
    SUM(points) as '总积分',
    AVG(points) as '平均积分',
    MIN(points) as '最小值',
    MAX(points) as '最大值'
FROM points_record 
GROUP BY type;

-- 查看描述中包含"赠送"的记录
SELECT 
    id,
    type as '类型',
    points as '积分数量',
    description as '描述'
FROM points_record 
WHERE description LIKE '%赠送%'
ORDER BY id DESC;
