$result PlantingReimbursementWorkbench::build() 的结果 * @return array{ok:bool,reasons:list} */ public static function check(array $result, bool $requirePass = true, ?Carbon $now = null): array { $now ??= now(); $reasons = []; $sync = $result['sync'] ?? ['code' => 'unavailable', 'last_succeeded_at' => null]; $last = $sync['last_succeeded_at'] ?? null; if (($sync['code'] ?? '') !== 'ready' || $last === null) { $reasons[] = '聚工单数据同步异常(最后成功:' . ($last ? substr((string) $last, 0, 16) : '无') . ')'; } elseif ($now->diffInMinutes(Carbon::parse((string) $last), true) > self::STALE_MINUTES) { $reasons[] = '聚工单数据超过 ' . self::STALE_MINUTES . ' 分钟没同步(最后成功:' . substr((string) $last, 0, 16) . ')'; } if (trim((string) ($result['quota_error'] ?? '')) !== '') { $reasons[] = '种菜额度没有校验(' . $result['quota_error'] . ')'; } if (($result['quota_rules']['count'] ?? 1) === 0) { $reasons[] = '没有种菜额度规则'; } $failed = array_column(array_filter($result['summary']['checks'] ?? [], static fn (array $check): bool => ! $check['ok']), 'label'); if ($failed !== []) { $reasons[] = '自检未通过:' . implode('、', $failed); } if ($requirePass && (int) ($result['summary']['counts'][PlantingReimbursementAuditor::DECISION_PASS] ?? 0) === 0) { $reasons[] = '本批没有可报销的工单'; } return ['ok' => $reasons === [], 'reasons' => $reasons]; } }