feat(111): payment transition event for Allegro+shopPRO re-import

Re-import zamowienia wykrywa tranzycje payment_status 0/1->2 i emituje
payment.status_changed, dzieki czemu chain reguly automatyzacji #7 zmienia
status na w_realizacji.

- OrderImportRepository: rozdzielenie paymentTransition (event 0/1->2) i
  statusOverwriteAllowed (preservacja status_code z Phase 62)
- AllegroOrderImportService + ShopproOrdersSyncService: emit
  payment.status_changed na re-imporcie (gate !wasCreated && wasPaymentTransition)
- bin/backfill_payment_transition_111.php: jednorazowy CLI dla zamowien
  payment_status=2 && status_code='nieoplacone' (Allegro + shopPRO)
- Naprawa luki znalezionej w analizie zamowienia #864

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-05 23:35:14 +02:00
parent 0da0241ebf
commit 5cf531d718
12 changed files with 691 additions and 31 deletions

View File

@@ -278,6 +278,15 @@ final class ShopproOrdersSyncService
'new_payment_status' => (string) ($aggregate['order']['payment_status'] ?? ''),
]);
}
if ($savedOrderId > 0 && !$wasCreated && $wasPaymentTransition && $this->automationService !== null) {
$this->automationService->trigger('payment.status_changed', $savedOrderId, [
'source' => 'shoppro',
'integration_id' => $integrationId,
'old_payment_status' => '',
'new_payment_status' => (string) ($aggregate['order']['payment_status'] ?? ''),
]);
}
} catch (Throwable $exception) {
$result['failed'] = (int) $result['failed'] + 1;
$errors = is_array($result['errors']) ? $result['errors'] : [];