✏️ 正在编辑: CallcenterEmprestimoCliente.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/models/DbTable/CallcenterEmprestimoCliente.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_DbTable_CallcenterEmprestimoCliente extends Core_DbTable { protected $_name = 'tb_callcenter_emprestimos_clientes'; public function insert(array $data) { $this->closeConnection(); if( !isset($data['base_cliente_id']) || !isset($data['banco']) || empty($data['base_cliente_id']) || empty($data['banco']) ){ return null; } return parent::insert($data); } /** * Retorna true se existir ou false se não existir * @param type $cpfCiente * @param type $banco * @param type $qtdParcelas * @param type $valorParcela * @return boolean */ public function existe($cpfCliente, $banco, $qtdParcelas, $valorParcela) { $cpf = String_Refatorar::formatarCpf($cpfCliente); $select = $this->select()->from(array('emprestimos' => $this->_name), '*') ->joinInner(array('base' => 'tb_callcenter_base'), 'emprestimos.base_cliente_id = base.id', array()) ->where("base.cpf = '$cpf'") ->where("banco = '$banco'") ->where("qtd_parcelas = '$qtdParcelas'") ->where("valor_parcela = '$valorParcela'"); return $this->fetchRow($select) != null; } public function limparConsultaEmprestimos($cpfCliente, $beneficios, $tipo = 'EMPRESTIMO') { $this->closeConnection(); $cpfs = is_array($cpfCliente) ? $cpfCliente : array($cpfCliente); $matriculas = is_array($beneficios) ? $beneficios : array($beneficios); $where = "cpf_cliente IN ('". implode("','", $cpfs)."')" . " AND beneficio IN ('". implode("','", $matriculas) ."')"; if( $tipo != null ){ $where .= " AND tipo LIKE '{$tipo}'"; } return $this->delete($where); } public function delete($where) { if( !$where ){ return; } $sql = "DELETE FROM " . $this->getAdapter()->quoteIdentifier($this->_name, true) . " WHERE $where"; $this->getAdapter()->beginTransaction(); try{ $stmt = $this->getAdapter()->query($sql); $this->getAdapter()->commit(); $result = $stmt->rowCount(); } catch (Exception $ex) { echo $ex->getMessage() . "<br>"; echo $ex->getTraceAsString(); $this->getAdapter()->rollBack(); } return $result; } public function getBancos() { $select = $this->select()->from($this, array('banco')) ->where('banco is not null') ->order('banco ASC') ->group('banco'); return $this->getAdapter()->fetchAll($select); } /** * @return Zend_Db_Select */ public function sqlQuantidadeEmprestimos() { return $this->getAdapter()->select()->from(['emprestimos' => 'tb_callcenter_emprestimos_clientes'], [ 'quantidade_emprestimos' => 'COUNT(DISTINCT id)', 'cpf' => 'cpf_cliente' ])->group('cpf_cliente'); } }
💾 保存文件
← 返回文件管理器