option('from') ?: FreightCarrierRules::START_DATE); $to = (string) ($this->option('to') ?: now()->addDay()->format('Y-m-d')); if (! preg_match('/^\d{4}-\d{2}-\d{2}$/', $from) || ! preg_match('/^\d{4}-\d{2}-\d{2}$/', $to)) { $this->error('--from / --to 需要 YYYY-MM-DD'); return self::FAILURE; } $carriers = array_values(array_filter(array_map('trim', (array) $this->option('carrier')))); $res = $service->recalculate($from, $to, $carriers === [] ? null : $carriers); $this->info(sprintf('运费核算完成:%s ~ %s,包裹 %d 个,核算成功 %d 个,无法核算 %d 个', $from, $to, $res['packages'], $res['ok'], $res['packages'] - $res['ok'])); return self::SUCCESS; } }