✏️ 正在编辑: CallcenterTelefone.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/models/DbTable/CallcenterTelefone.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_DbTable_CallcenterTelefone extends Core_DbTable { protected $_name = 'tb_callcenter_telefones'; public function insert(array $data) { if (!isset($data['fone']) || empty($data['fone'])) { throw new Core_Exception('Número de telefone inválido'); } $data['fone'] = String_Refatorar::formatarTelefone($data['fone']); if( count($this->fetchAll("fone = '" . $data['fone'] . "' AND cliente_id = '" . $data['cliente_id'] . "'")) > 0 ) { throw new Core_Exception('Telefone já cadastrado'); } $this->closeConnection(); return parent::insert($data); } public function selectTelefonesParaResetar($params) { $select = $this->select() ->from(['t' => $this->_name], 'id') ->join(['b' => 'tb_callcenter_base'], 'b.id = t.cliente_id', '') ->where('b.campanha_id IN (?)', $params['campanha_id']) ->where('b.status_atendimento IN (?) OR b.status_atendimento is null', $params['status_atendimento']) ->where('t.discador_status IN (?)', $params['status_discador']); if(!empty($params['ids'])){ $select->where("b.id IN ({$params['ids']})"); } $atendimentos = $this->getAdapter()->fetchCol($select, 'id'); if (count($atendimentos) > 0) { return implode($atendimentos, ','); } return null; } public function selectDiscadorChamadaIdFalando($baseId, $chamadaId) { $select = $this->getAdapter() ->select() ->from(['telefone' => $this->_name], [ 'contato_id' => 'telefone.discador_chamada_id', 'campanha_codigo' => 'campanha.codigo', 'campanha_id' => 'campanha.id' ]) ->join(['base' => 'tb_callcenter_base'], 'base.id = telefone.cliente_id', '') ->join(['campanha' => 'tb_callcenter_campanhas'], 'campanha.id = base.campanha_id', '') ->where('base.id = ?', $baseId) ->where('telefone.discador_chamada_id = ?', $chamadaId); return $this->getAdapter()->fetchRow($select); } public function setNaoAtende($campanhaId) { if( empty($campanhaId) ){ return; } $this->closeConnection(); $query = "update tb_callcenter_telefones t " . "inner join tb_callcenter_base b on(b.id = t.cliente_id) " . "set t.discador_descartar = 1 " . "where b.campanha_id = {$campanhaId}"; try{ $stmt = $this->getAdapter()->prepare($query); $stmt->getAdapter()->beginTransaction(); $stmt->execute(); $stmt->getAdapter()->commit(); } catch (Zend_Db_Statement_Exception $exc) { $stmt->getAdapter()->rollBack(); return false; } catch (Exception $ex) { return false; } $this->closeConnection(); return true; } }
💾 保存文件
← 返回文件管理器