const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();

async function checkUsers() {
  try {
    const users = await prisma.user.findMany();
    console.log('用户总数:', users.length);
    console.log('用户列表:');
    users.forEach(u => {
      console.log(`  ID: ${u.id}, 手机: ${u.phone}, 会员等级: ${u.memberLevel}`);
    });
    
    if (users.length === 0) {
      console.log('\n数据库为空，需要创建测试用户...');
      // 创建测试用户
      const testUser = await prisma.user.create({
        data: {
          phone: '13812341234',
          memberLevel: 0,
          dailyUsage: 0,
          lastUsageDate: new Date().toISOString().slice(0, 10)
        }
      });
      console.log('✅ 测试用户创建成功:', testUser);
    }
  } catch (error) {
    console.error('错误:', error);
  } finally {
    await prisma.$disconnect();
  }
}

checkUsers();
