
- ✅ Добавлено поле nameForSeller в FulfillmentConsumable для кастомизации названий - ✅ Добавлено поле inventoryId для связи между каталогом и складом - ✅ Реализована автосинхронизация FulfillmentConsumableInventory → FulfillmentConsumable - ✅ Обновлен UI с колонкой "Название для селлера" в /fulfillment/services/consumables - ✅ Исправлены GraphQL запросы (удалено поле description, добавлены новые поля) - ✅ Создан скрипт sync-inventory-to-catalog.ts для миграции существующих данных - ✅ Добавлена техническая документация архитектуры системы инвентаря - ✅ Создан отчет о статусе миграции V1→V2 с детальным планом 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
206 lines
7.0 KiB
JavaScript
206 lines
7.0 KiB
JavaScript
// Скрипт для создания тестовых данных V2
|
||
import { PrismaClient } from '@prisma/client'
|
||
|
||
const prisma = new PrismaClient()
|
||
|
||
async function seedV2TestData() {
|
||
try {
|
||
console.warn('🌱 Создание тестовых данных для V2 системы...')
|
||
|
||
// Найдем фулфилмент организацию
|
||
const fulfillment = await prisma.organization.findFirst({
|
||
where: { type: 'FULFILLMENT' }
|
||
})
|
||
|
||
if (!fulfillment) {
|
||
throw new Error('❌ Фулфилмент организация не найдена')
|
||
}
|
||
|
||
console.warn(`✅ Найдена фулфилмент организация: ${fulfillment.name} (${fulfillment.id})`)
|
||
|
||
// Создаем тестовые услуги
|
||
console.warn('📋 Создание тестовых услуг...')
|
||
const services = await Promise.all([
|
||
prisma.fulfillmentService.upsert({
|
||
where: { id: 'test-service-1' },
|
||
update: {},
|
||
create: {
|
||
id: 'test-service-1',
|
||
fulfillmentId: fulfillment.id,
|
||
name: 'Упаковка товаров',
|
||
description: 'Профессиональная упаковка с пузырчатой пленкой',
|
||
price: 50.00,
|
||
unit: 'шт',
|
||
isActive: true,
|
||
sortOrder: 1
|
||
}
|
||
}),
|
||
prisma.fulfillmentService.upsert({
|
||
where: { id: 'test-service-2' },
|
||
update: {},
|
||
create: {
|
||
id: 'test-service-2',
|
||
fulfillmentId: fulfillment.id,
|
||
name: 'Маркировка товаров',
|
||
description: 'Наклейка штрих-кодов и этикеток',
|
||
price: 15.00,
|
||
unit: 'шт',
|
||
isActive: true,
|
||
sortOrder: 2
|
||
}
|
||
}),
|
||
prisma.fulfillmentService.upsert({
|
||
where: { id: 'test-service-3' },
|
||
update: {},
|
||
create: {
|
||
id: 'test-service-3',
|
||
fulfillmentId: fulfillment.id,
|
||
name: 'Фотосъемка товаров',
|
||
description: 'Профессиональная предметная съемка',
|
||
price: 200.00,
|
||
unit: 'шт',
|
||
isActive: true,
|
||
sortOrder: 3
|
||
}
|
||
})
|
||
])
|
||
console.warn(`✅ Создано ${services.length} тестовых услуг`)
|
||
|
||
// Создаем тестовые расходники
|
||
console.warn('📦 Создание тестовых расходников...')
|
||
const consumables = await Promise.all([
|
||
prisma.fulfillmentConsumable.upsert({
|
||
where: { id: 'test-consumable-1' },
|
||
update: {},
|
||
create: {
|
||
id: 'test-consumable-1',
|
||
fulfillmentId: fulfillment.id,
|
||
name: 'Коробки картонные 20x15x10',
|
||
article: 'BOX-001',
|
||
description: 'Стандартные коробки для упаковки мелких товаров',
|
||
pricePerUnit: 25.50,
|
||
unit: 'шт',
|
||
minStock: 20,
|
||
currentStock: 150,
|
||
isAvailable: true,
|
||
sortOrder: 1
|
||
}
|
||
}),
|
||
prisma.fulfillmentConsumable.upsert({
|
||
where: { id: 'test-consumable-2' },
|
||
update: {},
|
||
create: {
|
||
id: 'test-consumable-2',
|
||
fulfillmentId: fulfillment.id,
|
||
name: 'Пузырчатая пленка',
|
||
article: 'BUBBLE-001',
|
||
description: 'Защитная пленка для хрупких товаров',
|
||
pricePerUnit: 12.30,
|
||
unit: 'м',
|
||
minStock: 50,
|
||
currentStock: 500,
|
||
isAvailable: true,
|
||
sortOrder: 2
|
||
}
|
||
}),
|
||
prisma.fulfillmentConsumable.upsert({
|
||
where: { id: 'test-consumable-3' },
|
||
update: {},
|
||
create: {
|
||
id: 'test-consumable-3',
|
||
fulfillmentId: fulfillment.id,
|
||
name: 'Скотч упаковочный',
|
||
article: 'TAPE-001',
|
||
description: 'Прозрачный упаковочный скотч 48мм',
|
||
pricePerUnit: 8.75,
|
||
unit: 'шт',
|
||
minStock: 10,
|
||
currentStock: 75,
|
||
isAvailable: true,
|
||
sortOrder: 3
|
||
}
|
||
}),
|
||
prisma.fulfillmentConsumable.upsert({
|
||
where: { id: 'test-consumable-4' },
|
||
update: {},
|
||
create: {
|
||
id: 'test-consumable-4',
|
||
fulfillmentId: fulfillment.id,
|
||
name: 'Этикетки самоклеящиеся',
|
||
article: 'LABEL-001',
|
||
description: 'Белые этикетки для маркировки',
|
||
pricePerUnit: 5.20,
|
||
unit: 'лист',
|
||
minStock: 5,
|
||
currentStock: 0,
|
||
isAvailable: false,
|
||
sortOrder: 4
|
||
}
|
||
})
|
||
])
|
||
console.warn(`✅ Создано ${consumables.length} тестовых расходников`)
|
||
|
||
// Создаем тестовые логистические маршруты
|
||
console.warn('🚚 Создание тестовых логистических маршрутов...')
|
||
const logistics = await Promise.all([
|
||
prisma.fulfillmentLogistics.upsert({
|
||
where: { id: 'test-logistics-1' },
|
||
update: {},
|
||
create: {
|
||
id: 'test-logistics-1',
|
||
fulfillmentId: fulfillment.id,
|
||
fromLocation: 'Москва',
|
||
toLocation: 'Санкт-Петербург',
|
||
priceUnder1m3: 800.00,
|
||
priceOver1m3: 1200.00,
|
||
estimatedDays: 2,
|
||
description: 'Экспресс доставка до двери',
|
||
isActive: true,
|
||
sortOrder: 1
|
||
}
|
||
}),
|
||
prisma.fulfillmentLogistics.upsert({
|
||
where: { id: 'test-logistics-2' },
|
||
update: {},
|
||
create: {
|
||
id: 'test-logistics-2',
|
||
fulfillmentId: fulfillment.id,
|
||
fromLocation: 'Москва',
|
||
toLocation: 'Казань',
|
||
priceUnder1m3: 600.00,
|
||
priceOver1m3: 900.00,
|
||
estimatedDays: 3,
|
||
description: 'Стандартная доставка',
|
||
isActive: true,
|
||
sortOrder: 2
|
||
}
|
||
}),
|
||
prisma.fulfillmentLogistics.upsert({
|
||
where: { id: 'test-logistics-3' },
|
||
update: {},
|
||
create: {
|
||
id: 'test-logistics-3',
|
||
fulfillmentId: fulfillment.id,
|
||
fromLocation: 'Санкт-Петербург',
|
||
toLocation: 'Новосибирск',
|
||
priceUnder1m3: 1500.00,
|
||
priceOver1m3: 2200.00,
|
||
estimatedDays: 5,
|
||
description: 'Межрегиональная доставка',
|
||
isActive: true,
|
||
sortOrder: 3
|
||
}
|
||
})
|
||
])
|
||
console.warn(`✅ Создано ${logistics.length} тестовых логистических маршрутов`)
|
||
|
||
console.warn('🎉 Все тестовые данные V2 созданы успешно!')
|
||
|
||
} catch (error) {
|
||
console.error('❌ Ошибка при создании тестовых данных:', error)
|
||
} finally {
|
||
await prisma.$disconnect()
|
||
}
|
||
}
|
||
|
||
seedV2TestData() |