✏️ 正在编辑: BancosSpreadFaixaComissao.php
路径:
/srv/systems_dir/yuppiecred/application/models/BancosSpreadFaixaComissao.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_BancosSpreadFaixaComissao { private $_id; private $_bancoId; private $_valorInicial; private $_valorFinal; private $_spread; public function getId() { return $this->_id; } public function setId($id) { $this->_id = $id; } public function getBancoId() { return $this->_bancoId; } public function setBancoId($value) { $this->_bancoId = $value; } function getSpread() { return $this->_spread; } function setSpread($value) { $this->_spread = str_replace(['.', ','], ['', '.'], $value); } function getValorInicial() { return $this->_valorInicial; } function setValorInicial($valorInicial) { $this->_valorInicial = str_replace(['.', ','], ['', '.'], $valorInicial); } function getValorFinal() { return $this->_valorFinal; } function setValorFinal($valorFinal) { $this->_valorFinal = str_replace(['.', ','], ['', '.'], $valorFinal); } public function setOptions(array $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_BancosSpreadFaixaComissao(); $info = $dbtable->info(); $methods = get_class_methods($this); $data = []; 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; } public function __construct($options = null) { if (is_array($options)) { $this->setOptions($options); } } public function salvar(Model_BancosSpreadFaixaComissao $faixa) { $dbtable = new Model_DbTable_BancosSpreadFaixaComissao(); if ($faixa->getId() > 0) { $dbtable->update($faixa->_toArray(), "id = " . $faixa->getId()); return $faixa->getId(); } else { return $dbtable->insert($faixa->_toArray()); } } public function listar($where = null, $order = null, $count = null, $offset = null) { $dbtable = new Model_DbTable_BancosSpreadFaixaComissao(); return $dbtable->fetchAll($where, $order, $count, $offset); } public function excluir($id) { if ($id > 0) { $dbtable = new Model_DbTable_BancosSpreadFaixaComissao(); return $dbtable->delete("id = " . $id); } return null; } public static function validaIntercessao($data) { $dbtable = new Model_DbTable_BancosSpreadFaixaComissao(); $faixa = $dbtable->getByInterval($data['valor_inicial'], $data['valor_final'], $data['banco_id']); if (empty($faixa)) { return false; } return true; } public static function getSpreadByComissao($bancoId = 0, $comissao = 0) { $banco = (new Model_Banco())->exibir($bancoId); $dbtable = new Model_DbTable_BancosSpreadFaixaComissao(); $faixa = $dbtable->fetchRow([ 'banco_id = ?' => $bancoId, 'valor_inicial <= ?' => $comissao, 'valor_final >= ?' => $comissao ]); if (empty($faixa)) { return false; } if (empty($banco)) { return false; } return $banco->tipo_spread == 'PERCENTUAL' ? ($faixa->spread * $comissao / 100) : $faixa->spread; } }
💾 保存文件
← 返回文件管理器