Matriz facturacion
This commit is contained in:
@ -2,16 +2,15 @@
|
||||
namespace Incoviba\Controller\API\Ventas;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Implement\Exception\EmptyRedis;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\emptyBody;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Controller\withRedis;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\{EmptyRedis,EmptyResult};
|
||||
use Incoviba\Controller\API\{emptyBody,withJson};
|
||||
use Incoviba\Controller\withRedis;
|
||||
use Incoviba\Service;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Facturacion
|
||||
class Facturacion extends Ideal\Service
|
||||
{
|
||||
use withJson, withRedis, emptyBody;
|
||||
|
||||
@ -34,4 +33,31 @@ class Facturacion
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function ventas(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService,
|
||||
Service\Venta $ventaService, Service\Proyecto\Terreno $terrenoService, Service\UF $ufService,
|
||||
Service\IPC $ipcService): ResponseInterface
|
||||
{
|
||||
$input = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $input,
|
||||
'ventas' => []
|
||||
];
|
||||
$ventas = explode(',', $input['ventas']);
|
||||
foreach ($ventas as $venta_id) {
|
||||
$redisKey = "ventas:facturacion:venta:{$venta_id}";
|
||||
try {
|
||||
$venta = $this->fetchRedis($redisService, $redisKey);
|
||||
$output['ventas'] []= $venta;
|
||||
} catch (EmptyRedis) {
|
||||
try {
|
||||
$venta = $ventaService->getFacturacionById($venta_id);
|
||||
$output['ventas'] []= $venta;
|
||||
$this->saveRedis($redisService, $redisKey, $venta);
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->notice($exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user