|
|
@ -169,6 +169,27 @@ class JiandaoyunService { |
|
|
|
|
|
|
|
|
// 更新数据
|
|
|
// 更新数据
|
|
|
const result = await this.updateDataInForm(recordId, jiandaoyunData); |
|
|
const result = await this.updateDataInForm(recordId, jiandaoyunData); |
|
|
|
|
|
|
|
|
|
|
|
// 更新数据库中的同步状态
|
|
|
|
|
|
if (connection && item.user && item.user.userId) { |
|
|
|
|
|
try { |
|
|
|
|
|
console.log(`更新用户 ${item.user.userId} 的同步状态`); |
|
|
|
|
|
const [updateResult] = await connection.execute( |
|
|
|
|
|
`UPDATE ${config.tables.users.name} SET ${config.sync.statusField} = ${config.sync.syncedValue}, ${config.sync.timeField} = NOW() WHERE userId = ?`, |
|
|
|
|
|
[item.user.userId] |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (updateResult.affectedRows > 0) { |
|
|
|
|
|
console.log(`✅ 成功更新用户 ${item.user.userId} 的同步状态`); |
|
|
|
|
|
} else { |
|
|
|
|
|
console.log(`⚠️ 更新用户 ${item.user.userId} 的同步状态失败: 未找到匹配的用户`); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (updateError) { |
|
|
|
|
|
console.error(`❌ 更新数据库同步状态时发生错误:`, updateError.message); |
|
|
|
|
|
console.error(`错误堆栈:`, updateError.stack); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
results.push({ |
|
|
results.push({ |
|
|
success: true, |
|
|
success: true, |
|
|
updated: true, |
|
|
updated: true, |
|
|
@ -194,20 +215,20 @@ class JiandaoyunService { |
|
|
|
|
|
|
|
|
if (connection && item.user && item.user.userId) { |
|
|
if (connection && item.user && item.user.userId) { |
|
|
try { |
|
|
try { |
|
|
console.log(`准备更新用户 ${item.user.userId} 的jiandaoyun_record_id为 ${newRecordId}`); |
|
|
console.log(`准备更新用户 ${item.user.userId} 的jiandaoyun_record_id为 ${newRecordId} 并设置同步状态`); |
|
|
const [updateResult] = await connection.execute( |
|
|
const [updateResult] = await connection.execute( |
|
|
`UPDATE ${config.tables.users.name} SET jiandaoyun_record_id = ? WHERE userId = ?`, |
|
|
`UPDATE ${config.tables.users.name} SET jiandaoyun_record_id = ?, ${config.sync.statusField} = ${config.sync.syncedValue}, ${config.sync.timeField} = NOW() WHERE userId = ?`, |
|
|
[newRecordId, item.user.userId] |
|
|
[newRecordId, item.user.userId] |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
console.log(`数据库更新结果:`, updateResult); |
|
|
console.log(`数据库更新结果:`, updateResult); |
|
|
if (updateResult.affectedRows > 0) { |
|
|
if (updateResult.affectedRows > 0) { |
|
|
console.log(`✅ 成功将简道云记录ID ${newRecordId} 保存到数据库`); |
|
|
console.log(`✅ 成功将简道云记录ID ${newRecordId} 保存到数据库并更新同步状态`); |
|
|
} else { |
|
|
} else { |
|
|
console.log(`⚠️ 更新用户 ${item.user.userId} 的jiandaoyun_record_id失败: 未找到匹配的用户`); |
|
|
console.log(`⚠️ 更新用户 ${item.user.userId} 的jiandaoyun_record_id和同步状态失败: 未找到匹配的用户`); |
|
|
} |
|
|
} |
|
|
} catch (updateError) { |
|
|
} catch (updateError) { |
|
|
console.error(`❌ 更新数据库jiandaoyun_record_id时发生错误:`, updateError.message); |
|
|
console.error(`❌ 更新数据库jiandaoyun_record_id和同步状态时发生错误:`, updateError.message); |
|
|
console.error(`错误堆栈:`, updateError.stack); |
|
|
console.error(`错误堆栈:`, updateError.stack); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
|