✏️ 正在编辑: CorretorPendenciaFisico.php
路径:
/srv/systems_dir/yuppiecred/application/models/DbTable/CorretorPendenciaFisico.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_DbTable_CorretorPendenciaFisico extends Core_DbTable { protected function _getSelect($atrasoMaximo = null) { $colums = [ 'tipo_formalizacao', 'prazo' => new Zend_Db_Expr("IF((cp.prazo > 0), cp.prazo, cor.prazo_fisico)"), 'data_base' => new Zend_Db_Expr("IF((con.previa_recebimento > 0), con.data_recebimento_previa, con.data_liberacao)"), 'dias_atraso' => new Zend_Db_Expr("MAX((to_days(now()) - to_days(if((con.motivo_pendencia = 3), con.data_emissao, IF((con.previa_recebimento > 0), con.data_recebimento_previa, con.data_liberacao)))))"), 'motivo_pendencia' => new Zend_Db_Expr("group_concat(DISTINCT con.motivo_pendencia separator ' ')"), 'contratos' => new Zend_Db_Expr("group_concat(con.id separator ',')") ]; $select = $this->getAdapter() ->select()->from(['con' => 'tb_contratos'], $colums) ->joinInner(['cor' => 'tb_corretores'], "con.corretor_id = cor.id", ['id', 'nome']) ->joinLeft(['cp' => 'tb_corretores_prazos'], "cp.corretor_id = cor.id AND con.banco_id = cp.banco_id AND cp.excluido <> 1", []) ->where("cor.excluido <> 1") ->where("cor.corretor_desativado <> 1") ->where("con.pendente = 1") ->where("con.excluido <> 1") ->where("con.tipo_registro = 1") ->where("(con.tipo_formalizacao = 0 AND con.motivo_pendencia IN(1,3)) OR con.motivo_pendencia = 2") ->group(['cor.id', 'cp.id']); if( $atrasoMaximo != null && $atrasoMaximo > 0 ){ $select->having("dias_atraso > {$atrasoMaximo} OR locate('2', motivo_pendencia) > 0"); }else{ $select->having("dias_atraso > prazo OR locate('2', motivo_pendencia) > 0"); } return $select; } public function selectPendenciasAcessoCorretor() { $select = $this->_getSelect(); if( Yuppie_Auth::getIdentity()->grupo == "Corretor" || !empty(Yuppie_Auth::getIdentity()->corretor_id) ){ $corretorId = Yuppie_Auth::getIdentity()->grupo == "Corretor" ? Yuppie_Auth::getIdentity()->id : Yuppie_Auth::getIdentity()->corretor_id; $select->where("cor.id = {$corretorId}"); } return $this->getAdapter()->fetchRow($select); } public function selectCorretoresLista($corretores = null, $atrasoMaximo = null) { $select = $this->_getSelect($atrasoMaximo); if( $corretores ){ $select->where("cor.id IN ($corretores)"); } return $this->getAdapter()->fetchAll($select); } }
💾 保存文件
← 返回文件管理器