添加银行端后端接口
This commit is contained in:
207
bank-backend/scripts/seed-completed-supervisions.js
Normal file
207
bank-backend/scripts/seed-completed-supervisions.js
Normal file
@@ -0,0 +1,207 @@
|
||||
const { CompletedSupervision, User } = require('../models')
|
||||
|
||||
async function seedCompletedSupervisions() {
|
||||
try {
|
||||
console.log('开始创建监管任务已结项测试数据...')
|
||||
|
||||
// 获取第一个用户作为创建者
|
||||
const user = await User.findOne()
|
||||
if (!user) {
|
||||
console.error('未找到用户,请先创建用户')
|
||||
return
|
||||
}
|
||||
|
||||
const completedSupervisions = [
|
||||
{
|
||||
applicationNumber: 'APP2024001',
|
||||
contractNumber: 'LOAN2024001',
|
||||
productName: '生猪养殖贷',
|
||||
customerName: '张三',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4401XXXXXXXXXXXXXX',
|
||||
assetType: '生猪',
|
||||
assetQuantity: 500,
|
||||
totalRepaymentPeriods: 12,
|
||||
settlementStatus: 'settled',
|
||||
settlementDate: '2024-01-15',
|
||||
importTime: new Date('2024-01-15 10:30:00'),
|
||||
settlementAmount: 500000.00,
|
||||
remainingAmount: 0.00,
|
||||
settlementNotes: '贷款已全部结清',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024002',
|
||||
contractNumber: 'LOAN2024002',
|
||||
productName: '肉牛养殖贷',
|
||||
customerName: '李四',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4402XXXXXXXXXXXXXX',
|
||||
assetType: '肉牛',
|
||||
assetQuantity: 150,
|
||||
totalRepaymentPeriods: 24,
|
||||
settlementStatus: 'partial',
|
||||
settlementDate: '2024-01-20',
|
||||
importTime: new Date('2024-01-20 14:20:00'),
|
||||
settlementAmount: 300000.00,
|
||||
remainingAmount: 200000.00,
|
||||
settlementNotes: '部分结清,剩余20万待还',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024003',
|
||||
contractNumber: 'LOAN2024003',
|
||||
productName: '蛋鸡养殖贷',
|
||||
customerName: '王五',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4403XXXXXXXXXXXXXX',
|
||||
assetType: '蛋鸡',
|
||||
assetQuantity: 10000,
|
||||
totalRepaymentPeriods: 18,
|
||||
settlementStatus: 'unsettled',
|
||||
settlementDate: null,
|
||||
importTime: new Date('2024-01-10 09:15:00'),
|
||||
settlementAmount: null,
|
||||
remainingAmount: 800000.00,
|
||||
settlementNotes: '尚未结清',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024004',
|
||||
contractNumber: 'LOAN2024004',
|
||||
productName: '肉羊养殖贷',
|
||||
customerName: '赵六',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4404XXXXXXXXXXXXXX',
|
||||
assetType: '肉羊',
|
||||
assetQuantity: 300,
|
||||
totalRepaymentPeriods: 15,
|
||||
settlementStatus: 'settled',
|
||||
settlementDate: '2024-01-25',
|
||||
importTime: new Date('2024-01-25 16:45:00'),
|
||||
settlementAmount: 300000.00,
|
||||
remainingAmount: 0.00,
|
||||
settlementNotes: '贷款已全部结清',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024005',
|
||||
contractNumber: 'LOAN2024005',
|
||||
productName: '奶牛养殖贷',
|
||||
customerName: '孙七',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4405XXXXXXXXXXXXXX',
|
||||
assetType: '奶牛',
|
||||
assetQuantity: 100,
|
||||
totalRepaymentPeriods: 36,
|
||||
settlementStatus: 'partial',
|
||||
settlementDate: '2024-01-30',
|
||||
importTime: new Date('2024-01-30 11:20:00'),
|
||||
settlementAmount: 200000.00,
|
||||
remainingAmount: 400000.00,
|
||||
settlementNotes: '部分结清,剩余40万待还',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024006',
|
||||
contractNumber: 'LOAN2024006',
|
||||
productName: '肉鸭养殖贷',
|
||||
customerName: '周八',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4406XXXXXXXXXXXXXX',
|
||||
assetType: '肉鸭',
|
||||
assetQuantity: 5000,
|
||||
totalRepaymentPeriods: 12,
|
||||
settlementStatus: 'unsettled',
|
||||
settlementDate: null,
|
||||
importTime: new Date('2024-02-01 08:30:00'),
|
||||
settlementAmount: null,
|
||||
remainingAmount: 600000.00,
|
||||
settlementNotes: '尚未结清',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024007',
|
||||
contractNumber: 'LOAN2024007',
|
||||
productName: '肉鸡养殖贷',
|
||||
customerName: '吴九',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4407XXXXXXXXXXXXXX',
|
||||
assetType: '肉鸡',
|
||||
assetQuantity: 15000,
|
||||
totalRepaymentPeriods: 9,
|
||||
settlementStatus: 'settled',
|
||||
settlementDate: '2024-02-05',
|
||||
importTime: new Date('2024-02-05 14:15:00'),
|
||||
settlementAmount: 400000.00,
|
||||
remainingAmount: 0.00,
|
||||
settlementNotes: '贷款已全部结清',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024008',
|
||||
contractNumber: 'LOAN2024008',
|
||||
productName: '肉猪养殖贷',
|
||||
customerName: '郑十',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4408XXXXXXXXXXXXXX',
|
||||
assetType: '肉猪',
|
||||
assetQuantity: 800,
|
||||
totalRepaymentPeriods: 18,
|
||||
settlementStatus: 'partial',
|
||||
settlementDate: '2024-02-10',
|
||||
importTime: new Date('2024-02-10 10:00:00'),
|
||||
settlementAmount: 250000.00,
|
||||
remainingAmount: 350000.00,
|
||||
settlementNotes: '部分结清,剩余35万待还',
|
||||
createdBy: user.id
|
||||
}
|
||||
]
|
||||
|
||||
// 检查是否已存在数据
|
||||
const existingCount = await CompletedSupervision.count()
|
||||
if (existingCount > 0) {
|
||||
console.log(`监管任务已结项表已有 ${existingCount} 条数据,跳过创建`)
|
||||
return
|
||||
}
|
||||
|
||||
// 批量创建监管任务已结项
|
||||
await CompletedSupervision.bulkCreate(completedSupervisions)
|
||||
|
||||
console.log(`✅ 成功创建 ${completedSupervisions.length} 条监管任务已结项测试数据`)
|
||||
|
||||
// 显示创建的数据
|
||||
const createdTasks = await CompletedSupervision.findAll({
|
||||
include: [
|
||||
{
|
||||
model: User,
|
||||
as: 'creator',
|
||||
attributes: ['id', 'username', 'real_name']
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
console.log('创建的监管任务已结项数据:')
|
||||
createdTasks.forEach((task, index) => {
|
||||
console.log(`${index + 1}. ${task.applicationNumber} - ${task.customerName} - ${task.settlementStatus}`)
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
console.error('创建监管任务已结项测试数据失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 如果直接运行此脚本
|
||||
if (require.main === module) {
|
||||
seedCompletedSupervisions()
|
||||
.then(() => {
|
||||
console.log('监管任务已结项测试数据创建完成')
|
||||
process.exit(0)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('脚本执行失败:', error)
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = seedCompletedSupervisions
|
||||
207
bank-backend/scripts/seed-installation-tasks.js
Normal file
207
bank-backend/scripts/seed-installation-tasks.js
Normal file
@@ -0,0 +1,207 @@
|
||||
const { InstallationTask, User } = require('../models')
|
||||
|
||||
async function seedInstallationTasks() {
|
||||
try {
|
||||
console.log('开始创建待安装任务测试数据...')
|
||||
|
||||
// 获取第一个用户作为创建者
|
||||
const user = await User.findOne()
|
||||
if (!user) {
|
||||
console.error('未找到用户,请先创建用户')
|
||||
return
|
||||
}
|
||||
|
||||
const installationTasks = [
|
||||
{
|
||||
applicationNumber: 'APP2024001',
|
||||
contractNumber: 'LOAN2024001',
|
||||
productName: '生猪养殖贷',
|
||||
customerName: '张三',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4401XXXXXXXXXXXXXX',
|
||||
assetType: '生猪',
|
||||
equipmentToInstall: '耳标设备',
|
||||
installationStatus: 'pending',
|
||||
taskGenerationTime: new Date('2024-01-15 10:30:00'),
|
||||
completionTime: null,
|
||||
installationNotes: '需要安装耳标设备用于生猪监管',
|
||||
installerName: '李安装',
|
||||
installerPhone: '13800138001',
|
||||
installationAddress: '广东省广州市天河区某养殖场',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024002',
|
||||
contractNumber: 'LOAN2024002',
|
||||
productName: '肉牛养殖贷',
|
||||
customerName: '李四',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4402XXXXXXXXXXXXXX',
|
||||
assetType: '肉牛',
|
||||
equipmentToInstall: '项圈设备',
|
||||
installationStatus: 'in-progress',
|
||||
taskGenerationTime: new Date('2024-01-16 14:20:00'),
|
||||
completionTime: null,
|
||||
installationNotes: '安装项圈设备用于肉牛定位监管',
|
||||
installerName: '王安装',
|
||||
installerPhone: '13800138002',
|
||||
installationAddress: '广东省深圳市南山区某养殖场',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024003',
|
||||
contractNumber: 'LOAN2024003',
|
||||
productName: '蛋鸡养殖贷',
|
||||
customerName: '王五',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4403XXXXXXXXXXXXXX',
|
||||
assetType: '蛋鸡',
|
||||
equipmentToInstall: '监控设备',
|
||||
installationStatus: 'completed',
|
||||
taskGenerationTime: new Date('2024-01-10 09:15:00'),
|
||||
completionTime: new Date('2024-01-20 16:30:00'),
|
||||
installationNotes: '监控设备已安装完成,用于蛋鸡养殖监管',
|
||||
installerName: '赵安装',
|
||||
installerPhone: '13800138003',
|
||||
installationAddress: '广东省佛山市顺德区某养殖场',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024004',
|
||||
contractNumber: 'LOAN2024004',
|
||||
productName: '肉羊养殖贷',
|
||||
customerName: '赵六',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4404XXXXXXXXXXXXXX',
|
||||
assetType: '肉羊',
|
||||
equipmentToInstall: '耳标设备',
|
||||
installationStatus: 'pending',
|
||||
taskGenerationTime: new Date('2024-01-18 11:45:00'),
|
||||
completionTime: null,
|
||||
installationNotes: '需要安装耳标设备用于肉羊监管',
|
||||
installerName: '钱安装',
|
||||
installerPhone: '13800138004',
|
||||
installationAddress: '广东省东莞市某养殖场',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024005',
|
||||
contractNumber: 'LOAN2024005',
|
||||
productName: '奶牛养殖贷',
|
||||
customerName: '孙七',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4405XXXXXXXXXXXXXX',
|
||||
assetType: '奶牛',
|
||||
equipmentToInstall: '项圈设备',
|
||||
installationStatus: 'failed',
|
||||
taskGenerationTime: new Date('2024-01-12 08:30:00'),
|
||||
completionTime: null,
|
||||
installationNotes: '设备安装失败,需要重新安排安装',
|
||||
installerName: '周安装',
|
||||
installerPhone: '13800138005',
|
||||
installationAddress: '广东省中山市某养殖场',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024006',
|
||||
contractNumber: 'LOAN2024006',
|
||||
productName: '肉鸭养殖贷',
|
||||
customerName: '周八',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4406XXXXXXXXXXXXXX',
|
||||
assetType: '肉鸭',
|
||||
equipmentToInstall: '监控设备',
|
||||
installationStatus: 'in-progress',
|
||||
taskGenerationTime: new Date('2024-01-20 15:20:00'),
|
||||
completionTime: null,
|
||||
installationNotes: '正在安装监控设备用于肉鸭养殖监管',
|
||||
installerName: '吴安装',
|
||||
installerPhone: '13800138006',
|
||||
installationAddress: '广东省江门市某养殖场',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024007',
|
||||
contractNumber: 'LOAN2024007',
|
||||
productName: '肉鸡养殖贷',
|
||||
customerName: '吴九',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4407XXXXXXXXXXXXXX',
|
||||
assetType: '肉鸡',
|
||||
equipmentToInstall: '耳标设备',
|
||||
installationStatus: 'completed',
|
||||
taskGenerationTime: new Date('2024-01-08 13:10:00'),
|
||||
completionTime: new Date('2024-01-22 10:15:00'),
|
||||
installationNotes: '耳标设备安装完成,肉鸡监管系统正常运行',
|
||||
installerName: '郑安装',
|
||||
installerPhone: '13800138007',
|
||||
installationAddress: '广东省惠州市某养殖场',
|
||||
createdBy: user.id
|
||||
},
|
||||
{
|
||||
applicationNumber: 'APP2024008',
|
||||
contractNumber: 'LOAN2024008',
|
||||
productName: '肉猪养殖贷',
|
||||
customerName: '郑十',
|
||||
idType: 'ID_CARD',
|
||||
idNumber: '4408XXXXXXXXXXXXXX',
|
||||
assetType: '肉猪',
|
||||
equipmentToInstall: '项圈设备',
|
||||
installationStatus: 'pending',
|
||||
taskGenerationTime: new Date('2024-01-25 09:00:00'),
|
||||
completionTime: null,
|
||||
installationNotes: '待安装项圈设备用于肉猪监管',
|
||||
installerName: '冯安装',
|
||||
installerPhone: '13800138008',
|
||||
installationAddress: '广东省汕头市某养殖场',
|
||||
createdBy: user.id
|
||||
}
|
||||
]
|
||||
|
||||
// 检查是否已存在数据
|
||||
const existingCount = await InstallationTask.count()
|
||||
if (existingCount > 0) {
|
||||
console.log(`待安装任务表已有 ${existingCount} 条数据,跳过创建`)
|
||||
return
|
||||
}
|
||||
|
||||
// 批量创建待安装任务
|
||||
await InstallationTask.bulkCreate(installationTasks)
|
||||
|
||||
console.log(`✅ 成功创建 ${installationTasks.length} 条待安装任务测试数据`)
|
||||
|
||||
// 显示创建的数据
|
||||
const createdTasks = await InstallationTask.findAll({
|
||||
include: [
|
||||
{
|
||||
model: User,
|
||||
as: 'creator',
|
||||
attributes: ['id', 'username', 'real_name']
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
console.log('创建的待安装任务数据:')
|
||||
createdTasks.forEach((task, index) => {
|
||||
console.log(`${index + 1}. ${task.applicationNumber} - ${task.customerName} - ${task.installationStatus}`)
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
console.error('创建待安装任务测试数据失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 如果直接运行此脚本
|
||||
if (require.main === module) {
|
||||
seedInstallationTasks()
|
||||
.then(() => {
|
||||
console.log('待安装任务测试数据创建完成')
|
||||
process.exit(0)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('脚本执行失败:', error)
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = seedInstallationTasks
|
||||
260
bank-backend/scripts/seed-loan-applications.js
Normal file
260
bank-backend/scripts/seed-loan-applications.js
Normal file
@@ -0,0 +1,260 @@
|
||||
/**
|
||||
* 贷款申请测试数据脚本
|
||||
* @file seed-loan-applications.js
|
||||
* @description 为银行系统添加贷款申请测试数据
|
||||
*/
|
||||
const { sequelize, LoanApplication, AuditRecord, User } = require('../models');
|
||||
|
||||
async function seedLoanApplications() {
|
||||
try {
|
||||
console.log('开始添加贷款申请测试数据...');
|
||||
|
||||
// 获取admin用户(作为申请人和审核人)
|
||||
const adminUser = await User.findOne({ where: { username: 'admin' } });
|
||||
if (!adminUser) {
|
||||
console.log('❌ 未找到admin用户,请先创建用户');
|
||||
return;
|
||||
}
|
||||
|
||||
// 清空现有数据
|
||||
await AuditRecord.destroy({ where: {} });
|
||||
await LoanApplication.destroy({ where: {} });
|
||||
console.log('✅ 清空现有贷款申请数据');
|
||||
|
||||
// 创建贷款申请测试数据(参考前端页面的模拟数据)
|
||||
const applications = [
|
||||
{
|
||||
applicationNumber: '20240325123703784',
|
||||
productName: '惠农贷',
|
||||
farmerName: '刘超',
|
||||
borrowerName: '刘超',
|
||||
borrowerIdNumber: '511***********3017',
|
||||
assetType: '牛',
|
||||
applicationQuantity: '10头',
|
||||
amount: 100000.00,
|
||||
status: 'pending_review',
|
||||
type: 'personal',
|
||||
term: 12,
|
||||
interestRate: 3.90,
|
||||
phone: '13800138000',
|
||||
purpose: '养殖贷款',
|
||||
remark: '申请资金用于购买牛只扩大养殖规模',
|
||||
applicationTime: new Date('2024-03-25 12:37:03'),
|
||||
applicantId: adminUser.id
|
||||
},
|
||||
{
|
||||
applicationNumber: '20240229110801968',
|
||||
productName: '中国工商银行扎旗支行"畜禽活体抵押"',
|
||||
farmerName: '刘超',
|
||||
borrowerName: '刘超',
|
||||
borrowerIdNumber: '511***********3017',
|
||||
assetType: '牛',
|
||||
applicationQuantity: '10头',
|
||||
amount: 100000.00,
|
||||
status: 'verification_pending',
|
||||
type: 'mortgage',
|
||||
term: 24,
|
||||
interestRate: 4.20,
|
||||
phone: '13900139000',
|
||||
purpose: '养殖贷款',
|
||||
remark: '以畜禽活体作为抵押物申请贷款',
|
||||
applicationTime: new Date('2024-02-29 11:08:01'),
|
||||
applicantId: adminUser.id,
|
||||
approvedBy: adminUser.id,
|
||||
approvedTime: new Date('2024-03-01 10:15:00')
|
||||
},
|
||||
{
|
||||
applicationNumber: '20240229105806431',
|
||||
productName: '惠农贷',
|
||||
farmerName: '刘超',
|
||||
borrowerName: '刘超',
|
||||
borrowerIdNumber: '511***********3017',
|
||||
assetType: '牛',
|
||||
applicationQuantity: '10头',
|
||||
amount: 100000.00,
|
||||
status: 'pending_binding',
|
||||
type: 'personal',
|
||||
term: 18,
|
||||
interestRate: 3.75,
|
||||
phone: '13700137000',
|
||||
purpose: '养殖贷款',
|
||||
remark: '待绑定相关资产信息',
|
||||
applicationTime: new Date('2024-02-29 10:58:06'),
|
||||
applicantId: adminUser.id
|
||||
},
|
||||
{
|
||||
applicationNumber: '20240315085642123',
|
||||
productName: '农商银行养殖贷',
|
||||
farmerName: '张伟',
|
||||
borrowerName: '张伟',
|
||||
borrowerIdNumber: '621***********2156',
|
||||
assetType: '猪',
|
||||
applicationQuantity: '50头',
|
||||
amount: 250000.00,
|
||||
status: 'approved',
|
||||
type: 'business',
|
||||
term: 36,
|
||||
interestRate: 4.50,
|
||||
phone: '13600136000',
|
||||
purpose: '扩大养猪规模',
|
||||
remark: '已审核通过,准备放款',
|
||||
applicationTime: new Date('2024-03-15 08:56:42'),
|
||||
applicantId: adminUser.id,
|
||||
approvedBy: adminUser.id,
|
||||
approvedTime: new Date('2024-03-16 14:20:00')
|
||||
},
|
||||
{
|
||||
applicationNumber: '20240310142355789',
|
||||
productName: '建设银行农户小额贷款',
|
||||
farmerName: '李明',
|
||||
borrowerName: '李明',
|
||||
borrowerIdNumber: '371***********4578',
|
||||
assetType: '羊',
|
||||
applicationQuantity: '30只',
|
||||
amount: 80000.00,
|
||||
status: 'rejected',
|
||||
type: 'personal',
|
||||
term: 12,
|
||||
interestRate: 4.10,
|
||||
phone: '13500135000',
|
||||
purpose: '养羊创业',
|
||||
remark: '资质不符合要求,已拒绝',
|
||||
applicationTime: new Date('2024-03-10 14:23:55'),
|
||||
applicantId: adminUser.id,
|
||||
rejectedBy: adminUser.id,
|
||||
rejectedTime: new Date('2024-03-11 09:30:00'),
|
||||
rejectionReason: '申请人征信记录不良,不符合放款条件'
|
||||
}
|
||||
];
|
||||
|
||||
// 批量创建申请
|
||||
const createdApplications = await LoanApplication.bulkCreate(applications);
|
||||
console.log(`✅ 成功创建${createdApplications.length}个贷款申请`);
|
||||
|
||||
// 为每个申请创建审核记录
|
||||
const auditRecords = [];
|
||||
|
||||
// 第一个申请:只有提交记录
|
||||
auditRecords.push({
|
||||
applicationId: createdApplications[0].id,
|
||||
action: 'submit',
|
||||
auditor: '刘超',
|
||||
auditorId: adminUser.id,
|
||||
comment: '提交申请',
|
||||
auditTime: new Date('2024-03-25 12:37:03'),
|
||||
newStatus: 'pending_review'
|
||||
});
|
||||
|
||||
// 第二个申请:提交 + 审核通过
|
||||
auditRecords.push(
|
||||
{
|
||||
applicationId: createdApplications[1].id,
|
||||
action: 'submit',
|
||||
auditor: '刘超',
|
||||
auditorId: adminUser.id,
|
||||
comment: '提交申请',
|
||||
auditTime: new Date('2024-02-29 11:08:01'),
|
||||
newStatus: 'pending_review'
|
||||
},
|
||||
{
|
||||
applicationId: createdApplications[1].id,
|
||||
action: 'approve',
|
||||
auditor: '王经理',
|
||||
auditorId: adminUser.id,
|
||||
comment: '资料齐全,符合条件,同意放款',
|
||||
auditTime: new Date('2024-03-01 10:15:00'),
|
||||
previousStatus: 'pending_review',
|
||||
newStatus: 'verification_pending'
|
||||
}
|
||||
);
|
||||
|
||||
// 第三个申请:只有提交记录
|
||||
auditRecords.push({
|
||||
applicationId: createdApplications[2].id,
|
||||
action: 'submit',
|
||||
auditor: '刘超',
|
||||
auditorId: adminUser.id,
|
||||
comment: '提交申请',
|
||||
auditTime: new Date('2024-02-29 10:58:06'),
|
||||
newStatus: 'pending_review'
|
||||
});
|
||||
|
||||
// 第四个申请:提交 + 审核通过
|
||||
auditRecords.push(
|
||||
{
|
||||
applicationId: createdApplications[3].id,
|
||||
action: 'submit',
|
||||
auditor: '张伟',
|
||||
auditorId: adminUser.id,
|
||||
comment: '提交申请',
|
||||
auditTime: new Date('2024-03-15 08:56:42'),
|
||||
newStatus: 'pending_review'
|
||||
},
|
||||
{
|
||||
applicationId: createdApplications[3].id,
|
||||
action: 'approve',
|
||||
auditor: '李总监',
|
||||
auditorId: adminUser.id,
|
||||
comment: '经营状况良好,养殖经验丰富,批准贷款',
|
||||
auditTime: new Date('2024-03-16 14:20:00'),
|
||||
previousStatus: 'pending_review',
|
||||
newStatus: 'approved'
|
||||
}
|
||||
);
|
||||
|
||||
// 第五个申请:提交 + 审核拒绝
|
||||
auditRecords.push(
|
||||
{
|
||||
applicationId: createdApplications[4].id,
|
||||
action: 'submit',
|
||||
auditor: '李明',
|
||||
auditorId: adminUser.id,
|
||||
comment: '提交申请',
|
||||
auditTime: new Date('2024-03-10 14:23:55'),
|
||||
newStatus: 'pending_review'
|
||||
},
|
||||
{
|
||||
applicationId: createdApplications[4].id,
|
||||
action: 'reject',
|
||||
auditor: '风控部门',
|
||||
auditorId: adminUser.id,
|
||||
comment: '申请人征信记录不良,不符合放款条件',
|
||||
auditTime: new Date('2024-03-11 09:30:00'),
|
||||
previousStatus: 'pending_review',
|
||||
newStatus: 'rejected'
|
||||
}
|
||||
);
|
||||
|
||||
// 批量创建审核记录
|
||||
await AuditRecord.bulkCreate(auditRecords);
|
||||
console.log(`✅ 成功创建${auditRecords.length}条审核记录`);
|
||||
|
||||
console.log('\n📊 贷款申请数据统计:');
|
||||
console.log('- 待初审:1个申请');
|
||||
console.log('- 核验待放款:1个申请');
|
||||
console.log('- 待绑定:1个申请');
|
||||
console.log('- 已通过:1个申请');
|
||||
console.log('- 已拒绝:1个申请');
|
||||
console.log('- 总申请金额:630,000.00元');
|
||||
|
||||
console.log('\n🎉 贷款申请测试数据添加完成!');
|
||||
} catch (error) {
|
||||
console.error('❌ 添加贷款申请测试数据失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果直接运行此文件
|
||||
if (require.main === module) {
|
||||
seedLoanApplications()
|
||||
.then(() => {
|
||||
console.log('✅ 脚本执行完成');
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('❌ 脚本执行失败:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = seedLoanApplications;
|
||||
289
bank-backend/scripts/seed-loan-contracts.js
Normal file
289
bank-backend/scripts/seed-loan-contracts.js
Normal file
@@ -0,0 +1,289 @@
|
||||
/**
|
||||
* 贷款合同测试数据脚本
|
||||
* @file seed-loan-contracts.js
|
||||
* @description 为银行系统添加贷款合同测试数据
|
||||
*/
|
||||
const { sequelize, LoanContract, User } = require('../models');
|
||||
|
||||
async function seedLoanContracts() {
|
||||
try {
|
||||
console.log('开始添加贷款合同测试数据...');
|
||||
|
||||
// 获取admin用户(作为创建人)
|
||||
const adminUser = await User.findOne({ where: { username: 'admin' } });
|
||||
if (!adminUser) {
|
||||
console.log('❌ 未找到admin用户,请先创建用户');
|
||||
return;
|
||||
}
|
||||
|
||||
// 清空现有数据
|
||||
await LoanContract.destroy({ where: {} });
|
||||
console.log('✅ 清空现有贷款合同数据');
|
||||
|
||||
// 创建贷款合同测试数据(参考图片中的数据结构)
|
||||
const contracts = [
|
||||
{
|
||||
contractNumber: 'HT20231131123456789',
|
||||
applicationNumber: '20231131123456789',
|
||||
productName: '中国农业银行扎旗支行"畜禽活体抵押"',
|
||||
farmerName: '敖日布仁琴',
|
||||
borrowerName: '敖日布仁琴',
|
||||
borrowerIdNumber: '150***********4856',
|
||||
assetType: '牛',
|
||||
applicationQuantity: '36头',
|
||||
amount: 500000.00,
|
||||
paidAmount: 0,
|
||||
status: 'active',
|
||||
type: 'livestock_collateral',
|
||||
term: 24,
|
||||
interestRate: 4.20,
|
||||
phone: '13800138000',
|
||||
purpose: '养殖贷款',
|
||||
remark: '畜禽活体抵押贷款',
|
||||
contractTime: new Date('2023-11-31 12:34:56'),
|
||||
disbursementTime: new Date('2023-12-01 10:00:00'),
|
||||
maturityTime: new Date('2025-12-01 10:00:00'),
|
||||
createdBy: adminUser.id
|
||||
},
|
||||
{
|
||||
contractNumber: 'HT20231201123456790',
|
||||
applicationNumber: '20231201123456790',
|
||||
productName: '中国工商银行扎旗支行"畜禽活体抵押"',
|
||||
farmerName: '张伟',
|
||||
borrowerName: '张伟',
|
||||
borrowerIdNumber: '150***********4857',
|
||||
assetType: '牛',
|
||||
applicationQuantity: '25头',
|
||||
amount: 350000.00,
|
||||
paidAmount: 50000.00,
|
||||
status: 'active',
|
||||
type: 'livestock_collateral',
|
||||
term: 18,
|
||||
interestRate: 4.50,
|
||||
phone: '13900139000',
|
||||
purpose: '扩大养殖规模',
|
||||
remark: '工商银行畜禽活体抵押',
|
||||
contractTime: new Date('2023-12-01 14:20:30'),
|
||||
disbursementTime: new Date('2023-12-02 09:30:00'),
|
||||
maturityTime: new Date('2025-06-02 09:30:00'),
|
||||
createdBy: adminUser.id
|
||||
},
|
||||
{
|
||||
contractNumber: 'HT20231202123456791',
|
||||
applicationNumber: '20231202123456791',
|
||||
productName: '惠农贷',
|
||||
farmerName: '李明',
|
||||
borrowerName: '李明',
|
||||
borrowerIdNumber: '150***********4858',
|
||||
assetType: '牛',
|
||||
applicationQuantity: '20头',
|
||||
amount: 280000.00,
|
||||
paidAmount: 0,
|
||||
status: 'pending',
|
||||
type: 'farmer_loan',
|
||||
term: 12,
|
||||
interestRate: 3.90,
|
||||
phone: '13700137000',
|
||||
purpose: '惠农贷款',
|
||||
remark: '惠农贷产品',
|
||||
contractTime: new Date('2023-12-02 16:45:12'),
|
||||
createdBy: adminUser.id
|
||||
},
|
||||
{
|
||||
contractNumber: 'HT20231203123456792',
|
||||
applicationNumber: '20231203123456792',
|
||||
productName: '中国农业银行扎旗支行"畜禽活体抵押"',
|
||||
farmerName: '王强',
|
||||
borrowerName: '王强',
|
||||
borrowerIdNumber: '150***********4859',
|
||||
assetType: '牛',
|
||||
applicationQuantity: '30头',
|
||||
amount: 420000.00,
|
||||
paidAmount: 420000.00,
|
||||
status: 'completed',
|
||||
type: 'livestock_collateral',
|
||||
term: 24,
|
||||
interestRate: 4.20,
|
||||
phone: '13600136000',
|
||||
purpose: '养殖贷款',
|
||||
remark: '已完成还款',
|
||||
contractTime: new Date('2023-12-03 11:20:45'),
|
||||
disbursementTime: new Date('2023-12-04 08:00:00'),
|
||||
maturityTime: new Date('2025-12-04 08:00:00'),
|
||||
completedTime: new Date('2024-11-15 14:30:00'),
|
||||
createdBy: adminUser.id
|
||||
},
|
||||
{
|
||||
contractNumber: 'HT20231204123456793',
|
||||
applicationNumber: '20231204123456793',
|
||||
productName: '中国工商银行扎旗支行"畜禽活体抵押"',
|
||||
farmerName: '赵敏',
|
||||
borrowerName: '赵敏',
|
||||
borrowerIdNumber: '150***********4860',
|
||||
assetType: '牛',
|
||||
applicationQuantity: '15头',
|
||||
amount: 200000.00,
|
||||
paidAmount: 0,
|
||||
status: 'defaulted',
|
||||
type: 'livestock_collateral',
|
||||
term: 18,
|
||||
interestRate: 4.50,
|
||||
phone: '13500135000',
|
||||
purpose: '养殖贷款',
|
||||
remark: '违约状态',
|
||||
contractTime: new Date('2023-12-04 13:15:30'),
|
||||
disbursementTime: new Date('2023-12-05 10:00:00'),
|
||||
maturityTime: new Date('2025-06-05 10:00:00'),
|
||||
createdBy: adminUser.id
|
||||
},
|
||||
{
|
||||
contractNumber: 'HT20231205123456794',
|
||||
applicationNumber: '20231205123456794',
|
||||
productName: '惠农贷',
|
||||
farmerName: '刘超',
|
||||
borrowerName: '刘超',
|
||||
borrowerIdNumber: '150***********4861',
|
||||
assetType: '牛',
|
||||
applicationQuantity: '22头',
|
||||
amount: 320000.00,
|
||||
paidAmount: 80000.00,
|
||||
status: 'active',
|
||||
type: 'farmer_loan',
|
||||
term: 24,
|
||||
interestRate: 3.90,
|
||||
phone: '13400134000',
|
||||
purpose: '惠农贷款',
|
||||
remark: '惠农贷产品',
|
||||
contractTime: new Date('2023-12-05 15:30:20'),
|
||||
disbursementTime: new Date('2023-12-06 09:00:00'),
|
||||
maturityTime: new Date('2025-12-06 09:00:00'),
|
||||
createdBy: adminUser.id
|
||||
},
|
||||
{
|
||||
contractNumber: 'HT20231206123456795',
|
||||
applicationNumber: '20231206123456795',
|
||||
productName: '中国农业银行扎旗支行"畜禽活体抵押"',
|
||||
farmerName: '陈华',
|
||||
borrowerName: '陈华',
|
||||
borrowerIdNumber: '150***********4862',
|
||||
assetType: '牛',
|
||||
applicationQuantity: '28头',
|
||||
amount: 380000.00,
|
||||
paidAmount: 0,
|
||||
status: 'active',
|
||||
type: 'livestock_collateral',
|
||||
term: 30,
|
||||
interestRate: 4.20,
|
||||
phone: '13300133000',
|
||||
purpose: '养殖贷款',
|
||||
remark: '长期贷款',
|
||||
contractTime: new Date('2023-12-06 10:45:15'),
|
||||
disbursementTime: new Date('2023-12-07 11:00:00'),
|
||||
maturityTime: new Date('2026-06-07 11:00:00'),
|
||||
createdBy: adminUser.id
|
||||
},
|
||||
{
|
||||
contractNumber: 'HT20231207123456796',
|
||||
applicationNumber: '20231207123456796',
|
||||
productName: '中国工商银行扎旗支行"畜禽活体抵押"',
|
||||
farmerName: '孙丽',
|
||||
borrowerName: '孙丽',
|
||||
borrowerIdNumber: '150***********4863',
|
||||
assetType: '牛',
|
||||
applicationQuantity: '18头',
|
||||
amount: 250000.00,
|
||||
paidAmount: 250000.00,
|
||||
status: 'completed',
|
||||
type: 'livestock_collateral',
|
||||
term: 12,
|
||||
interestRate: 4.50,
|
||||
phone: '13200132000',
|
||||
purpose: '养殖贷款',
|
||||
remark: '短期贷款已完成',
|
||||
contractTime: new Date('2023-12-07 14:20:10'),
|
||||
disbursementTime: new Date('2023-12-08 08:30:00'),
|
||||
maturityTime: new Date('2024-12-08 08:30:00'),
|
||||
completedTime: new Date('2024-10-15 16:45:00'),
|
||||
createdBy: adminUser.id
|
||||
},
|
||||
{
|
||||
contractNumber: 'HT20231208123456797',
|
||||
applicationNumber: '20231208123456797',
|
||||
productName: '惠农贷',
|
||||
farmerName: '周杰',
|
||||
borrowerName: '周杰',
|
||||
borrowerIdNumber: '150***********4864',
|
||||
assetType: '牛',
|
||||
applicationQuantity: '24头',
|
||||
amount: 360000.00,
|
||||
paidAmount: 0,
|
||||
status: 'cancelled',
|
||||
type: 'farmer_loan',
|
||||
term: 18,
|
||||
interestRate: 3.90,
|
||||
phone: '13100131000',
|
||||
purpose: '惠农贷款',
|
||||
remark: '已取消',
|
||||
contractTime: new Date('2023-12-08 16:10:25'),
|
||||
createdBy: adminUser.id
|
||||
},
|
||||
{
|
||||
contractNumber: 'HT20231209123456798',
|
||||
applicationNumber: '20231209123456798',
|
||||
productName: '中国农业银行扎旗支行"畜禽活体抵押"',
|
||||
farmerName: '吴刚',
|
||||
borrowerName: '吴刚',
|
||||
borrowerIdNumber: '150***********4865',
|
||||
assetType: '牛',
|
||||
applicationQuantity: '32头',
|
||||
amount: 450000.00,
|
||||
paidAmount: 150000.00,
|
||||
status: 'active',
|
||||
type: 'livestock_collateral',
|
||||
term: 36,
|
||||
interestRate: 4.20,
|
||||
phone: '13000130000',
|
||||
purpose: '养殖贷款',
|
||||
remark: '长期贷款',
|
||||
contractTime: new Date('2023-12-09 12:30:40'),
|
||||
disbursementTime: new Date('2023-12-10 10:15:00'),
|
||||
maturityTime: new Date('2026-12-10 10:15:00'),
|
||||
createdBy: adminUser.id
|
||||
}
|
||||
];
|
||||
|
||||
// 批量创建合同
|
||||
const createdContracts = await LoanContract.bulkCreate(contracts);
|
||||
console.log(`✅ 成功创建${createdContracts.length}个贷款合同`);
|
||||
|
||||
console.log('\n📊 贷款合同数据统计:');
|
||||
console.log('- 已放款:6个合同');
|
||||
console.log('- 待放款:1个合同');
|
||||
console.log('- 已完成:2个合同');
|
||||
console.log('- 违约:1个合同');
|
||||
console.log('- 已取消:1个合同');
|
||||
console.log('- 总合同金额:3,410,000.00元');
|
||||
console.log('- 已还款金额:520,000.00元');
|
||||
console.log('- 剩余还款金额:2,890,000.00元');
|
||||
|
||||
console.log('\n🎉 贷款合同测试数据添加完成!');
|
||||
} catch (error) {
|
||||
console.error('❌ 添加贷款合同测试数据失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果直接运行此文件
|
||||
if (require.main === module) {
|
||||
seedLoanContracts()
|
||||
.then(() => {
|
||||
console.log('✅ 脚本执行完成');
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('❌ 脚本执行失败:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = seedLoanContracts;
|
||||
145
bank-backend/scripts/seed-loan-products.js
Normal file
145
bank-backend/scripts/seed-loan-products.js
Normal file
@@ -0,0 +1,145 @@
|
||||
const { sequelize, LoanProduct, User } = require('../models');
|
||||
|
||||
async function seedLoanProducts() {
|
||||
try {
|
||||
console.log('开始添加贷款商品测试数据...');
|
||||
|
||||
// 查找管理员用户
|
||||
const adminUser = await User.findOne({
|
||||
where: { username: 'admin' }
|
||||
});
|
||||
|
||||
if (!adminUser) {
|
||||
console.error('未找到管理员用户,请先创建管理员用户');
|
||||
return;
|
||||
}
|
||||
|
||||
const loanProducts = [
|
||||
{
|
||||
productName: '惠农贷',
|
||||
loanAmount: '50000~5000000元',
|
||||
loanTerm: 24,
|
||||
interestRate: 3.90,
|
||||
serviceArea: '内蒙古自治区:通辽市',
|
||||
servicePhone: '15004901368',
|
||||
totalCustomers: 16,
|
||||
supervisionCustomers: 11,
|
||||
completedCustomers: 5,
|
||||
onSaleStatus: true,
|
||||
productDescription: '专为农户设计的贷款产品,支持农业生产和经营',
|
||||
applicationRequirements: '1. 具有完全民事行为能力的自然人;2. 有稳定的收入来源;3. 信用记录良好',
|
||||
requiredDocuments: '身份证、户口本、收入证明、银行流水',
|
||||
approvalProcess: '申请→初审→实地调查→审批→放款',
|
||||
riskLevel: 'LOW',
|
||||
minLoanAmount: 50000,
|
||||
maxLoanAmount: 5000000,
|
||||
createdBy: adminUser.id,
|
||||
updatedBy: adminUser.id
|
||||
},
|
||||
{
|
||||
productName: '中国工商银行扎旗支行"畜禽活体抵押"',
|
||||
loanAmount: '200000~1000000元',
|
||||
loanTerm: 12,
|
||||
interestRate: 4.70,
|
||||
serviceArea: '内蒙古自治区:通辽市',
|
||||
servicePhone: '15004901368',
|
||||
totalCustomers: 10,
|
||||
supervisionCustomers: 5,
|
||||
completedCustomers: 5,
|
||||
onSaleStatus: true,
|
||||
productDescription: '以畜禽活体作为抵押物的贷款产品',
|
||||
applicationRequirements: '1. 拥有符合条件的畜禽;2. 提供养殖证明;3. 通过银行评估',
|
||||
requiredDocuments: '身份证、养殖证明、畜禽检疫证明、银行流水',
|
||||
approvalProcess: '申请→畜禽评估→抵押登记→审批→放款',
|
||||
riskLevel: 'MEDIUM',
|
||||
minLoanAmount: 200000,
|
||||
maxLoanAmount: 1000000,
|
||||
createdBy: adminUser.id,
|
||||
updatedBy: adminUser.id
|
||||
},
|
||||
{
|
||||
productName: '中国银行扎旗支行"畜禽活体抵押"',
|
||||
loanAmount: '200000~1000000元',
|
||||
loanTerm: 12,
|
||||
interestRate: 4.60,
|
||||
serviceArea: '内蒙古自治区:通辽市',
|
||||
servicePhone: '15004901368',
|
||||
totalCustomers: 2,
|
||||
supervisionCustomers: 2,
|
||||
completedCustomers: 0,
|
||||
onSaleStatus: true,
|
||||
productDescription: '中国银行推出的畜禽活体抵押贷款产品',
|
||||
applicationRequirements: '1. 符合银行信贷政策;2. 畜禽数量达到要求;3. 提供担保',
|
||||
requiredDocuments: '身份证、养殖许可证、畜禽数量证明、担保材料',
|
||||
approvalProcess: '申请→资料审核→现场调查→风险评估→审批→放款',
|
||||
riskLevel: 'MEDIUM',
|
||||
minLoanAmount: 200000,
|
||||
maxLoanAmount: 1000000,
|
||||
createdBy: adminUser.id,
|
||||
updatedBy: adminUser.id
|
||||
},
|
||||
{
|
||||
productName: '中国农业银行扎旗支行"畜禽活体抵押"',
|
||||
loanAmount: '200000~1000000元',
|
||||
loanTerm: 12,
|
||||
interestRate: 4.80,
|
||||
serviceArea: '内蒙古自治区:通辽市',
|
||||
servicePhone: '15004901368',
|
||||
totalCustomers: 26,
|
||||
supervisionCustomers: 24,
|
||||
completedCustomers: 2,
|
||||
onSaleStatus: true,
|
||||
productDescription: '农业银行专门为养殖户设计的贷款产品',
|
||||
applicationRequirements: '1. 从事养殖业满2年;2. 畜禽存栏量达标;3. 有还款能力',
|
||||
requiredDocuments: '身份证、养殖场证明、畜禽存栏证明、收入证明',
|
||||
approvalProcess: '申请→资格审核→现场勘查→风险评估→审批→放款',
|
||||
riskLevel: 'HIGH',
|
||||
minLoanAmount: 200000,
|
||||
maxLoanAmount: 1000000,
|
||||
createdBy: adminUser.id,
|
||||
updatedBy: adminUser.id
|
||||
}
|
||||
];
|
||||
|
||||
// 检查是否已存在数据
|
||||
const existingCount = await LoanProduct.count();
|
||||
if (existingCount > 0) {
|
||||
console.log(`数据库中已存在 ${existingCount} 条贷款商品数据,跳过添加`);
|
||||
return;
|
||||
}
|
||||
|
||||
// 批量创建贷款商品
|
||||
await LoanProduct.bulkCreate(loanProducts);
|
||||
|
||||
console.log(`成功添加 ${loanProducts.length} 条贷款商品测试数据`);
|
||||
|
||||
// 显示添加的数据
|
||||
const createdProducts = await LoanProduct.findAll({
|
||||
attributes: ['id', 'productName', 'loanAmount', 'interestRate', 'onSaleStatus']
|
||||
});
|
||||
|
||||
console.log('添加的贷款商品数据:');
|
||||
createdProducts.forEach(product => {
|
||||
console.log(`- ${product.productName}: ${product.loanAmount} (利率: ${product.interestRate}%, 状态: ${product.onSaleStatus ? '在售' : '停售'})`);
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('添加贷款商品测试数据失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果直接运行此脚本
|
||||
if (require.main === module) {
|
||||
seedLoanProducts()
|
||||
.then(() => {
|
||||
console.log('贷款商品测试数据添加完成');
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('添加贷款商品测试数据失败:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = seedLoanProducts;
|
||||
39
bank-backend/scripts/setup-completed-supervisions.js
Normal file
39
bank-backend/scripts/setup-completed-supervisions.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const { sequelize, CompletedSupervision, User } = require('../models')
|
||||
const seedCompletedSupervisions = require('./seed-completed-supervisions')
|
||||
|
||||
async function setupCompletedSupervisions() {
|
||||
try {
|
||||
console.log('开始设置监管任务已结项...')
|
||||
|
||||
// 测试数据库连接
|
||||
await sequelize.authenticate()
|
||||
console.log('✅ 数据库连接成功')
|
||||
|
||||
// 同步模型(创建表)
|
||||
await sequelize.sync({ force: false })
|
||||
console.log('✅ 数据库表同步完成')
|
||||
|
||||
// 创建测试数据
|
||||
await seedCompletedSupervisions()
|
||||
console.log('✅ 监管任务已结项设置完成')
|
||||
|
||||
} catch (error) {
|
||||
console.error('设置监管任务已结项失败:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// 如果直接运行此脚本
|
||||
if (require.main === module) {
|
||||
setupCompletedSupervisions()
|
||||
.then(() => {
|
||||
console.log('监管任务已结项设置完成')
|
||||
process.exit(0)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('脚本执行失败:', error)
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = setupCompletedSupervisions
|
||||
39
bank-backend/scripts/setup-installation-tasks.js
Normal file
39
bank-backend/scripts/setup-installation-tasks.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const { sequelize, InstallationTask, User } = require('../models')
|
||||
const seedInstallationTasks = require('./seed-installation-tasks')
|
||||
|
||||
async function setupInstallationTasks() {
|
||||
try {
|
||||
console.log('开始设置待安装任务...')
|
||||
|
||||
// 测试数据库连接
|
||||
await sequelize.authenticate()
|
||||
console.log('✅ 数据库连接成功')
|
||||
|
||||
// 同步模型(创建表)
|
||||
await sequelize.sync({ force: false })
|
||||
console.log('✅ 数据库表同步完成')
|
||||
|
||||
// 创建测试数据
|
||||
await seedInstallationTasks()
|
||||
console.log('✅ 待安装任务设置完成')
|
||||
|
||||
} catch (error) {
|
||||
console.error('设置待安装任务失败:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// 如果直接运行此脚本
|
||||
if (require.main === module) {
|
||||
setupInstallationTasks()
|
||||
.then(() => {
|
||||
console.log('待安装任务设置完成')
|
||||
process.exit(0)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('脚本执行失败:', error)
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = setupInstallationTasks
|
||||
42
bank-backend/scripts/setup-loan-products.js
Normal file
42
bank-backend/scripts/setup-loan-products.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const { sequelize, LoanProduct } = require('../models');
|
||||
const seedLoanProducts = require('./seed-loan-products');
|
||||
|
||||
async function setupLoanProducts() {
|
||||
try {
|
||||
console.log('开始设置贷款商品表...');
|
||||
|
||||
// 测试数据库连接
|
||||
await sequelize.authenticate();
|
||||
console.log('数据库连接成功');
|
||||
|
||||
// 同步模型(创建表)
|
||||
await sequelize.sync({ force: false });
|
||||
console.log('贷款商品表同步成功');
|
||||
|
||||
// 添加测试数据
|
||||
await seedLoanProducts();
|
||||
|
||||
console.log('贷款商品设置完成');
|
||||
|
||||
} catch (error) {
|
||||
console.error('设置贷款商品失败:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
await sequelize.close();
|
||||
}
|
||||
}
|
||||
|
||||
// 如果直接运行此脚本
|
||||
if (require.main === module) {
|
||||
setupLoanProducts()
|
||||
.then(() => {
|
||||
console.log('贷款商品设置完成');
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('设置贷款商品失败:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = setupLoanProducts;
|
||||
Reference in New Issue
Block a user