argument('days'); if ($days <= 0) { $this->error("保留天数必须大于0"); return 1; } $cutoffDate = Carbon::now()->subDays($days); $this->info("将清理 {$cutoffDate} 之前的奖励日志"); // 询问确认 if (!$this->confirm('确定要继续吗?此操作不可撤销')) { $this->info('操作已取消'); return 0; } try { // 删除过期日志 $count = GameRewardLog::where('created_at', '<', $cutoffDate)->delete(); $this->info("成功清理 {$count} 条过期奖励日志"); return 0; } catch (\Exception $e) { $this->error("清理过期奖励日志失败: {$e->getMessage()}"); return 1; } } }