UnknownSec Bypass
403
:
/
mnt
/
lmsestudio-instance-vol002
/
lms_dfc6afe0cd4d
/
app
/
Services
/
Admin
/ [
drwxr-xr-x
]
Menu
Upload
Mass depes
Mass delete
Terminal
Info server
About
name :
BillingServices.php
<?php namespace EstudioLMS\Services\Admin; use Carbon\Carbon; use EstudioLMS\Repositories\Environment\HiredCourseRepository; use EstudioLMS\Repositories\Financial\BillingRepository; use EstudioLMS\Repositories\Financial\HireDetailRepository; use EstudioLMS\Repositories\Financial\HireHeaderRepository; use Laracasts\Flash\Flash; class BillingServices { /** * @var BillingRepository */ private $billingRepository; /** * @var ConfigurationServices */ private $configurationServices; /** * @var HireHeaderRepository */ private $hireHeaderRepository; /** * @var HireDetailRepository */ private $hireDetailRepository; /** * @var HiredCourseRepository */ private $hiredCourseRepository; /** * BillingServices constructor. * @param BillingRepository $billingRepository * @param ConfigurationServices $configurationServices * @param HireHeaderRepository $hireHeaderRepository * @param HireDetailRepository $hireDetailRepository * @param HiredCourseRepository $hiredCourseRepository */ public function __construct( BillingRepository $billingRepository, ConfigurationServices $configurationServices, HireHeaderRepository $hireHeaderRepository, HireDetailRepository $hireDetailRepository, HiredCourseRepository $hiredCourseRepository ) { $this->billingRepository = $billingRepository; $this->configurationServices = $configurationServices; $this->hireHeaderRepository = $hireHeaderRepository; $this->hireDetailRepository = $hireDetailRepository; $this->hiredCourseRepository = $hiredCourseRepository; } public function blockCourseForBillingOverdue($billingId) { $billing = $this->billingRepository->find($billingId); $date = Carbon::createFromFormat('Y-m-d H:i:s', $billing->due_date); if ($this->checkBlockForOverdue($date)) { $hireId = $billing->hire_header_id; $hireStatusId = 1; try { $this->hireHeaderRepository->update(['status' => $hireStatusId], $hireId); $this->hireDetailRepository->massStatusUpdate($hireId, $hireStatusId); $this->hiredCourseRepository->massStatusUpdate($hireId, $hireStatusId); } catch (\Exception $e) { \Log::critical('blockCourseForBillingOverdue' . PHP_EOL . $e->getCode() . ' -> ' . $e->getMessage()); } } } private function checkBlockForOverdue($date) { $daysForBlock = $this->configurationServices->boletoConfiguration()['block_after_days']; if ($date->diff(Carbon::now())->days >= $daysForBlock) { return true; } return false; } /* * Método responsável por desbloquear o curso após o pagamento. * Será feita a verificação, se não existe mais nenhum boleto vencido, dentro do prazo de bloqueio, * antes de efetivar o desbloqueio do curso. */ public function unblockCourseForPayment($hireHeaderId) { $billings = $this->billingRepository->findWhere([ ['hire_header_id', '=', $hireHeaderId], ['billing_status_id', '=', 2] ])->all(); if (count($billings) <= 0) { return true; } foreach ($billings as $key => $billing) { $date = Carbon::createFromFormat('Y-m-d H:i:s', $billing->due_date); if ($this->checkBlockForOverdue($date)) { return false; } } return true; } public function processReturnFile($file) { if ($this->configurationServices->boletoConfiguration()['bank'] !== '341') { flash()->warning('No momento só é possível a importação de retornos do banco 341 - Itaú '); return redirect()->route('admin.billing.index'); } $retorno = \Eduardokum\LaravelBoleto\Cnab\Retorno\Factory::make($file); $details = $retorno->getDetalhes(); foreach ($details as $key => $detail) { if ($detail->valorRecebido > 0) { if ($this->configurationServices->boletoConfiguration()['bank'] == '341') { if (empty($detail->numeroDocumento)) { $numDoc = (int)substr($detail->nossoNumero, 0, 8); } else { $numDoc = (int)$detail->numeroDocumento; } } $billing = $this->billingRepository->findByField('our_number', $numDoc)->first(); if (count($billing) > 0) { $this->billingRepository->updateBilling( $numDoc, $detail->getDataCredito('Y-m-d H:i:s'), $detail->getValorTarifa(), $detail->getValorRecebido() ); if ($this->unblockCourseForPayment($billing->hire_header_id)) { $hireStatusId = 3; $hireId = $billing->hire->id; $this->hireHeaderRepository->update(['status' => $hireStatusId], $hireId); $this->hireDetailRepository->massStatusUpdate($hireId, $hireStatusId); $this->hiredCourseRepository->massStatusUpdate($hireId, $hireStatusId); } } } } flash()->success('Arquivo de retorno processado'); return redirect()->route('admin.billing.index'); } }
Copyright © 2026 - UnknownSec