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:
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user