✏️ 正在编辑: CallcenterBeneficio.php
路径:
/srv/systems_dir/yuppiecred-lidernegocios/application/models/CallcenterBeneficio.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_CallcenterBeneficio { //<editor-fold defaultstate="collapsed" desc="Propriedades e getters e setters"> private $_id; private $_cpfCliente; private $_baseClienteId; private $_beneficio; private $_margemLivre; private $_margemCartao; private $_margemCartaoRmc; private $_margemBensDuraveis; private $_mr; private $_situacao; private $_bancoPagto; private $_agenciaPagto; private $_contaPagto; private $_orgaoPagador; private $_tipoPagto; private $_detalhamento; private $_dataConsulta; private $_competencia; private $_especie; private $_dib; private $_cessado; private $_bloqEmp; private $_origem; public function getId() { return $this->_id; } public function getCpfCliente() { return $this->_cpfCliente; } public function getBaseClienteId() { return $this->_baseClienteId; } public function setBaseClienteId($baseClienteId) { $this->_baseClienteId = $baseClienteId; } public function getBeneficio() { return $this->_beneficio; } public function getMargemLivre() { return $this->_margemLivre; } public function getMargemCartao() { return $this->_margemCartao; } public function getMargemCartaoRmc() { return $this->_margemCartaoRmc; } public function getMr() { return $this->_mr; } public function getSituacao() { return $this->_situacao; } public function getBancoPagto() { return $this->_bancoPagto; } public function getAgenciaPagto() { return $this->_agenciaPagto; } public function getContaPagto() { return $this->_contaPagto; } public function getOrgaoPagador() { return $this->_orgaoPagador; } public function getTipoPagto() { return $this->_tipoPagto; } public function getDetalhamento() { return $this->_detalhamento; } public function getDataConsulta() { return $this->_dataConsulta; } public function getCompetencia() { return $this->_competencia; } public function getEspecie() { return $this->_especie; } public function setId($id) { $this->_id = $id; } public function setCpfCliente($cpfCliente) { $this->_cpfCliente = String_Refatorar::formatarCpf($cpfCliente); } public function setBeneficio($beneficio) { $this->_beneficio = $beneficio; } public function setMargemLivre($margemLivre) { $this->_margemLivre = Core_FilterValor::filter($margemLivre); } public function setMargemCartao($margemCartao) { $this->_margemCartao = Core_FilterValor::filter($margemCartao); } public function setMargemCartaoRmc($margemCartaoRmc) { $this->_margemCartaoRmc = Core_FilterValor::filter($margemCartaoRmc); } public function setMr($mr) { $this->_mr = Core_FilterValor::filter($mr); } public function setSituacao($situacao) { $this->_situacao = $situacao; } public function setBancoPagto($bancoPagto) { $this->_bancoPagto = $bancoPagto; } public function setAgenciaPagto($agenciaPagto) { $this->_agenciaPagto = $agenciaPagto; } public function setContaPagto($contaPagto) { $this->_contaPagto = $contaPagto; } public function setOrgaoPagador($orgaoPagador) { $this->_orgaoPagador = $orgaoPagador; } public function setTipoPagto($tipoPagto) { $this->_tipoPagto = $tipoPagto; } public function setDetalhamento($detalhamento) { $this->_detalhamento = $detalhamento; } public function setDataConsulta($dataConsulta) { $this->_dataConsulta = $dataConsulta; } public function setCompetencia($competencia) { $this->_competencia = $competencia; } public function setEspecie($especie) { $this->_especie = $especie; } public function getDib() { return $this->_dib; } public function setDib($dib) { if( !$dib ){ return; } if( Zend_Date::isDate($dib, 'dd/MM/yyyy') ){ $dt = new Zend_Date($dib, 'dd/MM/yyyy'); }else{ $dt = new Zend_Date($dib); } $this->_dib = $dt->get('yyyy-MM-dd'); } public function getCessado() { return $this->_cessado; } public function getBloqEmp() { return $this->_bloqEmp; } public function setCessado($cessado) { $this->_cessado = $cessado; return $this; } public function setBloqEmp($bloqEmp) { $this->_bloqEmp = $bloqEmp; return $this; } public function getOrigem() { return $this->_origem; } public function setOrigem($origem) { $this->_origem = $origem; return $this; } public function getMargemBensDuraveis() { return $this->_margemBensDuraveis; } public function setMargemBensDuraveis($margemBensDuraveis) { $this->_margemBensDuraveis = Core_FilterValor::filter($margemBensDuraveis); } // </editor-fold> /** @var Model_DbTable_CallcenterBeneficio */ private $table; /** * Retorna um fetchRow do item passado por parâmetro * @param int $id * @return Zend_Db_Table_Row_Abstract | null */ public function exibir($id) { $dbtable = new Model_DbTable_CallcenterBeneficio(); return $dbtable->fetchRow("id = " . $id); } public function __construct($options = null) { $this->table = table('callcenter-beneficio'); if( is_array($options) ){ $this->setOptions($options); } } public function setOptions(array $options) { if( isset($options['id']) && ($dados = $this->exibir($options['id'])) ){ if( $dados ){ if( array_key_exists('origem', $options) && empty($options['origem']) ){ unset($options['origem']); } $options = array_merge($dados->toArray(), $options); } } $methods = get_class_methods($this); foreach ( $options as $key => $value ) { $explode = explode("_", $key); $methodName = ''; foreach ( $explode as $v ) { $methodName .= ucfirst($v); } $key = $methodName != '' ? $methodName : $key; $method = 'set' . ucfirst($key); if( in_array($method, $methods) ){ $this->$method($value); } } return $this; } public function _toArray() { $dbtable = new Model_DbTable_CallcenterBeneficio(); $info = $dbtable->info(); $methods = get_class_methods($this); $data = array(); foreach ( $info['cols'] as $key ) { $col = $key; $explode = explode("_", $key); $methodName = ''; foreach ( $explode as $v ) { $methodName .= ucfirst($v); } $key = $methodName != '' ? $methodName : $key; $method = 'get' . ucfirst($key); if( in_array($method, $methods) ){ $data[$col] = $this->$method(); } } return $data; } /** * Insere ou altera o registro passado por parâmetro * @param Model_CallcenterBeneficio $beneficio */ public function salvar(Model_CallcenterBeneficio $beneficio) { if( !$beneficio->getBeneficio() ){ throw new Core_Exception('O benefício não foi informado!'); } $dbtable = new Model_DbTable_CallcenterBeneficio(); if( $beneficio->getId() > 0 ){ $dbtable->update($beneficio->_toArray(), "id = " . $beneficio->getId()); return $beneficio->getId(); } else { $beneficioSalvar = $beneficio->_toArray(); return $dbtable->insert($beneficioSalvar); } } /** * Exclui o registro passado por parâmetro * @param int $id * @return int The number of rows deleted */ public function excluir($id) { if( $id > 0 ){ $dbtable = new Model_DbTable_CallcenterBeneficio(); return $dbtable->delete("id = " . $id); } return null; } /** * Coleta os beneficios do cliente e se houver especie, coleta * o tipo do beneficio * @param string @cpf * @return Zend_Db_Table_Rowset */ public function getBeneficios($cpf) { $dbtable = new Model_DbTable_CallcenterBeneficio(); $select = $dbtable->getAdapter()->select()->from(array( 'cb' => 'tb_callcenter_beneficios' ), array( '*' )) ->joinLeft(array( 'tt' => 'tb_tipos' ), 'cb.especie = tt.codigo AND tt.tipo="ESPECIE_CONSIGNAVEL"', array( 'descricao' )) ->where("cpf_cliente = '{$cpf}'") ->order("cpf_cliente"); return $dbtable->getAdapter()->fetchAll($select); } /** * @param int $numero * @return array */ public function getBeneficioByNumero(int $idCliente, int $numero): array { return $this->table->findByNumeroForProposta($idCliente, $numero); } /** * Coleta os beneficios do cliente pelo ID * @param int @id * @return Zend_Db_Table_Rowset */ public function getBeneficiosById($baseId) { $dbtable = new Model_DbTable_CallcenterBeneficio(); $select = $dbtable->getAdapter()->select()->from(array( 'cb' => 'tb_callcenter_beneficios' ), [ 'id', 'beneficio', 'margem_livre', 'margem_cartao', 'margem_cartao_rmc', 'saque_complementar', 'margem_rcc', 'margem_bens_duraveis', 'mr', 'situacao', 'banco_pagto', 'agencia_pagto', 'conta_pagto', 'orgao_pagador', 'tipo_pagto', 'data_consulta', 'origem', 'especie', 'cessado', 'dib', 'bloq_emp', 'senha_contra_cheque', 'limite_cartao', 'permite_saque_complementar', 'obs', 'parcela_suspensa', 'base_cliente_id', 'competencia', ]) ->joinLeft(array( 'tt' => 'tb_tipos' ), 'cb.especie = tt.codigo AND tt.tipo="ESPECIE_CONSIGNAVEL"', array( 'descricao' )) ->where("cb.base_cliente_id = ?", $baseId); return $dbtable->getAdapter()->fetchAll($select); } public function consultarBeneficiosIn100Master($beneficios) { $service = new Core_Banco_Service_Master_Api(); $count = 0; foreach ($beneficios as $beneficio) { try { $consulta = $service->consultaIn100($beneficio); } catch (Core_Exception $exception) { Yuppie_Log::write($exception->getMessage()); continue; } $count += $this->gravarConsultaIn100Master($consulta, $beneficio['id']); } return $count; } public function gravarConsultaIn100Master($consulta, $idBeneficio) { if (empty($consulta)) { return 0; } $dados = [ 'beneficio' => $consulta->numeroMatricula, 'cpf_cliente' => $consulta->cpf, 'especie' => $consulta->especieBeneficio, 'banco_pagto' => $consulta->cbcIfPagadora, 'agencia_pagto' => $consulta->agenciaPagadora, 'conta_pagto' => $consulta->contaCorrente, 'dib' => $consulta->dataDespachoBeneficio, 'margem_livre' => $consulta->margemDisponivel, 'margem_cartao' => $consulta->margemDisponivelCartao, 'margem_rcc' => $consulta->margemDisponivelRcc, 'limite_cartao' => $consulta->valorLimiteCartao ]; $beneficios = new Model_DbTable_CallcenterBeneficio(); return $beneficios->save($dados); } }
💾 保存文件
← 返回文件管理器