76 lines
3.5 KiB
JavaScript
76 lines
3.5 KiB
JavaScript
const { sequelize } = require('./config/database');
|
|
|
|
async function fixTestData() {
|
|
try {
|
|
console.log('开始修复测试数据...');
|
|
|
|
// 添加installation_tasks测试数据
|
|
await sequelize.query(`
|
|
INSERT INTO installation_tasks (
|
|
applicationNumber, contractNumber, productName, customerName, idType, idNumber,
|
|
assetType, equipmentToInstall, installationStatus, taskGenerationTime, completionTime,
|
|
installationNotes, installerName, installerPhone, installationAddress,
|
|
createdBy, updatedBy, createdAt, updatedAt
|
|
) VALUES
|
|
('APP001', 'CON001', '养殖设备', '张三', 'ID_CARD', '110101199001010001',
|
|
'cattle', '耳标设备', 'pending', NOW(), NULL,
|
|
'测试安装任务', '安装员1', '13900139000', '北京市朝阳区农场',
|
|
2, 2, NOW(), NOW()),
|
|
('APP002', 'CON002', '种植设备', '李四', 'ID_CARD', '110101199002020002',
|
|
'sheep', '项圈设备', 'completed', NOW(), NOW(),
|
|
'测试安装任务2', '安装员2', '14000140000', '北京市海淀区农场',
|
|
2, 2, NOW(), NOW())
|
|
`, { type: sequelize.QueryTypes.RAW });
|
|
console.log('✅ 添加installation_tasks测试数据成功');
|
|
|
|
// 添加completed_supervisions测试数据
|
|
await sequelize.query(`
|
|
INSERT INTO completed_supervisions (
|
|
applicationNumber, contractNumber, productName, customerName, idType, idNumber,
|
|
assetType, assetQuantity, totalRepaymentPeriods, settlementStatus, settlementDate,
|
|
importTime, settlementAmount, remainingAmount, settlementNotes,
|
|
createdBy, updatedBy, createdAt, updatedAt
|
|
) VALUES
|
|
('APP001', 'CON001', '养殖贷款', '张三', 'ID_CARD', '110101199001010001',
|
|
'cattle', 10, 12, 'partial', '2024-01-15',
|
|
NOW(), 30000.00, 20000.00, '已结清部分',
|
|
2, 2, NOW(), NOW()),
|
|
('APP002', 'CON002', '种植贷款', '李四', 'ID_CARD', '110101199002020002',
|
|
'sheep', 20, 10, 'settled', '2024-01-20',
|
|
NOW(), 30000.00, 0.00, '已完全结清',
|
|
2, 2, NOW(), NOW())
|
|
`, { type: sequelize.QueryTypes.RAW });
|
|
console.log('✅ 添加completed_supervisions测试数据成功');
|
|
|
|
// 添加loan_applications测试数据
|
|
await sequelize.query(`
|
|
INSERT INTO loan_applications (
|
|
customer_name, customer_phone, customer_id_card, loan_amount, loan_term,
|
|
interest_rate, application_date, status
|
|
) VALUES
|
|
('张三', '13800138000', '110101199001010001', 50000.00, 12, 0.05, '2024-01-01', 'pending'),
|
|
('李四', '13900139000', '110101199002020002', 30000.00, 10, 0.06, '2024-01-02', 'approved')
|
|
`, { type: sequelize.QueryTypes.RAW });
|
|
console.log('✅ 添加loan_applications测试数据成功');
|
|
|
|
// 添加loan_contracts测试数据
|
|
await sequelize.query(`
|
|
INSERT INTO loan_contracts (
|
|
contract_number, customer_name, customer_phone, customer_id_card, loan_amount,
|
|
loan_term, interest_rate, contract_date, status
|
|
) VALUES
|
|
('CON001', '张三', '13800138000', '110101199001010001', 50000.00, 12, 0.05, '2024-01-01', 'active'),
|
|
('CON002', '李四', '13900139000', '110101199002020002', 30000.00, 10, 0.06, '2024-01-02', 'completed')
|
|
`, { type: sequelize.QueryTypes.RAW });
|
|
console.log('✅ 添加loan_contracts测试数据成功');
|
|
|
|
console.log('\n✅ 所有测试数据修复完成!');
|
|
} catch (error) {
|
|
console.error('❌ 修复测试数据失败:', error.message);
|
|
} finally {
|
|
await sequelize.close();
|
|
}
|
|
}
|
|
|
|
fixTestData();
|