diff --git a/app/Console/Commands/UpdateUserTalentTags.php b/app/Console/Commands/UpdateUserTalentTags.php index c69dcf8..a1d9204 100644 --- a/app/Console/Commands/UpdateUserTalentTags.php +++ b/app/Console/Commands/UpdateUserTalentTags.php @@ -58,6 +58,7 @@ class UpdateUserTalentTags extends Command $notFoundCount = 0; $errorCount = 0; $skippedCount = 0; + $notFoundUsers = []; // 收集所有未匹配上的用户信息 DB::beginTransaction(); @@ -139,16 +140,22 @@ class UpdateUserTalentTags extends Command // 如果所有课程都找不到匹配的用户,直接通过姓名在用户表中查找 if (!$courseSign || !$courseSign->user) { $this->warn("第 {$rowNum} 行: 在所有课程中都未找到用户 '{$userName}' 的报名记录,尝试直接通过姓名匹配用户表..."); - + // 直接通过姓名在用户表中查找 $user = User::where('name', $userName)->first(); - + if (!$user) { $this->warn("第 {$rowNum} 行: 在用户表中也未找到用户 '{$userName}'(原始课程值: '{$courseNameRaw}'),跳过"); $notFoundCount++; + // 记录未匹配的用户信息 + $notFoundUsers[] = [ + 'row' => $rowNum, + 'name' => $userName, + 'course' => $courseNameRaw, + ]; continue; } - + $this->info("第 {$rowNum} 行: 通过姓名在用户表中找到用户 '{$userName}' (ID: {$user->id})"); } else { $user = $courseSign->user; @@ -209,6 +216,20 @@ class UpdateUserTalentTags extends Command $this->info("跳过(已存在/空数据): {$skippedCount} 条"); $this->info("更新失败: {$errorCount} 条"); $this->info('========================================'); + + // 输出所有未匹配上的用户列表 + if (!empty($notFoundUsers)) { + $this->info(''); + $this->info('========================================'); + $this->info('未匹配上的用户列表:'); + $this->info('========================================'); + foreach ($notFoundUsers as $notFoundUser) { + $this->warn("第 {$notFoundUser['row']} 行: 姓名: {$notFoundUser['name']}, 课程: {$notFoundUser['course']}"); + } + $this->info('========================================'); + $this->info("共 {$notFoundCount} 个用户未匹配上"); + $this->info('========================================'); + } return 0; } catch (\Exception $e) {