Files
sfera-new/check-new-seller.js
Veronika Smirnova d19530a985 debug: добавить скрипты отладки и бэкапы для диагностики проблем
- api_keys_backup_1758196936364.json - резервная копия API ключей
- check-active-key.js - проверка активного API ключа
- check-all-keys.js - проверка всех API ключей в системе
- check-new-seller.js - проверка нового селлера
- test-api-key-save.js - тестирование сохранения API ключей
- test-graphql-stats.js - тестирование GraphQL статистики
- test-resolver-direct.js - прямое тестирование резолверов
- test-sidebar.html - тестирование сайдбара
- test-statistics-direct.js - прямое тестирование статистики

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-18 21:32:23 +03:00

72 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
async function checkNewSeller() {
try {
// Найдем пользователя с номером 79988888888
const user = await prisma.user.findFirst({
where: { phone: '79988888888' },
include: {
organization: {
include: {
apiKeys: {
where: { marketplace: 'WILDBERRIES' },
orderBy: { createdAt: 'desc' },
},
},
},
},
})
if (!user) {
console.log('❌ Пользователь 79988888888 не найден')
return
}
console.log('👤 НОВЫЙ ПОЛЬЗОВАТЕЛЬ 79988888888:')
console.log('- ID:', user.id)
console.log('- Телефон:', user.phone)
console.log('- Организация:', user.organization?.name || 'НЕ ПРИВЯЗАНА')
if (user.organization) {
console.log('\n🏢 ОРГАНИЗАЦИЯ:')
console.log('- ID:', user.organization.id)
console.log('- Название:', user.organization.name)
console.log('- Тип:', user.organization.type)
console.log('- WB ключей:', user.organization.apiKeys.length)
if (user.organization.apiKeys.length > 0) {
console.log('\n🔑 API КЛЮЧИ WILDBERRIES:')
user.organization.apiKeys.forEach((key, index) => {
console.log(`\n--- КЛЮЧ ${index + 1} ---`)
console.log('- ID:', key.id)
console.log('- Длина:', key.apiKey?.length)
console.log('- Тип:', key.apiKey?.startsWith('eyJ') ? 'Валидный JWT' : 'Тестовый')
console.log('- Активен:', key.isActive)
console.log('- Создан:', key.createdAt.toISOString())
console.log('- Данные валидации:', JSON.stringify(key.validationData, null, 2))
})
// Найдем самый новый валидный ключ
const validKey = user.organization.apiKeys.find((key) => key.apiKey && key.apiKey.length > 100 && key.isActive)
if (validKey) {
console.log('\n✅ СТАТУС: Есть валидный API ключ')
console.log('- Можно получать статистику Wildberries')
} else {
console.log('\n⚠ СТАТУС: Только тестовые ключи')
console.log('- Статистика будет пустой')
}
} else {
console.log('\n❌ API КЛЮЧИ НЕ НАЙДЕНЫ')
}
}
} catch (error) {
console.error('❌ Ошибка:', error)
} finally {
await prisma.$disconnect()
}
}
checkNewSeller()