✏️ 正在编辑: TabelaFator.php
路径:
/srv/systems_dir/yuppiecred-lidernegocios/application/models/DbTable/TabelaFator.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_DbTable_TabelaFator extends Yuppie_DbTable { protected $_primary = 'id'; protected $_name = 'tb_tabelas_fatores'; protected $_referenceMap = array( 'Banco' => array( 'columns' => array('banco_id'), 'refTableClass' => 'Model_DbTable_Banco', 'refColumns' => array('id') ), 'Tabela' => array( 'columns' => array('tabela_id'), 'refTableClass' => 'Model_DbTable_Tabela', 'refColumns' => array('id') ), 'Convenio' => array( 'columns' => array('convenio_id'), 'refTableClass' => 'Model_DbTable_Convenio', 'refColumns' => array('id') ), ); public function getFatores($where) { $select = $this->select()->setIntegrityCheck(false); $select->from(array( 'fatores' => 'tb_tabelas_fatores' ), array('fatores.*')) ->joinLeft(array( 'bancos' => 'tb_bancos' ), "bancos.id = fatores.banco_id", array('banco' => 'bancos.nome')) ->joinLeft(array( 'tabelas' => 'tb_tabelas' ), "tabelas.id = fatores.tabela_id", array('tabela' => 'tabelas.nome')) ->where("fatores.excluido<>1") ->order(['tabela', 'prazo']); $this->_setWhere($select, $where); return $this->getAdapter()->fetchAll($select); } /** * @param int $convenioId * @param string $tipo * @param int $limit * @param string[] $order * @return array * @throws Zend_Date_Exception */ public function getFatoresSimulacaoAberta(int $convenioId, string $tipo, int $limit = 3, $order = ['prazo_maximo DESC', 'fator DESC']) { $data = Zend_Date::now(); //se hoje for final de semana, coloca para o fator do próximo dia if ($data->get(Zend_Date::WEEKDAY_DIGIT) == 0) { $data->addDay(1); } elseif ($data->get(Zend_Date::WEEKDAY_DIGIT) == 6) { $data->addDay(2); } $select = $this->select()->setIntegrityCheck(false); $select->from(['fatores' => 'tb_tabelas_fatores'], [ 'fatores.banco_id', 'fatores.fator', "max(fatores.prazo) as prazo_maximo" ]) ->joinInner(['bancos' => 'tb_bancos'], "bancos.id = fatores.banco_id", ['banco' => 'bancos.nome']) ->where("dia = ? OR dia = '' OR dia IS NULL", $data->get(Zend_Date::DAY)) ->where("fatores.convenio_id = ?", $convenioId) ->where("fatores.tipo = ?", $tipo) ->where("fatores.excluido <> 1") ->order($order) ->group(['fatores.banco_id', 'fatores.convenio_id', 'fatores.tipo', 'fatores.dia', 'fatores.fator']) ->limit($limit); //select de ordenação para o 1º valor ser o de menor prazo para o cliente $selectFinal = $this->select()->setIntegrityCheck(false); $selectFinal->from(['fatores_simulacao' => $select]) ->order(["prazo_maximo", "fatores.fator"]); return $this->getAdapter()->fetchAll($select); } public function fetchAll($where = null, $order = null, $count = null, $offset = null) { if (($where instanceof Zend_Db_Table_Select )) { $strWhere = implode(" ", $where->getPart(Zend_Db_Table_Select::WHERE)); if (empty($strWhere)) { $strWhere = "excluido<>1"; } else { $strWhere .= " AND excluido<>1"; } $where->where($strWhere); } elseif (is_array($where)) { $where[] = "excluido<>1"; } elseif ($where != null) { $where = $where . " AND excluido<>1 "; } else { $where = "excluido<>1 "; } return parent::fetchAll($where, $order, $count, $offset); } }
💾 保存文件
← 返回文件管理器