Redis
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user