修改政府端前端,银行端小程序和后端接口

This commit is contained in:
2025-09-26 17:52:50 +08:00
parent 852adbcfff
commit 00dfa83fd1
237 changed files with 9172 additions and 33500 deletions

View File

@@ -38,6 +38,9 @@ const getApplications = async (req, res) => {
} else if (searchField === 'applicationNumber') {
// 数据库中实际没有applicationNumber字段使用id作为替代
where.id = { [Op.like]: `%${searchValue}%` };
} else if (searchField === 'productName') {
// 产品名称搜索暂时不处理,因为数据库中没有这个字段
// 可以在前端过滤
}
}
@@ -70,17 +73,27 @@ const getApplications = async (req, res) => {
limit
});
// 格式化数据
// 格式化数据 - 匹配前端期望的字段
const applications = rows.map(app => ({
id: app.id,
customer_name: app.customer_name,
customer_phone: app.customer_phone,
customer_id_card: app.customer_id_card,
loan_amount: parseFloat(app.loan_amount),
loan_term: app.loan_term,
interest_rate: parseFloat(app.interest_rate),
application_date: app.application_date,
applicationNumber: `APP-${String(app.id).padStart(6, '0')}`, // 生成申请单号
productName: '养殖贷款', // 默认产品名称
farmerName: app.customer_name || '未知养殖户',
borrowerName: app.customer_name || '未知借款人',
borrowerIdNumber: app.customer_id_card || '',
assetType: '养殖设备', // 默认生资种类
applicationQuantity: '1', // 默认申请数量
amount: parseFloat(app.loan_amount),
status: app.status,
type: 'personal', // 默认类型
term: app.loan_term,
interestRate: parseFloat(app.interest_rate),
phone: app.customer_phone || '',
purpose: '养殖经营', // 默认用途
remark: '', // 默认备注
applicationTime: app.application_date,
approvedTime: null,
rejectedTime: null,
created_at: app.created_at,
updated_at: app.updated_at
}));
@@ -221,7 +234,7 @@ const auditApplication = async (req, res) => {
const { id } = req.params;
const { action, comment } = req.body;
const userId = req.user?.id;
const userId = req.user?.userId;
// 获取申请信息
const application = await LoanApplication.findByPk(id);
@@ -246,13 +259,15 @@ const auditApplication = async (req, res) => {
// 根据审核动作更新状态
if (action === 'approve') {
newStatus = 'approved';
application.approvedTime = new Date();
application.approvedBy = userId;
// 注意LoanApplication模型中没有这些字段暂时注释掉
// application.approvedTime = new Date();
// application.approvedBy = userId;
} else if (action === 'reject') {
newStatus = 'rejected';
application.rejectedTime = new Date();
application.rejectedBy = userId;
application.rejectionReason = comment;
// 注意LoanApplication模型中没有这些字段暂时注释掉
// application.rejectedTime = new Date();
// application.rejectedBy = userId;
// application.rejectionReason = comment;
}
// 更新申请状态
@@ -283,9 +298,12 @@ const auditApplication = async (req, res) => {
});
} catch (error) {
console.error('审核贷款申请失败:', error);
console.error('错误详情:', error.message);
console.error('错误堆栈:', error.stack);
res.status(500).json({
success: false,
message: '审核贷款申请失败'
message: '审核贷款申请失败',
error: error.message
});
}
};