From ad74231d0cbcdb7c9161b957206f7b2a3dbbcc6b Mon Sep 17 00:00:00 2001 From: fabio Date: Mon, 7 Dec 2020 13:00:47 +0000 Subject: [PATCH] bug#21146 dev: Valvevir qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@104610 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../dao/CategoriaDescuentoDAO.java | 2 ++ .../CategoriaDescuentoHibernateDAO.java | 33 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/dao/CategoriaDescuentoDAO.java b/src/com/rjconsultores/ventaboletos/dao/CategoriaDescuentoDAO.java index a07851450..f4cec46ab 100644 --- a/src/com/rjconsultores/ventaboletos/dao/CategoriaDescuentoDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/CategoriaDescuentoDAO.java @@ -13,4 +13,6 @@ import com.rjconsultores.ventaboletos.entidad.CategoriaDescuento; public interface CategoriaDescuentoDAO extends GenericDAO { public CategoriaDescuento pesquisarPorCategoriaEmpresa(Integer categoriaId, Integer empresaId); + + public boolean isAplicaTarifaMinima(Integer categoriaId, Integer empresaId); } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/CategoriaDescuentoHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/CategoriaDescuentoHibernateDAO.java index 3e0383762..5da57d9b8 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/CategoriaDescuentoHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/CategoriaDescuentoHibernateDAO.java @@ -4,16 +4,20 @@ */ package com.rjconsultores.ventaboletos.dao.hibernate; -import com.rjconsultores.ventaboletos.dao.CategoriaDescuentoDAO; -import com.rjconsultores.ventaboletos.entidad.CategoriaDescuento; import java.util.List; + import org.hibernate.Criteria; +import org.hibernate.Query; import org.hibernate.SessionFactory; import org.hibernate.criterion.Restrictions; +import org.hibernate.type.BooleanType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; +import com.rjconsultores.ventaboletos.dao.CategoriaDescuentoDAO; +import com.rjconsultores.ventaboletos.entidad.CategoriaDescuento; + /** * * @author Administrador @@ -48,4 +52,29 @@ public class CategoriaDescuentoHibernateDAO return (CategoriaDescuento) c.uniqueResult(); } + + @Override + public boolean isAplicaTarifaMinima(Integer categoriaId, Integer empresaId) { + + StringBuilder sql = new StringBuilder(); + + sql.append(" SELECT cd.indnaoaplicatarifaminima as tarifa "); + sql.append(" from categoria_descuento cd "); + sql.append(" inner join categoria_ctrl cc "); + sql.append(" on cc.categoriactrl_id = cd.categoriactrl_id "); + sql.append(" and cc.empresa_id = :empresaId "); + sql.append(" and cc.activo = 1 "); + sql.append(" where cd.categoria_id = :categoriaId "); + sql.append(" and cd.activo = 1 "); + + Query query = getSession().createSQLQuery(sql.toString()) + .addScalar("tarifa", BooleanType.INSTANCE); + + query.setParameter("empresaId", empresaId ); + query.setParameter("categoriaId", categoriaId ); + + Boolean retorno = (Boolean)query.uniqueResult(); + + return Boolean.FALSE.equals(retorno); + } }