27-05-2026 Update DHL Modul v2.0

This commit is contained in:
Kevin 2026-05-27 13:40:38 +00:00
parent 53bdba33cd
commit 036595be94
41 changed files with 3346 additions and 310 deletions

View file

@ -244,14 +244,7 @@ class DhlUpdateTracking extends Command
*/
private function shouldSendEmail(DhlShipment $shipment, string $oldStatus): bool
{
// E-Mail nur senden wenn:
// 1. Status ist jetzt "in_transit"
// 2. Vorheriger Status war NICHT "in_transit" (also Status hat sich geändert)
// 3. Noch keine E-Mail gesendet wurde
return $shipment->status === 'in_transit'
&& $oldStatus !== 'in_transit'
&& ! $shipment->wasTrackingEmailSent()
&& $shipment->canSendTrackingEmail();
return $shipment->shouldTriggerTrackingEmail($oldStatus);
}
/**
@ -282,7 +275,7 @@ class DhlUpdateTracking extends Command
// Sammle alle Sendungen für diese Bestellung, die noch keine E-Mail erhalten haben
$allShipments = DhlShipment::where('order_id', $order->id)
->where('status', 'in_transit')
->whereIn('status', DhlShipment::TRACKING_EMAIL_TRIGGER_STATUSES)
->whereNotNull('dhl_shipment_no')
->whereNull('tracking_email_sent_at')
->get();
@ -297,7 +290,7 @@ class DhlUpdateTracking extends Command
// Markiere alle Sendungen als versendet
foreach ($allShipments as $s) {
$s->markTrackingEmailSent('auto');
$s->markTrackingEmailSent('auto', $recipientEmail, $allShipments);
}
Log::info('[DHL Cron] Tracking email sent automatically', [