403Webshell
Server IP : 54.233.248.239  /  Your IP : 172.28.1.13
Web Server : Apache
System : Linux ip-172-28-29-189 6.5.0-1014-aws #14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.2.34-43+ubuntu22.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/vinumday2_0/app/Services/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/vinumday2_0/app/Services/PedidoEntregaService.php
<?php 

namespace App\Services;

use Exception;
use DB;
use Illuminate\Support\Facades\Log;

class PedidoEntregaService {

    public static function checkSendMail($pedidoEntregaHasStatus){

        try {
            
            $pedidoEntrega  = $pedidoEntregaHasStatus->pedidoEntrega;
            $listaHistorico = [];
            foreach ($pedidoEntrega->statusHistorico as $historico) {
                if($historico->id != $pedidoEntregaHasStatus->id && $historico->id_pedido_entrega_status == $pedidoEntregaHasStatus->id_pedido_entrega_status){
                    return FALSE;
                }
            }

            return TRUE;

        } catch (Exception $e) {
            Log::info("[PedidoEntregaService::checkSendMail] => " . $e->getMessage());
            return TRUE;
        }

    }

    public static function getAssuntoEmail($pedidoEntregaHasStatus){

        try {
            
            $assunto = (!empty($pedidoEntregaHasStatus->status->assunto_email) ? $pedidoEntregaHasStatus->status->assunto_email : 'Solicitação de entrega atualizada!');

            if($pedidoEntregaHasStatus->id_pedido_entrega_status == 8 && $pedidoEntregaHasStatus->pedidoEntrega->retirada_local){ //Pronto para Envio => Retirada no Local
                $assunto = 'Seu pedido está aguardando por você!';
            }

            $replaces = ['<PEDIDO_ENTREGA>'];
            $by       = [$pedidoEntregaHasStatus->id_pedido_entrega];
            $assunto  = str_replace($replaces, $by, $assunto);
            $assunto = trim($assunto);

            return $assunto;

        } catch (Exception $e) {
            Log::info("[PedidoEntregaService::getAssuntoEmail] => " . $e->getMessage());
            return "Solicitação de entrega atualizada!";
        }

    }

    public static function getTransportadora($pedidoEntrega){
        $transportadora = ($pedidoEntrega->cotacaoValor && $pedidoEntrega->cotacaoValor->transportadora ? $pedidoEntrega->cotacaoValor->transportadora->nome : '');
        return $transportadora;
    }

    public static function getDiasEntrega($pedidoEntrega){
        //DIAS PARA ENTREGA
        $dias = ($pedidoEntrega->endereco && $pedidoEntrega->endereco->estado && $pedidoEntrega->endereco->estado->regiao ? $pedidoEntrega->endereco->estado->regiao->prazo_transporte : '');
        return $dias;
    }

    public static function getTextoEmail($pedidoEntrega, $pedidoEntregaStatus, $dataStatus, $pedidoEntregaRastreamento){

        try {

            $dataStatus = (!$dataStatus ? date('Y-m-d H:i:s') : $dataStatus);
            $textoEmail = PedidoEntregaService::replaceTexto($pedidoEntregaStatus->texto_email, $pedidoEntrega, $pedidoEntregaStatus, $dataStatus, $pedidoEntregaRastreamento);

            return $textoEmail;

        } catch (Exception $e) {
            return 'Pedido atualizado!';
        }

    }

    public static function getFraseObservacao($pedidoEntrega, $pedidoEntregaStatus, $dataStatus = FALSE, $pedidoEntregaRastreamento = FALSE){

        try {

            $dataStatus      = (!$dataStatus ? date('Y-m-d H:i:s') : $dataStatus);
            $fraseObservacao = PedidoEntregaService::replaceTexto($pedidoEntregaStatus->frase_observacao, $pedidoEntrega, $pedidoEntregaStatus, $dataStatus, $pedidoEntregaRastreamento);

            return $fraseObservacao;
            
        } catch (Exception $e) {
            Log::info('PedidoEntregaService::getFraseObservacao: ' . $e->getMessage());
            return 'Atualização Frase Observação';
        }

    }

