This commit is contained in:
2023-11-23 00:53:49 -03:00
parent 9ab0515954
commit bf03e85975
32 changed files with 599 additions and 314 deletions

View File

@ -1,24 +1,25 @@
<?php
namespace Incoviba\Controller\API\Ventas;
use DateTimeImmutable;
use DateInterval;
use Incoviba\Controller\API\withRedis;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use DateTimeImmutable;
use Incoviba\Common\Implement\Exception\EmptyRedis;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Controller\API\withJson;
use Incoviba\Controller\withRedis;
use Incoviba\Repository;
use Incoviba\Service;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class Cuotas
{
use withJson, withRedis;
public function hoy(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Cuota $cuotaRepository, Service\Redis $redisService): ResponseInterface
public function hoy(ServerRequestInterface $request, ResponseInterface $response,
Repository\Venta\Cuota $cuotaRepository, Service\Redis $redisService): ResponseInterface
{
$today = new DateTimeImmutable();
$redisKey = "cuotas_hoy-{$today->format('Y-m-d')}";
$redisKey = "cuotas:hoy:{$today->format('Y-m-d')}";
$output = [
'cuotas' => 0
];
@ -32,10 +33,11 @@ class Cuotas
}
return $this->withJson($response, $output);
}
public function pendiente(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Cuota $cuotaRepository, Service\Redis $redisService): ResponseInterface
public function pendiente(ServerRequestInterface $request, ResponseInterface $response,
Repository\Venta\Cuota $cuotaRepository, Service\Redis $redisService): ResponseInterface
{
$today = new DateTimeImmutable();
$redisKey = "cuotas_pendientes-{$today->format('Y-m-d')}";
$redisKey = "cuotas:pendientes:{$today->format('Y-m-d')}";
$output = [
'cuotas' => 0
];
@ -49,10 +51,12 @@ class Cuotas
}
return $this->withJson($response, $output);
}
public function porVencer(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Cuota $cuotaRepository, Service\Redis $redisService, Service\Format $formatService): ResponseInterface
public function porVencer(ServerRequestInterface $request, ResponseInterface $response,
Repository\Venta\Cuota $cuotaRepository, Service\Redis $redisService,
Service\Format $formatService): ResponseInterface
{
$today = new DateTimeImmutable();
$redisKey = "cuotas_por_vencer-{$today->format('Y-m-d')}";
$redisKey = "cuotas:por_vencer:{$today->format('Y-m-d')}";
try {
$output = $this->fetchRedis($redisService, $redisKey);
} catch (EmptyRedis) {