option('period')) ?: $now->copy()->subMonthNoOverflow()->format('Y-m'); $cutoff = trim((string) $this->option('cutoff')) ?: $now->copy()->startOfMonth()->toDateString(); $companyId = max(1, (int) $this->option('company')); $userId = $this->option('user') !== null ? (int) $this->option('user') : null; try { $completed = $store->findLatestRow( PayablesUnpricedCycleProcessor::RUN_DATASET, ['summary_month' => $period, 'status' => 'completed'], $companyId, ); if ($completed !== null) { $this->info("账期 {$period} 已完成,本次自动任务跳过。"); return self::SUCCESS; } $result = $processor->processFromPlatformPrices( $period, $cutoff, $companyId, $userId, ); $this->line(json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); return self::SUCCESS; } catch (Throwable $exception) { report($exception); $this->error('自动定价失败:' . $exception->getMessage()); return self::FAILURE; } } }