src/Application/Internit/LeadBundle/Controller/ProductFrontController.php line 46

Open in your IDE?
  1. <?php
  2. namespace App\Application\Internit\LeadBundle\Controller;
  3. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  4. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  9. use App\Application\Internit\LeadBundle\Entity\Lead;
  10. use App\Application\Internit\LeadBundle\Entity\LeadErrorLog;
  11. use App\Application\Internit\LeadBundle\Entity\ChatbotLead;
  12. use Symfony\Component\HttpKernel\Exception\HttpException;
  13. use Swift_SmtpTransport;
  14. use Swift_Mailer;
  15. use Swift_Message;
  16. /**
  17.  * Product Front controller.
  18.  *
  19.  * @Route("/api/leads")
  20.  */
  21. class ProductFrontController extends Controller
  22. {
  23.     public function getBundleName()
  24.     {
  25.         return 'ApplicationInternitLeadBundle';
  26.     }
  27.     public function getEntityName()
  28.     {
  29.         return 'Product';
  30.     }
  31.     public function getFormType()
  32.     {
  33.         return 'App\Application\Internit\LeadBundle\Form\ProductType';
  34.     }
  35.     /**
  36.      * @Route("/send", name="front_product_lead_send")
  37.      * @Method("POST")
  38.      */
  39.     public function send(Request $request)
  40.     {
  41.         $entityManager $this->getDoctrine()->getManager();
  42.         $data json_decode($request->getContent());
  43.         $statusCode 400;
  44.         $result = [];
  45.         if (!$data) {
  46.             // $this->handleLeadError(null, null, null, 'Novo Lead não é válido.');
  47.             return $this->sendStatus(400"New Lead is not valid");
  48.         }
  49.         if (isset($data->token)) {
  50.             $product $this->getDoctrine()->getRepository('ApplicationInternitLeadBundle:Product')->findOneByToken($data->token);
  51.             if (!$product) {
  52.                 // $this->handleLeadError(null, null, null, 'ID da campanha não encontrado.');
  53.                 return $this->sendStatus(404"Product not found");
  54.             }
  55.             if (
  56.                 !empty($data->name) &&
  57.                 !empty($data->origem) &&
  58.                 !empty($data->group)
  59.             ) {
  60.                 // form de whatsapp não traz e-mail
  61.                 $emailLead = isset($data->email) ? $data->email '';
  62.                 $phoneLead = isset($data->phone) ? $data->phone '';
  63.                 $extraInfo = array();
  64.                 $to $this->get('tupi.caster.service')->next($product$emailLead$phoneLead);
  65.                 //dd($to);
  66.                 // dump($to);exit;
  67.                 $newLead = new Lead();
  68.                 //Obrigatórios
  69.                 $newLead->setName($data->name);
  70.                 $newLead->setGroup($data->group);
  71.                 $newLead->setOrigem($data->origem);
  72.                 $newLead->setProduct($product);
  73.                 $newLead->setEmail($emailLead);
  74.                 $newLead->setPhone($phoneLead);
  75.                 if (!empty($this->getDoctrine()->getRepository("ApplicationInternitLeadBundle:Lead")->attended($emailLead$phoneLead$product->getCorretores()))) {
  76.                     $newLead->setLoyalty(true);
  77.                 }
  78.                 //Opcionais
  79.                 if (isset($data->fixedPhone)) {
  80.                     $newLead->setFixedPhone(($data->fixedPhone $data->fixedPhone ''));
  81.                 }
  82.                 if (isset($data->empreendimento))
  83.                     $newLead->setEmpreendimento(($data->empreendimento $data->empreendimento ''));
  84.                 if (isset($data->utm_source))
  85.                     $newLead->setUtm_source(($data->utm_source $data->utm_source ''));
  86.                 if (isset($data->utm_medium))
  87.                     $newLead->setUtm_medium(($data->utm_medium $data->utm_medium ''));
  88.                 if (isset($data->utm_campaign))
  89.                     $newLead->setUtm_campaign(($data->utm_campaign $data->utm_campaign ''));
  90.                 if (isset($data->message))
  91.                     $newLead->setMessage(($data->message $data->message ''));
  92.                 // e-mail que a construtora configura para receber os leads deste produto.
  93.                 $productEmail $product->getEmail();
  94.                 if (!empty($productEmail) || !is_null($to)) {
  95.                     // obter e-mails de lead da imobiliária da vez
  96.                     $realEstateLeadEmails $this->getDoctrine()
  97.                         ->getRepository('ApplicationInternitLeadBundle:RealEstateEmail')
  98.                         ->findRealEstateLeadEmails($to['imob']);
  99.                     $realEstate $this->getDoctrine()
  100.                         ->getRepository('ApplicationInternitRealEstateBundle:RealEstate')
  101.                         ->findOneBy(['name' => $to['imob']]);
  102.                     //Chamar service de disparo para corretor
  103.                     $email1 $this->get('admin.mail.service');
  104.                     //$email2 = $this->get('admin.mail.service');
  105.                     // EMAILS COPY
  106.                     $emailCopySend = [];
  107.                     $emailToSend = [];
  108.                     if ($realEstate) {
  109.                         if ($realEstate->getReceiveLead()) {
  110.                             $emailCopySend[] = $realEstate->getEmail();
  111.                             //$email->setMessage()->setBCC($realEstate->getEmail());
  112.                         }
  113.                     }
  114.                     if (! empty($productEmail)) {
  115.                         $emailsSend explode(','str_replace(' '''$productEmail));
  116.                         foreach ($emailsSend as $sendMail) {
  117.                             $emailCopySend[] = $sendMail;
  118.                             //$email->setMessage()->setBCC($sendMail);
  119.                         }
  120.                     }
  121.                     // se houver o e-mail do corretor, ele é o destinatário principal e
  122.                     // o e-mail padrão da campanha é cópia oculta
  123.                     if (!empty($to['email'])) {
  124.                         // $email1->setMessage()->setTo($to['email']);
  125.                         $emailToSend[] = $to['email'];
  126.                         //dd($realEstate);
  127.                         // if (!empty($emailCopySend)) {
  128.                         //     $email1->setMessage()->setCC($emailCopySend);
  129.                         // }
  130.                     }
  131.                     // se não houver nenhum corretor para receber e-mail, o e-mail padrão
  132.                     // da campanha é o destinatário principal
  133.                     else if (! empty($productEmail)) {
  134.                         $emailsSend explode(','str_replace(' '''$productEmail));
  135.                         foreach ($emailsSend as $sendMail) {
  136.                             $emailCopySend[] = $sendMail;
  137.                             //$email->setMessage()->setBCC($sendMail);
  138.                         }
  139.                         // $email1->setMessage()->setTo($emailsSend);
  140.                         $emailToSend[] = $emailsSend;
  141.                         // if (!empty($emailCopySend)) {
  142.                         //     $email1->setMessage()->setCC($emailCopySend);
  143.                         // }
  144.                     }
  145.                     // if (!empty($realEstateLeadEmails)) {
  146.                     //     $email->setMessage()->setCC($realEstateLeadEmails);
  147.                     // }
  148.                     $newLead->setBrokerEmail(! empty($to['email']) ? $to['email'] : $productEmail); //Seta email do corretor que recebeu o lead
  149.                     $newLead->setBrokerRealState($to['imob']); //Seta Imobiliaria do corretor que recebeu o lead
  150.                     $extraInfo['broker_name'] = $to['name'];
  151.                     //if($to['phone'])
  152.                     //    $extraInfo['broker_phone'] = preg_replace('/[^0-9]/', '', $to['phone']);
  153.                     $extraInfo['realstate_name'] = $to['imob']; //strtoupper()
  154.                     $newLead->setSendStatus('Enviando');
  155.                     $entityManager->persist($newLead);
  156.                     $entityManager->flush();
  157.                     
  158.                     $this->get('tupi.caster.service')->gerarLogDistribuicao($product);
  159.                     // Insere na fila
  160.                     $conn $this->getDoctrine()->getConnection();
  161.                     $conn->insert('lead_queue', [
  162.                         'lead_id' => $newLead->getId(),
  163.                         'broker_name' => $to['name'],
  164.                         'broker_email' => $to['email'] ?? $productEmail,
  165.                         'copy_emails' => implode(','$emailCopySend),
  166.                         'status' => 'pendente',
  167.                         'created_at' => date('Y-m-d H:i:s'),
  168.                     ]);
  169.                     // Inicia o worker em background (se quiser garantir que ele esteja rodando)
  170.                     $projectRoot $this->get('kernel')->getProjectDir();
  171.                     $phpPath '/usr/local/bin/php';
  172.                     exec("nohup $phpPath $projectRoot/bin/console resend:lead:worker > $projectRoot/var/log/worker.log 2>&1 &");
  173.                     return $this->sendStatus(200"Lead criado "$extraInfo);
  174.                     // try {
  175.                     //     $this->get('tupi.caster.service')->gerarLogDistribuicao($product);
  176.                     //     $email1
  177.                     //         ->setMessage()
  178.                     //         ->setSubject("[leadcalper] " . $product->getName() . ' - ' . $newLead->getGroup() . ' - ' . $to['name'])
  179.                     //         ->setBody($this->renderView("@ApplicationInternit/SettingBundle/Resources/views/Mail/emailLead.html.twig", array(
  180.                     //             'data' => $newLead,
  181.                     //             'corretor' => $to['name'],
  182.                     //         )), 'text/html');
  183.                     //     $email1->send();
  184.                     //     $newLead->setSendStatus('Sim 1');
  185.                     //     $entityManager->persist($newLead);
  186.                     //     $entityManager->flush();
  187.                     // } catch (\Exception $e) {
  188.                     //     $this->handleLeadError($newLead, $to['name'], $to['email'], 'Erro ao enviar o e-mail: ');
  189.                     //     $entityManager->flush();
  190.                     //     return $this->sendStatus(200, "Lead created", $extraInfo);
  191.                     // }
  192.                     /*   $email2
  193.                         ->setMessage()
  194.                         ->setSubject("[Lead] ".$product->getName() . ' - ' . $newLead->getGroup())
  195.                         ->setBody($this->renderView("@ApplicationInternit/SettingBundle/Resources/views/Mail/emailLead.html.twig", array(
  196.                             'data' => $newLead,
  197.                         )), 'text/html');
  198.                     $email2->send();*/
  199.                 }
  200.                 // dump($newLead);
  201.                 // return $this->sendStatus(200, "Lead created", $extraInfo);
  202.             } else {
  203.                 // $this->handleLeadError(null, null, null, 'Conteúdo inválido, preencha os campos obrigatórios.');
  204.                 return $this->sendStatus(400"Invalid content");
  205.             }
  206.         }
  207.         // $this->handleLeadError(null, null, null, 'O token é obrigatório.');
  208.         return $this->sendStatus(400"Token is required");
  209.     }
  210.     public function sendLast(Request $request)
  211.     {
  212.         $data json_decode($request->getContent());
  213.         $statusCode 400;
  214.         $result = [];
  215.         if (!$data)
  216.             return $this->sendStatus(400"New Lead is not valid");
  217.         if (isset($data->token)) {
  218.             $product $this->getDoctrine()->getRepository('ApplicationInternitLeadBundle:Product')->findOneByToken($data->token);
  219.             // dump($product); exit;
  220.             if (!$product)
  221.                 return $this->sendStatus(404"Product not found");
  222.             if (
  223.                 !empty($data->name) &&
  224.                 !empty($data->origem) &&
  225.                 !empty($data->group)
  226.             ) {
  227.                 // form de whatsapp não traz e-mail
  228.                 $emailLead = isset($data->email) ? $data->email '';
  229.                 $phoneLead = isset($data->phone) ? $data->phone '';
  230.                 $extraInfo = array();
  231.                 $to $this->get('tupi.caster.service')->next($product$emailLead$phoneLead);
  232.                 //dd($to);
  233.                 // dump($to);exit;
  234.                 $newLead = new Lead();
  235.                 //Obrigatórios
  236.                 $newLead->setName($data->name);
  237.                 $newLead->setGroup($data->group);
  238.                 $newLead->setOrigem($data->origem);
  239.                 $newLead->setProduct($product);
  240.                 $newLead->setEmail($emailLead);
  241.                 $newLead->setPhone($phoneLead);
  242.                 //Opcionais
  243.                 if (isset($data->fixedPhone)) {
  244.                     $newLead->setFixedPhone(($data->fixedPhone $data->fixedPhone ''));
  245.                 }
  246.                 if (isset($data->empreendimento))
  247.                     $newLead->setEmpreendimento(($data->empreendimento $data->empreendimento ''));
  248.                 if (isset($data->utm_source))
  249.                     $newLead->setUtm_source(($data->utm_source $data->utm_source ''));
  250.                 if (isset($data->utm_medium))
  251.                     $newLead->setUtm_medium(($data->utm_medium $data->utm_medium ''));
  252.                 if (isset($data->utm_campaign))
  253.                     $newLead->setUtm_campaign(($data->utm_campaign $data->utm_campaign ''));
  254.                 if (isset($data->message))
  255.                     $newLead->setMessage(($data->message $data->message ''));
  256.                 // e-mail que a construtora configura para receber os leads deste produto.
  257.                 $productEmail $product->getEmail();
  258.                 if (!empty($productEmail) || !is_null($to)) {
  259.                     // obter e-mails de lead da imobiliária da vez
  260.                     $realEstateLeadEmails $this->getDoctrine()
  261.                         ->getRepository('ApplicationInternitLeadBundle:RealEstateEmail')
  262.                         ->findRealEstateLeadEmails($to['imob']);
  263.                     $realEstate $this->getDoctrine()
  264.                         ->getRepository('ApplicationInternitRealEstateBundle:RealEstate')
  265.                         ->findOneBy(['name' => $to['imob']]);
  266.                     //Chamar service de disparo para corretor
  267.                     $email1 $this->get('admin.mail.service');
  268.                     $email2 $this->get('admin.mail.service');
  269.                     // EMAILS COPY
  270.                     $emailCopySend = [];
  271.                     if ($realEstate) {
  272.                         if ($realEstate->getReceiveLead()) {
  273.                             $emailCopySend[] = $realEstate->getEmail();
  274.                             //$email->setMessage()->setBCC($realEstate->getEmail());
  275.                         }
  276.                     }
  277.                     if (! empty($productEmail)) {
  278.                         $emailsSend explode(','str_replace(' '''$productEmail));
  279.                         foreach ($emailsSend as $sendMail) {
  280.                             $emailCopySend[] = $sendMail;
  281.                             //$email->setMessage()->setBCC($sendMail);
  282.                         }
  283.                     }
  284.                     // se houver o e-mail do corretor, ele é o destinatário principal e
  285.                     // o e-mail padrão da campanha é cópia oculta
  286.                     if (!empty($to['email'])) {
  287.                         $email1->setMessage()->setTo($to['email']);
  288.                         //dd($realEstate);
  289.                         if (!empty($emailCopySend)) {
  290.                             $email2->setMessage()->setTo($emailCopySend);
  291.                         }
  292.                     }
  293.                     // se não houver nenhum corretor para receber e-mail, o e-mail padrão
  294.                     // da campanha é o destinatário principal
  295.                     else if (! empty($productEmail)) {
  296.                         $emailsSend explode(','str_replace(' '''$productEmail));
  297.                         foreach ($emailsSend as $sendMail) {
  298.                             $emailCopySend[] = $sendMail;
  299.                             //$email->setMessage()->setBCC($sendMail);
  300.                         }
  301.                         $email1->setMessage()->setTo($emailsSend);
  302.                         if (!empty($emailCopySend)) {
  303.                             $email2->setMessage()->setTo($emailCopySend);
  304.                         }
  305.                     }
  306.                     // if (!empty($realEstateLeadEmails)) {
  307.                     //     $email->setMessage()->setCC($realEstateLeadEmails);
  308.                     // }
  309.                     $newLead->setBrokerEmail(! empty($to['email']) ? $to['email'] : $productEmail); //Seta email do corretor que recebeu o lead
  310.                     $newLead->setBrokerRealState($to['imob']); //Seta Imobiliaria do corretor que recebeu o lead
  311.                     $extraInfo['broker_name'] = $to['name'];
  312.                     if ($to['phone'])
  313.                         $extraInfo['broker_phone'] = preg_replace('/[^0-9]/'''$to['phone']);
  314.                     $entityManager $this->getDoctrine()->getManager();
  315.                     $entityManager->persist($newLead);
  316.                     $entityManager->flush();
  317.                     $email1
  318.                         ->setMessage()
  319.                         ->setSubject("[Lead] " $product->getName() . ' - ' $newLead->getGroup())
  320.                         ->setBody($this->renderView("@ApplicationInternit/SettingBundle/Resources/views/Mail/emailLead.html.twig", array(
  321.                             'data' => $newLead,
  322.                         )), 'text/html');
  323.                     $email1->send();
  324.                     $email2
  325.                         ->setMessage()
  326.                         ->setSubject("[Lead] " $product->getName() . ' - ' $newLead->getGroup())
  327.                         ->setBody($this->renderView("@ApplicationInternit/SettingBundle/Resources/views/Mail/emailLead.html.twig", array(
  328.                             'data' => $newLead,
  329.                         )), 'text/html');
  330.                     $email2->send();
  331.                 }
  332.                 // dump($newLead);
  333.                 return $this->sendStatus(200"Lead created"$extraInfo);
  334.             } else {
  335.                 return $this->sendStatus(400"Invalid content");
  336.             }
  337.         }
  338.         return $this->sendStatus(400"Token is required");
  339.     }
  340.     private function sendStatus($code 401$message "Requisição não autorizada"$extra = array())
  341.     {
  342.         $array = array('message' => $message);
  343.         $array array_merge($array$extra);
  344.         $response = new Response(json_encode($array), $code);
  345.         $response->headers->set('Content-Type''application/json');
  346.         return $response;
  347.     }
  348.     private function handleBodyView($lead null$brokerName null)
  349.     {
  350.         return $this->renderView('@ApplicationInternit/SettingBundle/Resources/views/Mail/emailLead.html.twig', [
  351.             'data' => $lead ?? '',
  352.             'corretor' => $brokerName ?? '',
  353.         ]);
  354.     }
  355.     private function handleLeadError($lead null$brokerName null$brokerEmail null$errorMessage null)
  356.     {
  357.         $entityManager $this->getDoctrine()->getManager();
  358.         $html $this->handleBodyView($lead$brokerName);
  359.         if (empty($lead) && empty($brokerEmail)) {
  360.             $log = new LeadErrorLog();
  361.             $log->setLead($lead ?? null);
  362.             $log->setErrorMessage($errorMessage);
  363.             $log->setErrorType('Server Error');
  364.             $log->setCreatedAt(new \DateTime());
  365.             $entityManager->persist($log);
  366.             $lead->setSendStatus('Não');
  367.             $entityManager->persist($lead);
  368.             $entityManager->flush();
  369.             return;
  370.         }
  371.         // // Tentativa 1
  372.         try {
  373.             $mailer1 $this->get('admin.mail.service');
  374.             $mailer1->setMessage()
  375.                 ->setTo($brokerEmail ?? $lead->getProduct()->getEmail())
  376.                 ->setSubject("[leadcalper] " $lead->getProduct()->getName() .  ' -' $lead->getGroup() . ' - ' $brokerName)
  377.                 ->setBody(
  378.                     $html,
  379.                     'text/html'
  380.                 );
  381.             $mailer1->send();
  382.             $lead->setSendStatus('Sim 1');
  383.             $entityManager->persist($lead);
  384.         } catch (\Exception $e) {
  385.             // Tentativa 2
  386.             try{
  387.                 
  388.                 $mailer2 $this->get('admin.mail.service2');
  389.                 $mailer2->setMessage()
  390.                     ->setTo($brokerEmail ?? $lead->getProduct()->getEmail()) 
  391.                     ->setSubject("[leadcalper] " $lead->getProduct()->getName() . $lead->getGroup() . ' - ' $brokerName)
  392.                     ->setBody($html'text/html')
  393.                     ->send();
  394.                 $lead->setSendStatus('Sim 2');
  395.                 $entityManager->persist($lead);
  396.             }catch(\Exception $e){
  397.                 
  398.                 $log = new LeadErrorLog();
  399.                 $log->setLead($lead ?? null);
  400.                 $log->setErrorMessage($errorMessage);
  401.                 $log->setErrorType('Email');
  402.                 $log->setCreatedAt(new \DateTime());
  403.                 $entityManager->persist($log);
  404.                 $lead->setSendStatus('Não');
  405.                 $entityManager->persist($lead);
  406.             }
  407.         }
  408.     }
  409.     /**
  410.      * @Route("/resend", name="front_product_lead_resend")
  411.      * @Method("POST")
  412.      */
  413.     public function resendLead(Request $request)
  414.     {
  415.         $entityManager $this->getDoctrine()->getManager();
  416.         $data json_decode($request->getContent(), true);
  417.         $leadsNotSent $this->getDoctrine()->getRepository('ApplicationInternitLeadBundle:Lead')->findBySendStatusAndProduct('Não'$data['productId']);
  418.         foreach ($leadsNotSent as $lead) {
  419.             $lead->setSendStatus('Enviando');
  420.             $entityManager->flush();
  421.             $brokerEmail $lead->getBrokerEmail();
  422.             $broker $this->getDoctrine()->getRepository('ApplicationSonataUserBundle:User')->findByEmail($brokerEmail);
  423.             $realEstate $this->getDoctrine()
  424.                         ->getRepository('ApplicationInternitRealEstateBundle:RealEstate')
  425.                         ->findOneBy(['name' => $lead->getBrokerRealState()]);
  426.             $product $this->getDoctrine()->getRepository('ApplicationInternitLeadBundle:Product')->find($data['productId']);
  427.             $productEmail $product->getEmail();
  428.             // COPY EMAILS
  429.             $emailCopySend = [];
  430.             if ($realEstate) {
  431.                 if ($realEstate->getReceiveLead()) {
  432.                     $emailCopySend[] = $realEstate->getEmail();
  433.                 }
  434.             }
  435.             if (! empty($productEmail)) {
  436.                 $emailsSend explode(','str_replace(' '''$productEmail));
  437.                 foreach ($emailsSend as $sendMail) {
  438.                     $emailCopySend[] = $sendMail;
  439.                 }
  440.             }
  441.             // se não houver nenhum corretor para receber e-mail, o e-mail padrão
  442.             // da campanha é o destinatário principal
  443.             else if (! empty($productEmail)) {
  444.                 $emailsSend explode(','str_replace(' '''$productEmail));
  445.                 foreach ($emailsSend as $sendMail) {
  446.                     $emailCopySend[] = $sendMail;
  447.                 }
  448.             }
  449.             $conn $this->getDoctrine()->getConnection();
  450.             $conn->insert('lead_queue', [
  451.                 'lead_id' => $lead->getId(),
  452.                 'broker_name' => $broker['firstname'],
  453.                 'broker_email' => $brokerEmail,
  454.                 'copy_emails' => implode(','$emailCopySend),
  455.                 'status' => 'pendente',
  456.                 'created_at' => date('Y-m-d H:i:s'),
  457.             ]);
  458.         }
  459.         $projectRoot $this->get('kernel')->getProjectDir();
  460.         $phpPath '/usr/local/bin/php';
  461.         exec("nohup $phpPath $projectRoot/bin/console resend:lead:worker > $projectRoot/var/log/worker.log 2>&1 &");
  462.         $entityManager->flush();
  463.         return $this->sendStatus(200"Leads Enviados");
  464.     }
  465.     /**
  466.      * @Route("/resend/cronjob1", name="front_product_lead_resend_cronjob1")
  467.      * @Method("POST")
  468.      */
  469.     public function resendLeadCron1()
  470.     {
  471.         $entityManager $this->getDoctrine()->getManager();
  472.         $leadsNotSent $this->getDoctrine()->getRepository('ApplicationInternitLeadBundle:Lead')->findBy(['send_status' => 'Não']);
  473.         foreach ($leadsNotSent as $lead) {
  474.             $lead->setSendStatus('Enviando');
  475.             $entityManager->flush();
  476.             $brokerEmail $lead->getBrokerEmail();
  477.             $broker $this->getDoctrine()->getRepository('ApplicationSonataUserBundle:User')->findByEmail($brokerEmail);
  478.             $conn $this->getDoctrine()->getConnection();
  479.             $conn->insert('lead_queue_cron', [
  480.                 'lead_id' => $lead->getId(),
  481.                 'broker_name' => $broker['firstname'],
  482.                 'broker_email' => $brokerEmail,
  483.                 'status' => 'pendente',
  484.                 'created_at' => date('Y-m-d H:i:s'),
  485.             ]);
  486.         }
  487.         $projectRoot $this->get('kernel')->getProjectDir();
  488.         $phpPath '/usr/local/bin/php';
  489.         exec("nohup $phpPath $projectRoot/bin/console resend:lead:workerCron1 > $projectRoot/var/log/worker.log 2>&1 &");
  490.         $entityManager->flush();
  491.         return $this->sendStatus(200"Leads Enviados");
  492.     }
  493.     /**
  494.      * @Route("/resend/cronjob2", name="front_product_lead_resend_cronjob2")
  495.      * @Method("POST")
  496.      */
  497.     public function resendLeadCron2()
  498.     {
  499.         $projectRoot $this->get('kernel')->getProjectDir();
  500.         $phpPath '/usr/local/bin/php';
  501.         exec("nohup $phpPath $projectRoot/bin/console resend:lead:workerCron2 > $projectRoot/var/log/worker.log 2>&1 &");
  502.         return $this->sendStatus(200"Notificações Enviadas");
  503.     }
  504. }