const { PrismaClient } = require('@prisma/client') const prisma = new PrismaClient() async function findUserByPhone() { try { console.log('🔍 ИЩЕМ ПОЛЬЗОВАТЕЛЯ ПО РАЗНЫМ ВАРИАНТАМ НОМЕРА...') const phoneVariants = [ '+7 (999) 999-99-99', '+79999999999', '79999999999', '9999999999', '+7(999)999-99-99', '+7 999 999 99 99' ] for (const phone of phoneVariants) { console.log(`\nПроверяем: "${phone}"`) const user = await prisma.user.findFirst({ where: { phone: phone }, include: { organization: true } }) if (user) { console.log('✅ НАЙДЕН!') console.log(' ID:', user.id) console.log(' Телефон:', user.phone) console.log(' Организация:', user.organization?.name || 'Нет') console.log(' Тип:', user.organization?.type || 'Нет') return user } } console.log('\n❌ Не найден ни по одному варианту') // Поищем похожие номера console.log('\n🔍 ИЩЕМ ПОХОЖИЕ НОМЕРА (содержащие 9999):') const similarUsers = await prisma.user.findMany({ where: { phone: { contains: '9999' } }, include: { organization: true }, take: 10 }) if (similarUsers.length > 0) { console.log(`\nНайдено ${similarUsers.length} пользователей с похожими номерами:`) similarUsers.forEach((user, index) => { console.log(`${index + 1}. ${user.phone} - ${user.organization?.name || 'Без организации'} (${user.organization?.type || 'Неизвестный тип'})`) }) } else { console.log('\nПохожих номеров не найдено') } } catch (error) { console.error('❌ Ошибка:', error.message) } finally { await prisma.$disconnect() } } findUserByPhone()