option('reconcile') && $this->option('preview')) throw new \InvalidArgumentException('reconcile不支持preview,请使用日期预览'); $allowToday=(bool)$this->option('allow-today'); if ($this->option('reconcile') && $allowToday) throw new \InvalidArgumentException('allow-today不能与reconcile同时使用'); if ($this->option('reconcile') && $this->option('diagnose')) throw new \InvalidArgumentException('diagnose不能与reconcile同时使用'); $defaultDate=Carbon::now(ShareDefaults::TIMEZONE); if (!$allowToday) $defaultDate->subDay(); if ($this->option('diagnose')) { $result=$service->diagnose($this->argument('date') ?: $defaultDate->toDateString()); $this->line(json_encode($result,JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR)); return self::SUCCESS; } $result=$this->option('reconcile') ? $service->reconcile() : $service->settle( $this->argument('date') ?: $defaultDate->toDateString(), !(bool)$this->option('preview'), $allowToday ); $this->line(json_encode($result,JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR)); return self::SUCCESS; } catch (\Throwable $e) { $this->error($e->getMessage()); return self::FAILURE; } } }