Cambio en queue para que no quede pegado esperando respuesta en cli.

Chequeo de servicios externos para agregar elementos pendientes.
This commit is contained in:
Juan Pablo Vial
2025-05-15 19:32:25 -04:00
parent 8d32aecd09
commit 8965354528
21 changed files with 687 additions and 65 deletions

View File

@ -1,9 +1,9 @@
<?php
namespace Incoviba\Service\Venta\MediosPago\Toku;
use Psr\Http\Client\ClientInterface;
use Incoviba\Repository;
use Incoviba\Service\Venta\MediosPago\AbstractEndPoint;
use Psr\Http\Client\ClientInterface;
class Customer extends AbstractEndPoint
{

View File

@ -1,14 +1,19 @@
<?php
namespace Incoviba\Service\Venta\MediosPago\Toku;
use Psr\Http\Client\ClientInterface;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Exception\ServiceAction\Read;
use Incoviba\Model\Venta;
use Incoviba\Repository;
use Incoviba\Service;
use Incoviba\Service\Venta\MediosPago\AbstractEndPoint;
use Psr\Http\Client\ClientInterface;
class Subscription extends AbstractEndPoint
{
public function __construct(ClientInterface $client, protected Repository\Venta\MediosPago\Toku\Subscription $subscriptionRepsitory)
public function __construct(ClientInterface $client,
protected Repository\Venta\MediosPago\Toku\Subscription $subscriptionRepsitory,
protected Service\Venta $ventaService)
{
parent::__construct($client);
}
@ -43,6 +48,28 @@ class Subscription extends AbstractEndPoint
$this->sendDelete($request_uri, [204], [404, 409]);
}
/**
* @return array
* @throws Read
*/
public function check(): array
{
$ventas = $this->ventaService->getAllWithCuotaPending();
$ids = array_column($ventas, 'id');
$existingSubscriptions = [];
try {
$existingSubscriptions = $this->subscriptionRepsitory->fetchByVentas($ids);
} catch (EmptyResult) {}
if (count($existingSubscriptions) === 0) {
$missingVentas = $ventas;
} else {
$missingVentas = array_filter($ventas, function($venta) use ($existingSubscriptions) {
return !array_any($existingSubscriptions, fn($subscription) => $subscription->venta->id === $venta->id);
});
}
return compact('existingSubscriptions', 'missingVentas');
}
protected function save(array $data): bool
{
return $this->doSave($this->subscriptionRepsitory, $data);