同步失败时展示错误信息并增加后端状态日志

This commit is contained in:
2026-07-04 12:14:27 +08:00
parent 46013a2b2f
commit 7f300b9067
2 changed files with 10 additions and 0 deletions
+7
View File
@@ -123,6 +123,13 @@ func (s *StockSyncService) finishJob(ctx context.Context, jobID string, recordsC
}
if err := s.db.WithContext(ctx).Model(&models.StockSyncJob{}).Where("id = ?", jobID).Updates(updates).Error; err != nil {
log.Printf("[stock sync] update job %s failed: %v", jobID, err)
return
}
var job models.StockSyncJob
if err := s.db.WithContext(ctx).Where("id = ?", jobID).First(&job).Error; err == nil {
log.Printf("[stock sync] job %s final state: status=%s, started_at=%v, finished_at=%v",
jobID, job.Status, job.StartedAt, job.FinishedAt)
}
}