argument('user_id'); $clear = $this->option('clear'); $this->info("测试用户 {$userId} 的任务暂存功能"); if ($clear) { // 清理暂存数据 $result = TaskTempService::clearUserTaskChanges($userId); if ($result) { $this->info('✓ 暂存数据已清理'); } else { $this->error('✗ 暂存数据清理失败'); } return 0; } // 检查是否有暂存数据 $hasChanges = TaskTempService::hasUserTaskChanges($userId); $this->info("是否有暂存数据: " . ($hasChanges ? '是' : '否')); if (!$hasChanges) { $this->warn('用户没有任务暂存数据'); return 0; } // 获取统计信息 $stats = TaskTempService::getUserTaskChangeStats($userId); $this->info('=== 暂存数据统计 ==='); $this->info("总变更数: {$stats['total_changes']}"); $this->info("进度更新: {$stats['progress_updates']}"); $this->info("完成任务: {$stats['completed_tasks']}"); $this->info("奖励领取: {$stats['reward_claims']}"); if ($stats['latest_update']) { $this->info("最新更新: " . date('Y-m-d H:i:s', $stats['latest_update'])); } // 获取所有暂存数据 $changes = TaskTempService::getUserTaskChanges($userId); $this->info("\n=== 暂存数据详情 ==="); foreach ($changes as $change) { $this->info("任务ID: {$change->taskId}"); $this->info("任务名称: {$change->taskName}"); $this->info("变更类型: {$change->getChangeTypeDescription()}"); $this->info("任务状态: {$change->getStatusDescription()}"); if ($change->isProgressUpdate()) { $this->info("进度: {$change->getFormattedProgress()}"); if ($change->progressDetails) { $this->info("进度详情: " . json_encode($change->progressDetails, JSON_UNESCAPED_UNICODE)); } } if ($change->isRewardClaimed()) { $this->info("奖励数量: {$change->getRewardCount()}"); } $this->info("更新时间: " . date('Y-m-d H:i:s', $change->updatedAt)); $this->info("---"); } // 获取最近的变更 $recentChanges = TaskTempService::getUserRecentTaskChanges($userId, 3); $this->info("\n=== 最近3次变更 ==="); foreach ($recentChanges as $index => $change) { $this->info(($index + 1) . ". 任务: {$change->taskName} - {$change->getChangeTypeDescription()} - " . date('H:i:s', $change->updatedAt)); } return 0; } }