option('business-id')), ))); try { if ($businessIds !== []) { if ((bool) $this->option('full')) { throw new \InvalidArgumentException('--full 不能和 --business-id 同时使用。'); } $result = $synchronizer->syncBusinessIds( $businessIds, (bool) $this->option('dry-run'), ! (bool) $this->option('skip-approval-api'), ); } else { $result = $synchronizer->sync( (bool) $this->option('full'), (bool) $this->option('dry-run'), ); } } catch (Throwable $exception) { $this->error('同步失败,已保留上一版共享数据:' . $exception->getMessage()); return self::FAILURE; } if ($result['status'] === 'requires_full_sync') { $this->warn('流程明细尚未完成结构化全量同步,请使用 --full。'); return self::SUCCESS; } $this->info(sprintf( '%s:%d 个审批,%d 条明细,%d 笔付款;金额合计 %.2f,银行付款合计 %.2f。', $result['status'] === 'validated' ? '校验通过' : '同步完成', $result['workflows'], $result['details'], $result['payments'], $result['amount_total'], $result['bank_amount_total'], )); if ($businessIds === [] && ! (bool) $this->option('dry-run') && ! (bool) $this->option('skip-invoices') && $result['workflows'] > 0 && (bool) config('ding_invoice_data.sync_with_oa_process', true)) { try { $month = $invoiceSync->latestPendingMonth(); if ($month !== null) { $invoiceResult = $invoiceSync->syncMonth( $month, (int) config('ding_invoice_data.auto_scan_limit', 5), ); $this->info(sprintf( '发票增量识别完成:%d 个流程,新识别 %d 张,保留 %d 张,剩余 %d 个流程。', $invoiceResult['processed_flows'], $invoiceResult['recognized_invoices'], $invoiceResult['preserved_invoices'], $invoiceResult['remaining_flows'], )); } } catch (Throwable $exception) { report($exception); $this->warn('发票增量识别失败,OA 流程镜像已正常更新:' . $exception->getMessage()); } } return self::SUCCESS; } }