option('date') ?: now('Asia/Shanghai')->format('Y-m-d'))); if (! preg_match('/^\d{4}-\d{2}-\d{2}$/D', $date)) { $this->error('快照日期格式应为 YYYY-MM-DD。'); return self::FAILURE; } try { $snapshotDate = CarbonImmutable::createFromFormat('!Y-m-d', $date, 'Asia/Shanghai'); } catch (Throwable) { $snapshotDate = null; } if ($snapshotDate === null || $snapshotDate->format('Y-m-d') !== $date) { $this->error('快照日期不是有效日期。'); return self::FAILURE; } try { $count = $archive->capture($snapshotDate); } catch (Throwable $exception) { report($exception); $this->error('店铺基础信息存档失败:' . $exception->getMessage()); return self::FAILURE; } $this->info(sprintf('已保存 %s 店铺基础信息快照,共 %d 条。', $date, $count)); return self::SUCCESS; } }