UpdateTrackingStatusCommand
extends ContainerAwareCommand
uses
LockableTrait
Table of Contents
Constants
-
HISTORY_BATCH_SIZE
= 200
-
SUPPORTED_CARRIERS
= ['GLS', 'GEODIS']
-
TERMINAL_STATUS_ALIASES
= ['DELIVERED' => 'DELIVERED', 'LIV' => 'DELIVERED', 'LIV-CFM' => 'DELIVERED', 'CANCELLED' => 'CANCELLED', 'CANCELED' => 'CANCELLED', 'CANCEL' => 'CANCELLED', 'ANN' => 'CANCELLED', 'ANNULE' => 'CANCELLED']
-
TRACKING_FETCH_BATCH_SIZE
= 200
-
UPDATE_BATCH_SIZE
= 200
Methods
-
configure()
: mixed
-
execute()
: mixed
-
addHistoryRecord()
: bool
-
buildReferenceKey()
: string
-
collectGeodisEvents()
: array<int, DateTimeImmutable, 'timestamp': int}>
-
collectTrackingIdsFromValues()
: array<int, string>
-
decodeToArray()
: array<int, string>
-
extractHistorySnapshotFromRows()
: array{last: array, seen: array>}
-
fetchHistoryRowsByTracking()
: array<int, array<int, array<string, mixed>>>
-
fetchTrackingCount()
: int
-
fetchTrackingsBatch()
: array<int, array<string, mixed>>
-
flushHistoryBuffer()
: void
-
flushShipmentStatusUpdates()
: void
-
getTrackingBaseSql()
: string
-
hasStatusSeen()
: bool
-
normalizeDateTimeValue()
: DateTimeImmutable|null
-
normalizeStatus()
: string|null
-
normalizeTrackingIds()
: array<int, string>
-
normalizeTrackingReference()
: string|null
-
parseCarrierDate()
: DateTimeImmutable|null
-
processGeodisHistory()
: DateTimeImmutable, 'timestamp': int}|null
-
processGlsHistory()
: DateTimeImmutable, 'timestamp': int}|null
-
resolveWarehouseIdFromRow()
: int|null
-
scheduleShipmentStatusUpdate()
: void
HISTORY_BATCH_SIZE
private
mixed
HISTORY_BATCH_SIZE
= 200
SUPPORTED_CARRIERS
private
mixed
SUPPORTED_CARRIERS
= ['GLS', 'GEODIS']
TERMINAL_STATUS_ALIASES
private
mixed
TERMINAL_STATUS_ALIASES
= ['DELIVERED' => 'DELIVERED', 'LIV' => 'DELIVERED', 'LIV-CFM' => 'DELIVERED', 'CANCELLED' => 'CANCELLED', 'CANCELED' => 'CANCELLED', 'CANCEL' => 'CANCELLED', 'ANN' => 'CANCELLED', 'ANNULE' => 'CANCELLED']
TRACKING_FETCH_BATCH_SIZE
private
mixed
TRACKING_FETCH_BATCH_SIZE
= 200
UPDATE_BATCH_SIZE
private
mixed
UPDATE_BATCH_SIZE
= 200
protected
configure() : mixed
execute()
protected
execute(InputInterface $input, OutputInterface $output) : mixed
Parameters
-
$input
: InputInterface
-
-
$output
: OutputInterface
-
addHistoryRecord()
private
addHistoryRecord(array<string, string> &$lastStatuses, array<string, array<string, bool>> &$seenStatuses, array<int, array<string, mixed>> &$historyBuffer, int $trackingId, string $carrier, string $status, DateTimeImmutable|null $recordedAt, DateTimeImmutable|null $carrierRecordedAt, string|null $trackingReference) : bool
Parameters
-
$lastStatuses
: array<string, string>
-
-
$seenStatuses
: array<string, array<string, bool>>
-
-
$historyBuffer
: array<int, array<string, mixed>>
-
-
$trackingId
: int
-
-
$carrier
: string
-
-
$status
: string
-
-
$recordedAt
: DateTimeImmutable|null
-
-
$carrierRecordedAt
: DateTimeImmutable|null
-
-
$trackingReference
: string|null
-
buildReferenceKey()
private
buildReferenceKey(string|null $trackingReference) : string
Parameters
-
$trackingReference
: string|null
-
collectGeodisEvents()
private
collectGeodisEvents(string $trackingId, int $warehouseId, GeodisService $geodisService) : array<int, DateTimeImmutable, 'timestamp': int}>
Parameters
-
$trackingId
: string
-
-
$warehouseId
: int
-
-
$geodisService
: GeodisService
-
Return values
array<int, DateTimeImmutable, 'timestamp': int}>
collectTrackingIdsFromValues()
private
collectTrackingIdsFromValues(mixed $trackingValue, mixed $fallbackTrackingValue) : array<int, string>
Parameters
-
$trackingValue
: mixed
-
-
$fallbackTrackingValue
: mixed
-
Return values
array<int, string>
decodeToArray()
private
decodeToArray(mixed $value[, bool $splitByComma = false ]) : array<int, string>
Parameters
-
$value
: mixed
-
-
$splitByComma
: bool
= false
-
Return values
array<int, string>
private
extractHistorySnapshotFromRows(array<string|int, mixed> $rows, string|null $currentShipmentStatus) : array{last: array, seen: array>}
Parameters
-
$rows
: array<string|int, mixed>
-
-
$currentShipmentStatus
: string|null
-
Return values
array{last: array, seen: array>}
fetchHistoryRowsByTracking()
private
fetchHistoryRowsByTracking(Connection $connection, array<int, int> $trackingIds) : array<int, array<int, array<string, mixed>>>
Parameters
-
$connection
: Connection
-
-
$trackingIds
: array<int, int>
-
Return values
array<int, array<int, array<string, mixed>>>
fetchTrackingCount()
private
fetchTrackingCount(Connection $connection, array<string, mixed> $baseParams) : int
Parameters
-
$connection
: Connection
-
-
$baseParams
: array<string, mixed>
-
fetchTrackingsBatch()
private
fetchTrackingsBatch(Connection $connection, array<string, mixed> $baseParams, int $lastId, int $limit) : array<int, array<string, mixed>>
Parameters
-
$connection
: Connection
-
-
$baseParams
: array<string, mixed>
-
-
$lastId
: int
-
-
$limit
: int
-
Return values
array<int, array<string, mixed>>
flushHistoryBuffer()
private
flushHistoryBuffer(Connection $connection, array<int, array<string, mixed>> &$historyBuffer) : void
Parameters
-
$connection
: Connection
-
-
$historyBuffer
: array<int, array<string, mixed>>
-
flushShipmentStatusUpdates()
private
flushShipmentStatusUpdates(Connection $connection, array<int, array{id: int, status: string}> &$updateBuffer) : void
Parameters
-
$connection
: Connection
-
-
$updateBuffer
: array<int, array{id: int, status: string}>
-
getTrackingBaseSql()
private
getTrackingBaseSql() : string
hasStatusSeen()
private
hasStatusSeen(array<string, array<string, bool>> $seenStatuses, string|null $status) : bool
Parameters
-
$seenStatuses
: array<string, array<string, bool>>
-
-
$status
: string|null
-
normalizeDateTimeValue()
private
normalizeDateTimeValue(mixed $value) : DateTimeImmutable|null
Parameters
-
$value
: mixed
-
Return values
DateTimeImmutable|null
normalizeStatus()
private
normalizeStatus(mixed $status) : string|null
Parameters
-
$status
: mixed
-
Return values
string|null
normalizeTrackingIds()
private
normalizeTrackingIds(array<int, string> $values) : array<int, string>
Parameters
-
$values
: array<int, string>
-
Return values
array<int, string>
normalizeTrackingReference()
private
normalizeTrackingReference(string|null $trackingReference) : string|null
Parameters
-
$trackingReference
: string|null
-
Return values
string|null
parseCarrierDate()
private
parseCarrierDate(mixed $value) : DateTimeImmutable|null
Parameters
-
$value
: mixed
-
Return values
DateTimeImmutable|null
processGeodisHistory()
private
processGeodisHistory(int $trackingId, string $carrier, array<int, string> $trackingIds, int $warehouseId, GeodisService $geodisService, array<string, string> &$lastStatuses, array<string, array<string, bool>> &$seenStatuses, array<int, array<string, mixed>> &$historyBuffer) : DateTimeImmutable, 'timestamp': int}|null
Parameters
-
$trackingId
: int
-
-
$carrier
: string
-
-
$trackingIds
: array<int, string>
-
-
$warehouseId
: int
-
-
$geodisService
: GeodisService
-
-
$lastStatuses
: array<string, string>
-
-
$seenStatuses
: array<string, array<string, bool>>
-
-
$historyBuffer
: array<int, array<string, mixed>>
-
Return values
DateTimeImmutable, 'timestamp': int}|null
processGlsHistory()
private
processGlsHistory(int $trackingId, string $carrier, array<int, string> $trackingIds, GlsService $glsService, array<string, string> &$lastStatuses, array<string, array<string, bool>> &$seenStatuses, array<int, array<string, mixed>> &$historyBuffer) : DateTimeImmutable, 'timestamp': int}|null
Parameters
-
$trackingId
: int
-
-
$carrier
: string
-
-
$trackingIds
: array<int, string>
-
-
$glsService
: GlsService
-
-
$lastStatuses
: array<string, string>
-
-
$seenStatuses
: array<string, array<string, bool>>
-
-
$historyBuffer
: array<int, array<string, mixed>>
-
Return values
DateTimeImmutable, 'timestamp': int}|null
resolveWarehouseIdFromRow()
private
resolveWarehouseIdFromRow(array<string|int, mixed> $row) : int|null
Parameters
-
$row
: array<string|int, mixed>
-
scheduleShipmentStatusUpdate()
private
scheduleShipmentStatusUpdate(array<int, array{id: int, status: string}> &$updateBuffer, int $trackingId, string $status) : void
Parameters
-
$updateBuffer
: array<int, array{id: int, status: string}>
-
-
$trackingId
: int
-
-
$status
: string
-