    public static function replaceTexto($texto, $pedidoEntrega, $pedidoEntregaStatus, $dataStatus, $pedidoEntregaRastreamento){

        $texto = trim($texto);

        //TRATAR RETIRADA NO LOCAL
        if($pedidoEntrega->retirada_local == 1){ //retirada no local

            if($pedidoEntregaStatus->id == 3){  //preparando envio
                $texto = 'Avisaremos quando seu pedido estiver disponível para a coleta.';
            }elseif($pedidoEntregaStatus->id == 8){  //pronto para envio
                $texto = '<p>Seu pedido está disponível para retirada no período de Segunda a Sexta das 08:00 às 12:00 - 13:30 às 18:00, no endereço: <br><br> ';
                $texto .= 'Rua Olavo Bilac, 61 <br>
                            Bairro: Rio Branco <br> 
                            Caxias do Sul-RS <br> 
                            95010-080';
                $texto .= '</p>';
            }

        }elseif(!empty($texto)){

            $replaces = ['#TRANSPORTADORA#','#DIAS#','#DIA#','#HORA#','#MOTIVO#','#LINK_NOTA#'];

            //TRANSPORTADORA PEDIDO ENTREGA
            if(!$pedidoEntrega->cotacaoValor && $pedidoEntregaStatus->id == 5){
                $transportadora = '';
                $texto          = 'Seu pedido foi despachado e será entregue em até #DIAS# dias úteis';
            }else{
                $transportadora = ($pedidoEntrega->cotacaoValor && $pedidoEntrega->cotacaoValor->transportadora ? $pedidoEntrega->cotacaoValor->transportadora->nome : '');
            }

            //DIAS PARA ENTREGA
            $dias = ($pedidoEntrega->endereco && $pedidoEntrega->endereco->estado && $pedidoEntrega->endereco->estado->regiao ? $pedidoEntrega->endereco->estado->regiao->prazo_transporte : '');

            //DIA ENTREGA
            $dia = date('d/m/Y', strtotime($dataStatus));

            //HORA ENTREGA
            $hora = date('H:i', strtotime($dataStatus));

            //MOTIVO CANCELAMENTO
            $motivo = ($pedidoEntregaStatus->id == 7 && $pedidoEntregaRastreamento ? ": {$pedidoEntregaRastreamento->descricao}" : '');
            if($pedidoEntregaStatus->id == 7 && !$pedidoEntregaRastreamento){ //Cancelado
                $texto = 'Seu pedido foi cancelado.';
            }
            if($pedidoEntregaStatus->id == 12 && !$pedidoEntregaRastreamento){ //Reentrega
                $texto = 'Não conseguimos efetuar a sua entrega.';
            }

            $link_nota = '';
            if(($pedidoEntregaStatus->id == 4 || $pedidoEntregaStatus->id == 5) && !empty($pedidoEntrega->id_nota_fiscal_erp)){

                if($pedidoEntrega->adega->cliente){
                    $token = GeralService::getApiKeyTinyErp($pedidoEntrega->adega->cliente);
                }elseif($pedidoEntrega->id_cliente){
                    $token = GeralService::getApiKeyTinyErp(FALSE, $pedidoEntrega->id_cliente);
                }else{
                    $token = '';
                }
                
                if(!empty($token)){

                    $url     = 'https://api.tiny.com.br/api2/nota.fiscal.obter.link.php';
                    $content = "token=$token&id=".$pedidoEntrega->id_nota_fiscal_erp."&formato=json";

                    $resultBusca = json_decode(GeralService::enviarREST($url, $content));

                    if($resultBusca->retorno->status_processamento == 3){
                        $link_nota = '<a href="'.$resultBusca->retorno->link_nfe.'" target="_blank">VISUALIZAR</a>';
                    }else{
                        $link_nota = '';
                    }
                }
            }

            $by = [$transportadora, $dias, $dia, $hora, $motivo, $link_nota];

            $texto = str_replace($replaces,$by, $texto);

        }elseif($pedidoEntregaRastreamento){
            $texto = trim($pedidoEntregaRastreamento->descricao);
        }

        return $texto;

    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit