option('days'); $this->info("开始清理 {$days} 天前的日志记录..."); try { // 清理收获记录 $harvestLogRepository = new FarmHarvestLogRepository(); $harvestCount = $harvestLogRepository->cleanupOldLogs($days); $this->info("清理了 {$harvestCount} 条收获记录"); // 清理升级记录 $upgradeLogRepository = new FarmUpgradeLogRepository(); $upgradeCount = $upgradeLogRepository->cleanupOldLogs($days); $this->info("清理了 {$upgradeCount} 条升级记录"); // 清理团队收益记录 $teamProfitRepository = new FarmTeamProfitRepository(); $profitCount = $teamProfitRepository->cleanupOldLogs($days); $this->info("清理了 {$profitCount} 条团队收益记录"); $totalCount = $harvestCount + $upgradeCount + $profitCount; $this->info("共清理了 {$totalCount} 条日志记录"); Log::info('日志清理成功', [ 'days' => $days, 'harvest_count' => $harvestCount, 'upgrade_count' => $upgradeCount, 'profit_count' => $profitCount, 'total_count' => $totalCount ]); return 0; } catch (\Exception $e) { $this->error('日志清理失败: ' . $e->getMessage()); Log::error('日志清理失败', [ 'days' => $days, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); return 1; } } }