update
This commit is contained in:
@@ -19,7 +19,8 @@ final class ShopproOrdersSyncService
|
||||
private readonly ShopproStatusMappingRepository $statusMappings,
|
||||
private readonly OrdersRepository $orders,
|
||||
private readonly ShopproOrderMapper $mapper,
|
||||
private readonly ShopproProductImageResolver $imageResolver
|
||||
private readonly ShopproProductImageResolver $imageResolver,
|
||||
private readonly ?ShopproPullStatusMappingRepository $pullStatusMappings = null
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -237,15 +238,21 @@ final class ShopproOrdersSyncService
|
||||
$result['imported_updated'] = (int) $result['imported_updated'] + 1;
|
||||
}
|
||||
$wasCreated = !empty($save['created']);
|
||||
$wasPaymentTransition = !empty($save['payment_transition']);
|
||||
$savedOrderId = (int) ($save['order_id'] ?? 0);
|
||||
$summary = $wasCreated
|
||||
? 'Import zamowienia z shopPRO'
|
||||
: 'Zaktualizowano zamowienie z shopPRO (re-import)';
|
||||
if ($wasPaymentTransition) {
|
||||
$summary = 'Platnosc potwierdzona z shopPRO — zmiana statusu na w realizacji';
|
||||
} elseif ($wasCreated) {
|
||||
$summary = 'Import zamowienia z shopPRO';
|
||||
} else {
|
||||
$summary = 'Zaktualizowano zamowienie z shopPRO (re-import)';
|
||||
}
|
||||
$details = [
|
||||
'integration_id' => $integrationId,
|
||||
'source_order_id' => $sourceOrderId,
|
||||
'source_updated_at' => $sourceUpdatedAt,
|
||||
'created' => $wasCreated,
|
||||
'payment_transition' => $wasPaymentTransition,
|
||||
'trigger' => 'orders_sync',
|
||||
'trigger_label' => 'Synchronizacja zamowien',
|
||||
];
|
||||
@@ -297,9 +304,40 @@ final class ShopproOrdersSyncService
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string> shoppro_status_code => orderpro_status_code (reverse of DB direction)
|
||||
* @return array<string, string> shoppro_status_code => orderpro_status_code
|
||||
*/
|
||||
private function buildStatusMap(int $integrationId): array
|
||||
{
|
||||
if ($this->pullStatusMappings !== null) {
|
||||
return $this->buildStatusMapFromPullTable($integrationId);
|
||||
}
|
||||
|
||||
return $this->buildStatusMapFromPushTable($integrationId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function buildStatusMapFromPullTable(int $integrationId): array
|
||||
{
|
||||
$rows = $this->pullStatusMappings->listByIntegration($integrationId);
|
||||
$map = [];
|
||||
foreach ($rows as $row) {
|
||||
$shopCode = strtolower(trim((string) ($row['shoppro_status_code'] ?? '')));
|
||||
$orderCode = strtolower(trim((string) ($row['orderpro_status_code'] ?? '')));
|
||||
if ($shopCode === '' || $orderCode === '') {
|
||||
continue;
|
||||
}
|
||||
$map[$shopCode] = $orderCode;
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function buildStatusMapFromPushTable(int $integrationId): array
|
||||
{
|
||||
$rows = $this->statusMappings->listByIntegration($integrationId);
|
||||
$map = [];
|
||||
|
||||
Reference in New Issue
Block a user