✏️ 正在编辑: CallcenterCampanhaController.php
路径:
/srv/systems_dir/yuppiecred/application/controllers/CallcenterCampanhaController.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php use Modules\Callcenter\Form\ReprocessamentoForm; use Modules\Callcenter\Service\ReprocessamentoService; use \Modules\Gatekeeper\Service\Gatekeeper as Gatekeeper; /** * @permissao 0 */ class CallcenterCampanhaController extends Zend_Controller_Action { public function init() { $this->_helper->layout->setLayout('layout_callcenter'); $this->view->tab = (int) $this->getRequest()->getParam('tab'); } /** * @permissao 0 */ public function indexAction() { $request = $this->getRequest(); $form = new Form_Filtro_CallcenterCampanha(); $ns = new Zend_Session_Namespace('filtro_campanhas'); $grupo = Yuppie_Auth::getIdentity()->grupo; $formDigitacao = new Form_CallcenterEnviarDigitacaoAutomatica(); if ( $request->isPost() ){ $ns->unsetAll(); $ns->filtro_campanhas = $request->getPost(); if ( strstr($grupo, 'Supervisor') ){ $ns->filtro_campanhas['supervisor_id'] = Yuppie_Auth::getIdentity()->id; }elseif ( strstr($grupo, 'Callcenter') ){ $ns->filtro_campanhas['operador_id'] = Yuppie_Auth::getIdentity()->id; } } if ( isset($ns->filtro_campanhas) ){ $campanha = new Model_CallcenterCampanha(); $paginator = $campanha->listar($ns->filtro_campanhas, ['data_inicial ASC', 'campanhas.nome'], $this->_getParam('page', 1)); $form->populate($ns->filtro_campanhas); $this->view->paginator = $paginator; } $this->view->formEnvioDigitacao = $formDigitacao; $this->view->form = $form; } /** * @permissao 0 */ public function saveAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); $form = new Form_CallcenterCampanha(); $estratForm = new ReprocessamentoForm($id, $this->_request->getBaseUrl()); $grupo = Yuppie_Auth::getIdentity()->grupo; if( $request->isPost() && $form->isValid($request->getPost()) ){ $campanha = new Model_CallcenterCampanha($request->getPost()); try { $id = $campanha->salvar($campanha); if ( strstr($grupo, 'Supervisor') ){ $campanha->adicionarSupervisor($id, Yuppie_Auth::getIdentity()->id); } $this->_helper->flashMessenger(array( 'success' => 'Dados salvos com sucesso.' )); } catch ( Zend_Exception $e ) { $this->_helper->flashMessenger(array("error" => $e->getMessage())); } } if( $id > 0 ){ $campanha = new Model_CallcenterCampanha(); $dados = $campanha->exibir($id); $form->populate($dados->toArray()); $this->view->form_alocar_supervisores = new Form_CallcenterAlocarSupervisores(); $this->view->supervisores = $campanha->getUsuarioSupervisor($id); $this->view->plano = Gatekeeper::getPlanoConfig(); $this->view->id = $id; $formMensagensUra = new Form_CallcenterMsgUra(); $this->view->form_mensagens_ura = $formMensagensUra->populate(['campanha_id' => $id]); $this->view->lista_mensagens = (new Model_CallcenterMsgUra())->listar(['campanha_id' => $id]); } $this->view->form = $form; $this->view->estratForm = $estratForm; } /** * @permissao 0 */ public function deleteAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); if( $id > 0 ){ $campanha = new Model_CallcenterCampanha(); try{ $campanha->excluir($id); }catch(Exception $e){ $this->_helper->flashMessenger(array("error" => $e->getMessage())); } } $this->_redirect('/callcenter-campanha'); } /** * @permissao 0 */ public function importarBaseAction() { // $this->_helper->flashMessenger(array("info" => "Estamos em manutenção nessa função. Por favor, aguarde!")); // $this->_helper->redirector('index'); // return; set_time_limit(0); $form = new Form_CallcenterImportarBase(); $this->view->form = $form; } /** * @permissao 0 */ public function higienizarBaseAction() { set_time_limit(0); $this->_helper->flashMessenger(array( 'info' => "Observe que a higienização vai surtir efeito apenas do " . "que tiver sido higienizado da \"Última Higienização\" para trás." . "<br> Por padrão essa tela inicia com esse campo setado para 2 meses atrás." )); $request = $this->getRequest(); $campanhaId = $request->getParam('campanha_id'); $form = new Form_CallcenterHigienizar($campanhaId); $dados = $request->getPost(); if( $request->isPost() && $form->isValid($dados) ){ $reHigienizar = $request->getParam('re-higienizar', array()); $configs = include CLIENT_PATH . '/configs/callcenter.php'; if (!isset($configs['consulta_beneficio'])) { $this->_helper->json(array('alert' => 'Selecione um serviço para consulta de benefício nas configurações')); } $serviceClass = 'Core_Service_' . $configs['consulta_beneficio']; $consulta = new $serviceClass; $campanha = new Model_CallcenterCampanha(); $campanha->setId($request->getParam('campanha_id')); $base = $campanha->getBase($dados['data_higienizacao'], $dados['qtd_higienizar'], $reHigienizar); if (empty($base)) { $this->_helper->json(array('alert' => 'Nenhum cliente encontrado')); } $result = 0; $this->view->naoHigienizados = array(); foreach ($base as $contato) { try { $callcenterBase = new Model_CallcenterBase(); $callcenterBase->setHigienizarTelefones($request->getParam('higienizar_telefones')); if ($request->getParam("tipo_consulta") == "Siape") { $callcenterBase->consultaSiape($contato['cpf']); } else { $beneficios = $consulta->getConsignadoPorCpf($contato['cpf']); $callcenterBase->consultaBeneficios($contato['cpf'], $beneficios, 'A', false); } $callcenterBase->marcarHigienizado($contato['id'], $dados['campanha_alterar']); $result++; }catch ( Exception $e) { $this->view->naoHigienizados[] = array( 'cpf' => $contato['cpf'], 'nome' => $contato['nome'], 'motivo' => $e->getMessage() ); } } $response['success'] = "Higienização concluída com sucesso."; $response['content'] = $this->view->render('callcenter-campanha/resultado-higienizacao.phtml'); $this->_helper->json($response); } $this->view->form = $form; } /** * @permissao 0 */ public function ativarClienteCampanhaAction() { $request = $this->getRequest(); $campanhaId = $request->getParam('campanha_id'); $form = new Form_CallcenterAtivarClientes($campanhaId); $this->_helper->flashMessenger(array('info' => "Caso queira ativar todos os clientes dessa campanha, deixe os filtros em branco.")); $dados = $request->getPost(); if($request->isPost() && $form->isValid($dados)){ $descricaoAcao = $form->getValue('acao') == 2 ? "desativados" : "ativados"; try { $modelCallcenterBase = new Model_DbTable_CallcenterBase(); $result = $modelCallcenterBase->ativarClientes($dados, $form->getValue('acao')); if($result){ $this->_helper->flashMessenger(array('success' => "$result Clientes {$descricaoAcao} com sucesso")); }else{ $this->_helper->flashMessenger(array('alert' => "Nenhum registro foi alterado")); } } catch ( Core_Exception $exc ) { $this->_helper->flashMessenger(array('error' => $exc->getMessage())); } } $this->view->form = $form; } /** * @permissao 0 */ public function alocarOperadoresAction() { $request = $this->getRequest(); $form = new Form_CallcenterAlocarOperadores(); $dados = $request->getPost(); if($request->isPost() && $form->isValid($dados)){ $form->populate($dados); $fields = $dados; $fields['grupos'] = Model_GrupoUsuario::getIdCallcenter(); $fields['desativado'] = 0; $usuario = new Model_Usuario(); $this->view->operadores = $usuario->listar($fields, 'login ASC'); } $this->view->form = $form; } /** * @permissao 0 */ public function alocarDesalocarOperadoresAction() { $request = $this->getRequest(); $campanhas = explode(',', $request->getParam('campanhas')); if ($request->isPost()) { $acao = $request->getPost('opcoes') == 1 ? 'alocados' : 'desalocados'; $cont = 0; $operadores = $request->getPost('operadores'); $modelOperador = new Model_CallcenterOperador(); foreach ($operadores as $operadorId) { if ($request->getPost('opcoes') == 1) { $result = $modelOperador->alocarDesalocarOperadoresCampanhas(1, $campanhas, $operadorId); } elseif( $request->getPost('opcoes') == 2 ){ $result = $modelOperador->alocarDesalocarOperadoresCampanhas(2, $campanhas, $operadorId); } if( $result != null ) $cont++; } if ($cont > 0) { $this->_helper->flashMessenger(['success' => 'Operadores ' . $acao . ' com sucesso.']); } else { $this->_helper->flashMessenger(['alert' => 'Atenção! Nenhum operador foi ' . substr($acao, 0, strlen($acao) - 1) . '.']); } } $this->_helper->redirector('alocar-operadores'); } /** * @permissao 0 */ public function addSupervisorCampanhaAction() { $request = $this->getRequest(); $form = new Form_CallcenterAlocarSupervisores(); if( $request->isPost() && $form->isValid($request->getPost()) ){ $campanha = new Model_CallcenterCampanha(); $result = $campanha->adicionarSupervisor($form->getValue('campanha_id'), $form->getValue('supervisor_id')); if( $result != null ){ $this->_helper->flashMessenger(array( 'success' => 'Supervisor adicionado com sucesso.' )); } else { $this->_helper->flashMessenger(array( 'alert' => 'Atenção! O supervisor não foi adicionado.' )); } } $this->_helper->redirector('save', null, null, array( 'id' => $form->getValue('campanha_id'), 'tab' => 1 )); } /** * @permissao 0 */ public function deleteSupervisorCampanhaAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); if( $id > 0 ){ $campanha = new Model_CallcenterCampanha(); $campanha->excluirSupervisorCampanha($id); } $this->_helper->redirector('save', null, null, array( 'id' => $request->getParam('campanha_id'), 'tab' => 1 )); } /** * @permissao 0 */ public function consultarTelefonesAction() { $this->_helper->flashMessenger(array('info' => "Caso queira consultar todos os clientes dessa campanha, deixe os filtros em branco.")); set_time_limit(0); $modelDbCallcenterBase = new Model_DbTable_CallcenterBase(); $modelDbCallcenterCampanha = new Model_DbTable_CallcenterCampanha(); $modelCallcenterBase = new Model_CallcenterBase(); $request = $this->getRequest(); $campanhaId = $request->getParam('campanha_id'); $form = new Form_CallcenterConsultarTelefone($campanhaId); $dados = $request->getPost(); if($request->isPost() && $form->isValid($dados)){ $stm = $modelDbCallcenterBase->filtrarClientes($dados, ['cpf', 'id']); $clientes = $stm->fetchAll(); $clientesSemResposta = []; $clientesComResposta = []; foreach ( $clientes as $c ) { //puxa os telefones do cliente $return = $modelCallcenterBase->localizaTelefone($c['cpf']); if(empty($return)){ $clientesSemResposta[] = $c['cpf']; continue; } if( $dados['remover_telefones_existentes'] == 2 ){ (new Model_CallcenterTelefone())->excluirTelefonesBase($c['id']); } $clientesComResposta[] = $c['cpf']; try{ $modelCallcenterBase->salvarConsultaTelefone($return, $c['cpf'], $form->getValue('sobrepor_endereco')); } catch( Exception $e ){ $this->_helper->json(['alert' => $e->getMessage()]); } } $this->view->naoHigienizados = $clientesSemResposta; if (count($clientesComResposta) <= 0) { $response['alert'] = "Nenhum cliente foi alterado."; } else { $response['success'] = "Consulta realizada com sucesso!"; } $response['content'] = $this->view->render('callcenter-campanha/resultado-consultar-telefones.phtml'); $this->_helper->json($response); } $this->view->campanha = $modelDbCallcenterCampanha->find($campanhaId)->toArray(); $this->view->form = $form; } /** * @permissao 0 */ public function importacaoPropriaAction() { $request = $this->getRequest(); $campanhaId = $request->getParam('campanha_id'); $form = new Form_Filtro_ImportacaoPropria(); if ($request->isPost() && $form->isValid($request->getPost())) { $model = new Model_CallcenterCampanha(); try { $model->importacaoPropria($campanhaId, $request->getPost()); $this->_helper->flashMessenger([ 'success' => 'Processamento realizado com sucesso.' ]); $this->_helper->redirector('save', null, null, ['id' => $campanhaId, 'tab' => 1]); } catch (Exception $e) { $this->_helper->flashMessenger(array( 'error' => $e->getMessage() )); } } $this->view->form = $form; } public function uploadFileAction() { set_time_limit(0); $form = new Form_CallcenterImportarBase(); if( !$form->isValid($this->getRequest()->getPost()) ){ $this->_helper->json(array( 'validations' => $form->getMessages() )); } $upload = new Zend_File_Transfer_Adapter_Http(); $upload->setDestination(UPLOAD_PATH); $upload->receive(); $ns = new Zend_Session_Namespace('importacao_callenter_base'); $ns->unsetAll(); $ns->importacao_callcenter_base = $upload->getFileName(); $this->_helper->json(array( 'params' => $this->getRequest()->getParams(), 'url' => '/callcenter-campanha/read-file', )); } public function readFileAction() { set_time_limit(0); ini_set('memory_limit', -1); ini_set('auto_detect_line_endings', true); $request = $this->getRequest(); $params = $request->getParam('params'); $ns = new Zend_Session_Namespace('importacao_callenter_base'); try { $fileName = $ns->importacao_callcenter_base; $callcenterCampanha = new Model_CallcenterCampanha(); $result = $callcenterCampanha->importarBase($params, $fileName); } catch ( Core_Exception $exc ) { $this->_helper->json(array( 'readCompleted' => true, 'alert' => $exc->getMessage() )); } ini_set('auto_detect_line_endings', false); $ns->unsetAll(); $this->view->result = $result; $this->_helper->json(array( 'readCompleted' => true, 'content' => $this->view->render('callcenter-campanha/resultado-importacao.phtml'), // 'naoImportados' => $result['nao_importados'] )); } public function politicaIdadeAction() { $this->_helper->viewRenderer->setNorender(); $this->_helper->getHelper('layout')->disableLayout(); $request = $this->getRequest(); $campanhaId = $request->getParam('campanha_id'); $campanha = new Model_CallcenterCampanha(); $dadosCampanha = $campanha->exibir($campanhaId); if( !$dadosCampanha ){ $this->_helper->flashMessenger(array( 'error' => "Campanha não identificada." )); $this->_helper->redirector('index'); } if( !$dadosCampanha->idade_minima || !$dadosCampanha->idade_maxima ){ $this->_helper->flashMessenger(array( 'alert' => "Campanha não possui idade mínima e/ou máxima configurada." )); $this->_helper->redirector('index'); } $result = $campanha->tratarPoliticaIdade(); if( $result ){ $this->_helper->flashMessenger(array( 'success' => "Operação realizada com sucesso <br/> Registros desativados: {$result}." )); }else{ $this->_helper->flashMessenger(array( 'alert' => 'Nenhum registro foi desativado.' )); } $this->_helper->redirector('index', 'callcenter-campanha'); } /** * Higienizar saque complementar BMG API */ public function higienizarBmgAction() { set_time_limit(0); $request = $this->getRequest(); $campanhaId = $request->getParam('campanha_id', 0); if( $campanhaId <= 0 ){ $this->_helper->json([ 'alert' => 'Uma campanha deve ser informada!' ]); return; } $campanha = new Model_CallcenterCampanha(); $campanha->exibir($campanhaId); $cont = 0; if( !$campanha ){ $this->_helper->json([ 'alert' => 'Campanha não localizada.' ]); return; } $clientes = $campanha->getBase(); if( !$clientes ){ $this->_helper->json([ 'alert' => "Campanha não retornou clientes para a consulta." ]); return; } $ns = new Zend_Session_Namespace('result_higienizar_bmg'); $ns->result_higienizar_bmg = [ 'error' => [], 'success' => [], ]; foreach( $clientes as $cliente ){ try{ $service = new Core_Banco_Service_Bmg(); $service->setCodEntidade($campanha->getCodigoEntidade()); $dadosConsulta = $service->buscarPorCpf($cliente['cpf']); }catch( Exception $e ){ $ns->result_higienizar_bmg['error'][] = $cliente['cpf'] . " - " . $e->getMessage(); continue; } if( is_string($dadosConsulta) ){ $this->_helper->json([ 'alert' => $dadosConsulta ]); continue; } $callcenterBase = new Model_CallcenterBase(); $result = $callcenterBase->gravarConsultaBmg($dadosConsulta); if ($result) { $ns->result_higienizar_bmg['success'][] = $cliente['cpf']; $cont++; } } $this->_helper->json([ 'alert' => count($ns->result_higienizar_bmg['success']) . " higienizados com sucesso." ]); $ns->unsetAll(); } public function limparTelefonesAction() { $campanhaId = $this->getRequest()->getParam('campanha_id'); $result = (new Model_CallcenterCampanha())->limparTelefonesBase($campanhaId); if( $result ){ $this->_helper->json(['alert' => 'Telefones excluídos com sucesso!']); } $this->_helper->json(['alert' => 'Nenhum telefone foi excluído!']); } /** * Higienizar contratos no Banrisul */ public function higienizarBanrisulAction() { set_time_limit(0); $request = $this->getRequest(); $campanhaId = $request->getParam('campanha_id', 0); if ($campanhaId <= 0) { $this->_helper->json([ 'alert' => 'Uma campanha deve ser informada!' ]); return; } $campanha = new Model_CallcenterCampanha(); $campanha->exibir($campanhaId); if (!$campanha) { $this->_helper->json([ 'alert' => 'Campanha não localizada.' ]); return; } $clientes = $campanha->getBase(null, null, null, ['cpf']); if (!$clientes) { $this->_helper->json([ 'alert' => "Campanha não retornou clientes para a consulta." ]); return; } try{ $service = new Core_Banco_Service_Banrisul(); $retornoConsulta = $service->buscarPorCpfs($clientes); } catch(Exception $e){ $this->_helper->json([ 'alert' => $e->getMessage() ]); } if ($retornoConsulta) { $this->_helper->json([ 'alert' => "Total de CPFs higienizados: {$retornoConsulta['total_success']}" ]); } } /** * Higienizar contratos no PAN */ public function higienizarPanAction() { set_time_limit(0); $request = $this->getRequest(); $campanhaId = $request->getParam('campanha_id', 0); if ($campanhaId <= 0) { $this->_helper->json([ 'alert' => 'Uma campanha deve ser informada!' ]); return; } $campanha = new Model_CallcenterCampanha(); $campanha->exibir($campanhaId); if (!$campanha) { $this->_helper->json([ 'alert' => 'Campanha não localizada.' ]); return; } $clientes = $campanha->getBaseHigienizar(); if (!$clientes) { $this->_helper->json([ 'alert' => "Campanha não retornou clientes para a consulta." ]); return; } if (empty($campanha->getCodigoEntidade()) || empty($campanha->getCodigoPromotora())) { $this->_helper->json([ 'alert' => "Campanha não possui Código da Entidade ou Código da Promotora." ]); return; } try{ $service = new Core_Banco_Service_Pan(); $retorno = $service->buscarPorMatriculas( $clientes, $campanha->getCodigoEntidade(), $campanha->getCodigoPromotora() ); } catch(Exception $e){ $this->_helper->json([ 'alert' => $e->getMessage() ]); } if ($retorno) { $this->_helper->json([ 'alert' => "Total de CPFs higienizados: {$retorno['total_clientes']}" ]); } } public function estrategiaReprocessamentoSaveAction() { $request = $this->getRequest()->getPost(); try { $service = new ReprocessamentoService(); $service->save($request); $this->_helper->flashMessenger(['success' => 'Atualizado com sucesso.']); } catch (DomainException $domainException) { $this->_helper->flashMessenger(['error' => $domainException->getMessage()]); } catch (Throwable $throwable) { $this->_helper->flashMessenger(['error' => $throwable->getMessage()]); } $this->_helper->redirector('save', null, null, ['id' => $request['campanha_id'], 'tab' => 2]); } public function higienizarOmegaAction() { set_time_limit(0); $request = $this->getRequest(); $campanhaId = $request->getParam('campanha_id', 0); if ($campanhaId <= 0) { $this->_helper->json([ 'alert' => 'Uma campanha deve ser informada!' ]); return; } $campanha = new Model_CallcenterCampanha(); $campanha->exibir($campanhaId); if( !$campanha ){ $this->_helper->json([ 'alert' => 'Campanha não localizada.' ]); return; } $clientes = $campanha->getBase(); if (empty($clientes)) { $this->_helper->json([ 'alert' => "Campanha não retornou clientes para a consulta." ]); return; } try { $service = new \Core_Service_Omega(); $service->buscarLote($clientes, (int)$campanha->getCodigoEntidade()); } catch (Exception $e) { $this->_helper->json([ 'alert' => $e->getMessage() ]); return; } $this->_helper->json([ 'alert' => "Lote enviado para consulta. Quando o processamento for conluído, o Sistema Yuppie será atualizado." ]); } public function higienizarIn100Action() { set_time_limit(0); $request = $this->getRequest(); $campanhaId = $request->getParam('campanha_id', 0); if ($campanhaId <= 0) { $this->_helper->json([ 'alert' => 'Uma campanha deve ser informada!' ]); return; } $campanha = new Model_CallcenterCampanha(); $campanha->exibir($campanhaId); if (!$campanha) { $this->_helper->json([ 'alert' => 'Campanha não localizada.' ]); return; } $beneficios = $campanha->getBaseHigienizar(); if (!$beneficios) { $this->_helper->json([ 'alert' => "Campanha não retornou clientes para a consulta." ]); return; } try { $modelBeneficios = new Model_CallcenterBeneficio(); $modelBeneficios->consultarBeneficiosIn100Master($beneficios); } catch (Throwable $throwable) { $this->_helper->json([ 'alert' => $throwable->getMessage() ]); return; } $this->_helper->json([ 'alert' => "Consulta concluída com sucesso!" ]); } public function higienizarFgtsAction() { set_time_limit(0); $request = $this->getRequest(); $campanhaId = $request->getParam('campanha_id', 0); // if (stristr($request->getParam('metodo'), 'icred')) { // $this->_helper->json([ // 'alert' => 'Higienização pelo ICRED temporariamente desabilitada.' // ]); // return; // } if ($campanhaId <= 0) { $this->_helper->json([ 'alert' => 'Uma campanha deve ser informada!' ]); return; } $campanha = new Model_CallcenterCampanha(); $campanha->exibir($campanhaId); $cont = 0; if( !$campanha ){ $this->_helper->json([ 'alert' => 'Campanha não localizada.' ]); return; } $clientes = $campanha->getBase(); if( !$clientes ){ $this->_helper->json([ 'alert' => "Campanha não retornou clientes para a consulta." ]); return; } $resultadoHigienizacao = [ 'error' => [], 'success' => [], ]; try { $service = new \Core_Banco_Service_Autocontratacao_Fgts(); } catch (Exception $e) { $this->_helper->json([ 'alert' => $e->getMessage() ]); return; } foreach( $clientes as $cliente ){ $dadosConsulta = null; $result = null; try { $dadosConsulta = $service->consultar($cliente['cpf'], $cliente['id'], $request->getParam('metodo')); } catch (Exception $e) { $resultadoHigienizacao['error'][] = $cliente['cpf'] . " - " . $e->getMessage(); (new Model_DbTable_CallcenterFgts())->insert([ 'base_id' => $cliente['id'], 'descricao_erro' => $e->getMessage(), 'origem_consulta' => $service->getApi()->getOrigemConsulta() ]); } if ($dadosConsulta) { $callcenterBase = new Model_CallcenterBase(); $result = $callcenterBase->gravarConsultaFgts($dadosConsulta, $cliente['cpf']); } if ($result) { $resultadoHigienizacao['success'][] = $cliente['cpf']; $cont++; } } $this->_helper->json([ 'alert' => count($resultadoHigienizacao['success']) . " higienizados com sucesso." ]); } public function campanhaEnviarDigitacaoAction() { $request = $this->getRequest(); $callcenterBase = (new Model_DbTable_CallcenterBase())->fetchAll('campanha_id = ' . $request->getParam('campanha_id')); if (empty($callcenterBase)) { $this->_helper->json(['error' => "Nenhuma digitação foi enviada."]); } if ($request->getParam('banco_id') && $request->getParam('convenio_id')) { $table = new Model_DbTable_DigitacaoAutomatica(); try { $table->gravarParaDigitacaoCampanha($callcenterBase->toArray(), $request->getParam('convenio_id'), $request->getParam('banco_id'), $request->getParam('tipo_operacao')); } catch (Core_Exception $erro) { $this->_helper->json(['error' => "Houve um erro durante o envio dos dados para digitação: " . $erro->getMessage()]); } $this->_helper->json(['success' => "Dados enviados para a esteira. A digitação iniciará em breve. Acompanhe pela esteira de digitação."]); } $this->_helper->json(['error' => "Preencha todos os campos."]); } public function higienizarLimiteMasterAction() { set_time_limit(0); $request = $this->getRequest(); $campanhaId = (int)$request->getParam('campanha_id', 0); if ($campanhaId <= 0) { $this->_helper->json([ 'alert' => 'Uma campanha deve ser informada!' ]); return; } $cont = 0; $campanha = new Model_CallcenterCampanha(); $campanha->exibir($campanhaId); if (!$campanha) { $this->_helper->json([ 'alert' => 'Campanha não localizada.' ]); return; } if (!$campanha->getCodigoEntidade()) { $this->_helper->json([ 'alert' => 'Campanha sem convênio setado.' ]); return; } $clientes = $campanha->getBase(); if (!$clientes) { $this->_helper->json([ 'alert' => "Campanha não retornou clientes para a consulta." ]); return; } $ns = new Zend_Session_Namespace('result_higienizar_limite_master'); $ns->result_higienizar_limite_master = [ 'error' => [], 'success' => [], ]; foreach ($clientes as $cliente) { try { $params = [ 'cpf' => $cliente['cpf'], 'convenio_id' => $campanha->getCodigoEntidade() ]; $service = new Core_Banco_Service_Master_Api(); $dadosConsulta = $service->consultarLimiteCliente($params); } catch(Exception $e) { $ns->result_higienizar_limite_master['error'][] = $cliente['cpf'] . " - " . $e->getMessage(); continue; } if (!empty($dadosConsulta->mensagem)) { $ns->result_higienizar_limite_master['error'][] = $cliente['cpf'] . " - " . $dadosConsulta->mensagem; continue; } (new Model_DbTable_CallcenterBase())->update([ 'nome' => $dadosConsulta->nome, 'data_higienizacao' => Zend_Date::now()->get('yyyy-MM-dd HH:mm:ss'), 'valor_saque' => $dadosConsulta->limiteDisponivel ], "id = " . $cliente['id']); $result = (new Model_CallcenterBase())->addBeneficios([ 'beneficio' => $dadosConsulta->matricula, 'margem' => $dadosConsulta->vlMargem, 'margem_rcc' => $dadosConsulta->limiteDisponivel, 'limite_cartao' => $dadosConsulta->limiteTotal, 'banco_pagto' => $dadosConsulta->cdBanco, 'agencia_pagto' => $dadosConsulta->cdAgencia, 'conta_pagto' => $dadosConsulta->cdConta, 'origem' => "Banco Master", ], $cliente['cpf'], $cliente['id']); if ($result) { $ns->result_higienizar_limite_master['success'][] = $cliente['cpf']; $cont++; } } $this->_helper->json([ 'alert' => count($ns->result_higienizar_limite_master['success']) . " higienizados com sucesso." ]); $ns->unsetAll(); } public function saveMensagemOpcaoUraAction() { $request = $this->getRequest(); $form = new Form_CallcenterMsgUra(); $dados = $request->getPost(); if ($request->isPost() && $form->isValid($dados)) { $mensagem = new Model_CallcenterMsgUra($request->getPost()); try { $mensagem->salvar($mensagem); $this->_helper->flashMessenger(['success' => 'Dados salvos com sucesso.']); } catch ( Exception $e ) { $this->_helper->flashMessenger(['error' => $e->getMessage()]); } } $this->_helper->redirector('save', null, null, ['id' => $dados['campanha_id'], 'tab' => 3]); } public function deleteMensagemOpcaoUraAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); $campanha = (int) $request->getParam('campanha_id'); if ($id > 0) { $mensagem = new Model_CallcenterMsgUra(); try { $mensagem->excluir($id); } catch (Exception $e){ $this->_helper->flashMessenger(array('error' => $e->getMessage())); } } $this->_helper->redirector('save', null, null, ['id' => $campanha, 'tab' => 4]); } public function higienizarDaycovalAction() { set_time_limit(0); $request = $this->getRequest(); $campanhaId = $request->getParam('campanha_id', 0); if ($campanhaId <= 0) { $this->_helper->json([ 'alert' => 'Uma campanha deve ser informada!' ]); return; } $campanha = new Model_CallcenterCampanha(); $campanha->exibir($campanhaId); if (!$campanha) { $this->_helper->json([ 'alert' => 'Campanha não localizada.' ]); return; } $clientes = $campanha->getBase(null, null, null, ['cpf']); if (!$clientes) { $this->_helper->json([ 'alert' => "Campanha não retornou clientes para a consulta." ]); return; } try { $service = new Core_Banco_Service_Daycoval_Api(); $retornoConsulta = $service->buscarPorCpfs($clientes, $campanha->getCodigoEntidade()); } catch(Exception $e){ $this->_helper->json([ 'alert' => $e->getMessage() ]); } if ($retornoConsulta) { $this->_helper->json([ 'alert' => "Total de CPFs higienizados: {$retornoConsulta['total_success']}" ]); } } public function exportarCampanhaAction() { $request = $this->getRequest(); $campanhaId = $request->getParam('campanha_id'); $model = new Model_CallcenterCampanha(); $campanha = $model->getCampanhaExportar($campanhaId); if (!empty($campanha)) { $fileName = $model->exportarCampanha($campanha); $url = getcwd() . "/downloads/" . $fileName; header('Content-Type: text/csv'); header("Content-Disposition: attachment;filename={$fileName}"); // header('Cache-Control: max-age=0'); readfile($url); unlink(getcwd() . "/downloads/" . $fileName); exit; } $this->_helper->redirector('callcenter-campanha'); } }
💾 保存文件
← 返回文件管理器