line(printf('[%s] 开始%s', date("Y-m-d H:i:s"), $this->description)); begin_time_consuming(); parent::execute($input, $output); } protected function getDateTime() { if ($month = $this->argument('month')) { if (!preg_match('/\d{4}-\d{1,2}/', $month)) { throw new \App\Exceptions\InvalidArgumentException('请输入正确的年月 #示例: 2018-10'); } return Carbon::parse($month)->startOfMonth(); } return Carbon::now()->startOfMonth()->subMonth(); } protected function getArguments() { return [ ['month', InputArgument::OPTIONAL, '要同步的数据月份,默认上个月 #示例: 2018-10'], ]; } }