feat: add Shoppro payment status synchronization service
- Implemented ShopproPaymentStatusSyncService to handle payment status synchronization between Shoppro and Orderpro. - Added methods for resolving watched status codes, finding candidate orders, and syncing individual order payments. - Introduced ShopproStatusMappingRepository for managing status mappings between Shoppro and Orderpro. - Created ShopproStatusSyncService to facilitate synchronization of order statuses from Shoppro to Orderpro.
This commit is contained in:
@@ -102,17 +102,19 @@ final class CronRepository
|
||||
/**
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public function listPastJobs(int $limit = 50): array
|
||||
public function listPastJobs(int $limit = 50, int $offset = 0): array
|
||||
{
|
||||
$safeLimit = max(1, min(200, $limit));
|
||||
$safeOffset = max(0, $offset);
|
||||
$statement = $this->pdo->prepare(
|
||||
'SELECT id, job_type, status, priority, attempts, max_attempts, scheduled_at, started_at, completed_at, last_error, created_at
|
||||
FROM cron_jobs
|
||||
WHERE status IN ("completed", "failed", "cancelled")
|
||||
ORDER BY completed_at DESC, id DESC
|
||||
LIMIT :limit'
|
||||
LIMIT :limit OFFSET :offset'
|
||||
);
|
||||
$statement->bindValue(':limit', $safeLimit, PDO::PARAM_INT);
|
||||
$statement->bindValue(':offset', $safeOffset, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
$rows = $statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (!is_array($rows)) {
|
||||
@@ -122,6 +124,18 @@ final class CronRepository
|
||||
return array_map(fn (array $row): array => $this->normalizeJobRow($row), $rows);
|
||||
}
|
||||
|
||||
public function countPastJobs(): int
|
||||
{
|
||||
$statement = $this->pdo->query(
|
||||
'SELECT COUNT(*)
|
||||
FROM cron_jobs
|
||||
WHERE status IN ("completed", "failed", "cancelled")'
|
||||
);
|
||||
$value = $statement !== false ? $statement->fetchColumn() : 0;
|
||||
|
||||
return max(0, (int) $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
|
||||
26
src/Modules/Cron/ShopproOrdersImportHandler.php
Normal file
26
src/Modules/Cron/ShopproOrdersImportHandler.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Cron;
|
||||
|
||||
use App\Modules\Settings\ShopproOrdersSyncService;
|
||||
|
||||
final class ShopproOrdersImportHandler
|
||||
{
|
||||
public function __construct(private readonly ShopproOrdersSyncService $syncService)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function handle(array $payload): array
|
||||
{
|
||||
return $this->syncService->sync([
|
||||
'max_pages' => (int) ($payload['max_pages'] ?? 3),
|
||||
'page_limit' => (int) ($payload['page_limit'] ?? 50),
|
||||
'max_orders' => (int) ($payload['max_orders'] ?? 200),
|
||||
]);
|
||||
}
|
||||
}
|
||||
24
src/Modules/Cron/ShopproPaymentStatusSyncHandler.php
Normal file
24
src/Modules/Cron/ShopproPaymentStatusSyncHandler.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Cron;
|
||||
|
||||
use App\Modules\Settings\ShopproPaymentStatusSyncService;
|
||||
|
||||
final class ShopproPaymentStatusSyncHandler
|
||||
{
|
||||
public function __construct(private readonly ShopproPaymentStatusSyncService $syncService)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function handle(array $payload): array
|
||||
{
|
||||
return $this->syncService->sync([
|
||||
'per_integration_limit' => (int) ($payload['per_integration_limit'] ?? 100),
|
||||
]);
|
||||
}
|
||||
}
|
||||
22
src/Modules/Cron/ShopproStatusSyncHandler.php
Normal file
22
src/Modules/Cron/ShopproStatusSyncHandler.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Cron;
|
||||
|
||||
use App\Modules\Settings\ShopproStatusSyncService;
|
||||
|
||||
final class ShopproStatusSyncHandler
|
||||
{
|
||||
public function __construct(private readonly ShopproStatusSyncService $syncService)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function handle(array $payload): array
|
||||
{
|
||||
return $this->syncService->sync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user