✏️ 正在编辑: ConsultaBancoController.php
路径:
/srv/systems_dir/yuppiecred/application/controllers/ConsultaBancoController.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class ConsultaBancoController extends Zend_Controller_Action { public function init() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper('layout')->disableLayout(); parent::init(); } public function bradescoAction() { try { $this->view->banco = 'bradesco'; $request = $this->getRequest(); $minerador = new Core_Minerador_Bradesco(); if (empty($request->getParam('captcha'))){ $acesso = Model_MineradorAcesso::getAcesso('BRADESCO'); $this->view->captcha = $minerador->novaSimulacao( $acesso['usuario'], $acesso['senha'] ); $body = $this->view->render('consulta-banco/_captcha.phtml'); $this->_helper->json(['captcha' => $body]); } if ($request->isPost()){ $baseId = $request->getPost('base_id'); $cpf = $request->getPost('cpf'); $captcha = $request->getPost('captcha'); $result = $minerador->simularRefin($cpf, $captcha); $this->salvarConsultaScraping('BRADESCO', $cpf, $baseId, $result); $body = ['success' => 'Dados incluídos com sucesso.']; $this->getResponse()->setBody(json_encode($body)); } } catch (Core_Exception $ex){ $body = json_encode(['error' => $ex->getMessage()]); $this->getResponse()->setBody($body)->setHttpResponseCode(502); } finally { Model_MineradorAcesso::liberaUsuario('BRADESCO'); (new Zend_Session_Namespace('callcenter_atendimento'))->unsetAll(); } } public function safraAction() { try { $request = $this->getRequest(); $minerador = new Core_Minerador_Safra(); $acesso = Model_MineradorAcesso::getAcesso('SAFRA'); $baseId = $request->getParam('base_id'); $cpf = $request->getParam('cpf'); $uf = $request->getParam('uf'); $response = $minerador->simularRefin( $acesso->usuario, $acesso->senha, $acesso->agente, $uf, $cpf ); $this->salvarConsultaScraping('SAFRA', $cpf, $baseId, $response, $uf); $body = ['success' => 'Dados incluídos com sucesso.']; $this->getResponse()->setBody(json_encode($body)); } catch (Exception $ex){ $body = json_encode(['error' => $ex->getMessage()]); $this->getResponse()->setBody($body)->setHttpResponseCode(502); } finally { Model_MineradorAcesso::liberaUsuario('SAFRA'); (new Zend_Session_Namespace('callcenter_atendimento'))->unsetAll(); } } public function panAction() { try { $request = $this->getRequest(); $minerador = new Core_Minerador_Pan(); $acesso = Model_MineradorAcesso::getAcesso('PAN'); $baseId = $request->getParam('base_id'); $cpf = $request->getParam('cpf'); $response = $minerador->simularRefin( $acesso->usuario, $acesso->senha, $acesso->agente, $cpf ); $this->salvarConsultaScraping('PAN', $cpf, $baseId, $response); $body = ['success' => 'Dados incluídos com sucesso.']; $this->getResponse()->setBody(json_encode($body)); } catch (Core_Exception $ex){ $body = json_encode(['error' => $ex->getMessage()]); $this->getResponse()->setBody($body)->setHttpResponseCode(502); } finally { Model_MineradorAcesso::liberaUsuario('PAN'); (new Zend_Session_Namespace('callcenter_atendimento'))->unsetAll(); } } public function itauAction() { try { $this->view->banco = 'itau'; $request = $this->getRequest(); $minerador = new Core_Minerador_Itau(); $ns = new Zend_Session_Namespace('acesso_itau'); if (empty($ns->acesso)){ $ns->acesso = Model_MineradorAcesso::getAcesso('ITAU'); } if (!$request->isPost()){ $this->view->login = true; $this->view->captcha = $minerador->iniciarSessao(); $body = $this->view->render('consulta-banco/_captcha.phtml'); $this->_helper->json(['captcha' => $body]); } if ((bool) $request->getParam('captcha-login')){ $this->view->login = false; $this->view->captcha = $minerador->novaSimulacao( $ns->acesso->usuario, $ns->acesso->senha, $request->getParam('captcha') ); $body = $this->view->render('consulta-banco/_captcha.phtml'); $this->_helper->json(['captcha' => $body]); } if($request->isPost()){ $baseId = $request->getParam('base_id'); $cpf = $request->getParam('cpf'); $response = $minerador->simularRefin( $cpf, $request->getParam('captcha') ); $this->salvarConsultaScraping('ITAU', $cpf, $baseId, $response); $body = ['success' => 'Dados incluídos com sucesso.']; $this->getResponse()->setBody(json_encode($body)); } } catch (Core_Exception $ex){ $body = json_encode(['error' => $ex->getMessage()]); $this->getResponse()->setBody($body)->setHttpResponseCode(502); } finally{ Model_MineradorAcesso::liberaUsuario('ITAU'); (new Zend_Session_Namespace('callcenter_atendimento'))->unsetAll(); } } private function salvarConsultaScraping($banco, $cpf, $baseId, $response, $uf = null) { (new Model_DbTable_CallcenterBase)->update(array_filter([ 'nome' => $response->nome, 'data_nascimento' => $response->data_nascimento, 'uf' => $uf ]), "id = {$baseId}"); if (!empty($response->endereco)){ Model_CallcenterEndereco::existeOuCria($cpf, $response->endereco->cep) ->setOptions(array_filter([ "cpf_cliente" => String_Refatorar::formatarCpf($cpf), "endereco" => $response->endereco->logradouro, "numero" => $response->endereco->numero, "complemento" => $response->endereco->complemento, "bairro" => $response->endereco->bairro, "cidade" => $response->endereco->cidade, "uf" => $response->endereco->uf, "cep" => $response->endereco->cep ]))->salvar(); } if (!empty($response->telefone)){ Model_CallcenterTelefone::existeOuCria($cpf, $response->telefone) ->setOptions([ "cliente_id" => $baseId, "fone" => $response->telefone, "cpf_cliente" => String_Refatorar::formatarCpf($cpf), ])->salvar(); } $dbCallBeneficio = new Model_DbTable_CallcenterBeneficio(); foreach ($response->beneficios as $beneficio){ $dbCallBeneficio->insert([ 'cpf_cliente' => String_Refatorar::formatarCpf($cpf), 'base_cliente_id' => $baseId, 'beneficio' => $beneficio->matricula ]); foreach ($beneficio->emprestimos as $emprestimo){ Model_CallcenterEmprestimoCliente::existeOuCria($emprestimo->numero_contrato) ->setOptions(array_filter([ 'base_cliente_id' => $baseId, 'tipo' => 'EMPRESTIMO', 'cpf_cliente' => String_Refatorar::formatarCpf($cpf), 'beneficio' => $beneficio->matricula, 'banco' => strtoupper($banco), 'numero_contrato' => $emprestimo->numero_contrato, 'valor_emprestimo' => $emprestimo->valor_solicitado, 'valor_parcela' => $emprestimo->valor_parcela, 'quitacao' => $emprestimo->saldo_devedor, 'parcelas_abertas' => $emprestimo->parcelas_restantes, 'parcelas_pagas' => $emprestimo->parcelas_pagas, 'qtd_parcelas' => $emprestimo->total_parcelas ]))->salvar(); } } } }
💾 保存文件
← 返回文件管理器