Subversion Repositories Integrator Subversion

Rev

Rev 697 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 697 Rev 701
Line 158... Line 158...
158
                }
158
                }
159
        }
159
        }
160
       
160
       
161
        @Override
161
        @Override
162
        public void validarRegrasCupom(ParametrosVendaDTO parametrosVenda, Cupom cupomSelecionado) {
162
        public void validarRegrasCupom(ParametrosVendaDTO parametrosVenda, Cupom cupomSelecionado) {
-
 
163
//              APENAS_CAPA_PELICULA_C0("C0", "REGRA: APENAS PARA CAPA OU PELÍCULA");
163
//              APENAS_PELICULA_TPUSOFT_P1("P1", "REGRA: APENAS PARA PELÍCULA TPU SOFT"),
164
//              APENAS_PELICULA_TPUSOFT_P1("P1", "REGRA: APENAS PARA PELÍCULA TPU SOFT"),
164
//              APENAS_PELICULA_TPUSOFTTPASEIRA_P2("P2", "REGRA: APENAS PARA PELÍCULA TPU SOFT TRASEIRA"),
165
//              APENAS_PELICULA_TPUSOFTTPASEIRA_P2("P2", "REGRA: APENAS PARA PELÍCULA TPU SOFT TRASEIRA"),
165
//              APENAS_PELICULA_CAMERACOMFRONTAL_P3("P3", "REGRA: APENAS PARA PELÍCULA DE CÂMERA NA COMPRA DA FRONTAL"),
166
//              APENAS_PELICULA_CAMERACOMFRONTAL_P3("P3", "REGRA: APENAS PARA PELÍCULA DE CÂMERA NA COMPRA DA FRONTAL"),
-
 
167
//              APENAS_PELICULA_VIDRO_COM_CAPA_P4("P4", "REGRA: APENAS PARA PELÍCULA DE VIDRO, NA COMPRA DE UMA CAPA"),
166
//              APENAS_CAPA_C1("C1", "REGRA: APENAS PARA CAPAS"),
168
//              APENAS_CAPA_C1("C1", "REGRA: APENAS PARA CAPAS"),
167
//              APENAS_2CAPAS_C2("C2", "REGRA: APENAS PARA VENDAS COM 2 CAPAS"),
169
//              APENAS_2CAPAS_C2("C2", "REGRA: APENAS PARA VENDAS COM 2 CAPAS"),
168
//              APENAS_3CAPAS_C3("C3", "REGRA: APENAS PARA VENDAS COM 3 CAPAS"),
170
//              APENAS_3CAPAS_C3("C3", "REGRA: APENAS PARA VENDAS COM 3 CAPAS"),
169
//              APENAS_CAPA_SILICONE_C4("C4", "REGRA: APENAS PARA CAPAS DE SILICONE");
171
//              APENAS_CAPA_SILICONE_C4("C4", "REGRA: APENAS PARA CAPAS DE SILICONE");
170
               
172
               
171
                Boolean verificarSeTemPeliculaFrontalParaP2P3 = false;
-
 
-
 
173
                Boolean verificarSeTemPeliculaTPUFrontalParaP2 = false;
-
 
174
                Boolean verificarSeTemPeliculaFrontalParaP3 = false;
172
                Integer quantidadeCapas = 0;
175
                Integer quantidadeCapas = 0;
173
                for (Lancamento lancamento : parametrosVenda.getLancamentos()) {
176
                for (Lancamento lancamento : parametrosVenda.getLancamentos()) {
174
                        if (lancamento.getProduto().getTipo().equals(TipoProduto.CAPA.getValor())) {
177
                        if (lancamento.getProduto().getTipo().equals(TipoProduto.CAPA.getValor())) {
175
                                quantidadeCapas++;
178
                                quantidadeCapas++;
176
                        }
179
                        }
177
                        if (lancamento.getProduto().getTipo().equals(TipoProduto.PELICULA.getValor()) &&
180
                        if (lancamento.getProduto().getTipo().equals(TipoProduto.PELICULA.getValor()) &&
178
                                        VerificadorUtil.naoEstaNuloOuVazio(lancamento.getProduto().getSubtipoProduto())) {
181
                                        VerificadorUtil.naoEstaNuloOuVazio(lancamento.getProduto().getSubtipoProduto())) {
179
                                if (!lancamento.getProduto().getSubtipoProduto().getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_TPU_SOFT_CAMERA_47) ||
-
 
180
                                        !lancamento.getProduto().getSubtipoProduto().getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_VIDRO_CAMERA_48)) {
-
 
181
                                        verificarSeTemPeliculaFrontalParaP2P3 = true;
-
 
-
 
182
                                if (lancamento.getProduto().getSubtipoProduto().getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_TPU_SOFT_NORMAL_42) ||
-
 
183
                                                lancamento.getProduto().getSubtipoProduto().getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_TPU_SOFT_PRIVACIDADE_43)) {
-
 
184
                                        verificarSeTemPeliculaTPUFrontalParaP2 = true;
-
 
185
                                }
-
 
186
                                if (lancamento.getProduto().getSubtipoProduto().getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_TPU_SOFT_NORMAL_42) ||
-
 
187
                                        lancamento.getProduto().getSubtipoProduto().getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_TPU_SOFT_PRIVACIDADE_43) ||
-
 
188
                                        lancamento.getProduto().getSubtipoProduto().getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_VIDRO_3D_NORMAL_44) ||
-
 
189
                                        lancamento.getProduto().getSubtipoProduto().getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_VIDRO_3D_PRIVACIDADE_45)) {
-
 
190
                                        verificarSeTemPeliculaFrontalParaP3 = true;
182
                                }
191
                                }
183
                        }
192
                        }
184
                }
193
                }
185
               
194
               
186
                for (Lancamento lancamento : parametrosVenda.getLancamentos()) {
195
                for (Lancamento lancamento : parametrosVenda.getLancamentos()) {
187
                        if (lancamento.equals(cupomSelecionado.getLancamento()) && VerificadorUtil.naoEstaNuloOuVazio(cupomSelecionado.getTipoRegraCupom())) {
196
                        if (lancamento.equals(cupomSelecionado.getLancamento()) && VerificadorUtil.naoEstaNuloOuVazio(cupomSelecionado.getTipoRegraCupom())) {
188
                                String tipoProdutoLancamento = lancamento.getProduto().getTipo();
197
                                String tipoProdutoLancamento = lancamento.getProduto().getTipo();
189
                                SubtipoProduto subtipoProdutoLancamento = lancamento.getProduto().getSubtipoProduto();
198
                                SubtipoProduto subtipoProdutoLancamento = lancamento.getProduto().getSubtipoProduto();
190
                               
199
                               
191
                                // REGRAS PARA PELÍCULAS
200
                                // REGRAS PARA PELÍCULAS
192
                                if (TipoRegraCupom.APENAS_PELICULA_TPUSOFT_P1.getValor().equals(cupomSelecionado.getTipoRegraCupom()) ||
-
 
193
                                                TipoRegraCupom.APENAS_PELICULA_TPUSOFTTPASEIRA_P2.getValor().equals(cupomSelecionado.getTipoRegraCupom()) ||
-
 
194
                                                TipoRegraCupom.APENAS_PELICULA_CAMERACOMFRONTAL_P3.getValor().equals(cupomSelecionado.getTipoRegraCupom())) {
-
 
-
 
201
                                if (ehPelicula(cupomSelecionado.getTipoRegraCupom())) {
195
                                        if (!tipoProdutoLancamento.equals(TipoProduto.PELICULA.getValor())) {
202
                                        if (!tipoProdutoLancamento.equals(TipoProduto.PELICULA.getValor())) {
196
                                                throw new RuntimeException(cupomSelecionado.getDescricaoDoTipoRegraCupom());
203
                                                throw new RuntimeException(cupomSelecionado.getDescricaoDoTipoRegraCupom());
197
                                        }
204
                                        }
198
                                        if (TipoRegraCupom.APENAS_PELICULA_TPUSOFT_P1.getValor().equals(cupomSelecionado.getTipoRegraCupom())) {
205
                                        if (TipoRegraCupom.APENAS_PELICULA_TPUSOFT_P1.getValor().equals(cupomSelecionado.getTipoRegraCupom())) {
199
                                                if (VerificadorUtil.naoEstaNulo(subtipoProdutoLancamento)) {
206
                                                if (VerificadorUtil.naoEstaNulo(subtipoProdutoLancamento)) {
Line 204... Line 211...
204
                                                }
211
                                                }
205
                                        }
212
                                        }
206
                               
213
                               
207
                                        if (TipoRegraCupom.APENAS_PELICULA_TPUSOFTTPASEIRA_P2.getValor().equals(cupomSelecionado.getTipoRegraCupom())) {
214
                                        if (TipoRegraCupom.APENAS_PELICULA_TPUSOFTTPASEIRA_P2.getValor().equals(cupomSelecionado.getTipoRegraCupom())) {
208
                                                if (VerificadorUtil.naoEstaNulo(subtipoProdutoLancamento)) {
215
                                                if (VerificadorUtil.naoEstaNulo(subtipoProdutoLancamento)) {
209
                                                        if (!subtipoProdutoLancamento.getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_TPU_SOFT_TRASEIRA_46)) {
-
 
-
 
216
                                                        if (!verificarSeTemPeliculaTPUFrontalParaP2 ||
-
 
217
                                                                !subtipoProdutoLancamento.getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_TPU_SOFT_TRASEIRA_46)) {
210
                                                                throw new RuntimeException(cupomSelecionado.getDescricaoDoTipoRegraCupom());
218
                                                                throw new RuntimeException(cupomSelecionado.getDescricaoDoTipoRegraCupom());
211
                                                        }
219
                                                        }
212
                                                }
220
                                                }
213
                                        }
221
                                        }
214
                                       
222
                                       
215
                                        if (TipoRegraCupom.APENAS_PELICULA_CAMERACOMFRONTAL_P3.getValor().equals(cupomSelecionado.getTipoRegraCupom())) {
223
                                        if (TipoRegraCupom.APENAS_PELICULA_CAMERACOMFRONTAL_P3.getValor().equals(cupomSelecionado.getTipoRegraCupom())) {
216
                                                if (VerificadorUtil.naoEstaNulo(subtipoProdutoLancamento)) {
224
                                                if (VerificadorUtil.naoEstaNulo(subtipoProdutoLancamento)) {
217
                                                        if (verificarSeTemPeliculaFrontalParaP2P3 &&
-
 
218
                                                                (!subtipoProdutoLancamento.getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_TPU_SOFT_CAMERA_47) ||
-
 
219
                                                                !subtipoProdutoLancamento.getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_VIDRO_CAMERA_48))) {
-
 
-
 
225
                                                        if (!verificarSeTemPeliculaFrontalParaP3 ||
-
 
226
                                                                !(subtipoProdutoLancamento.getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_TPU_SOFT_CAMERA_47) ||
-
 
227
                                                                subtipoProdutoLancamento.getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_VIDRO_CAMERA_48))) {
220
                                                                throw new RuntimeException(cupomSelecionado.getDescricaoDoTipoRegraCupom());
228
                                                                throw new RuntimeException(cupomSelecionado.getDescricaoDoTipoRegraCupom());
221
                                                        }
229
                                                        }
-
 
230
                                                }
-
 
231
                                        }
-
 
232
                                       
-
 
233
                                        if (TipoRegraCupom.APENAS_PELICULA_VIDRO_COM_CAPA_P4.getValor().equals(cupomSelecionado.getTipoRegraCupom())) {
-
 
234
                                                if (!(quantidadeCapas > 0 &&
-
 
235
                                                        subtipoProdutoLancamento.getSequencial().equals(ConstantesSEC.SubtipoProduto.SEQUENCIAL_SUBTIPO_VIDRO_3D_NORMAL_44))) {
-
 
236
                                                        throw new RuntimeException(cupomSelecionado.getDescricaoDoTipoRegraCupom());
222
                                                }
237
                                                }
223
                                        }
238
                                        }
224
                                }
239
                                }
225
240
226
                                // REGRAS PARA CAPAS
241
                                // REGRAS PARA CAPAS
227
                                if (TipoRegraCupom.APENAS_CAPA_C1.getValor().equals(cupomSelecionado.getTipoRegraCupom()) ||
-
 
228
                                                TipoRegraCupom.APENAS_2CAPAS_C2.getValor().equals(cupomSelecionado.getTipoRegraCupom()) ||
-
 
229
                                                TipoRegraCupom.APENAS_3CAPAS_C3.getValor().equals(cupomSelecionado.getTipoRegraCupom()) ||
-
 
230
                                                TipoRegraCupom.APENAS_CAPA_SILICONE_C4.getValor().equals(cupomSelecionado.getTipoRegraCupom())) {
-
 
-
 
242
                                if (ehCapa(cupomSelecionado.getTipoRegraCupom())) {
231
                                        if (!tipoProdutoLancamento.equals(TipoProduto.CAPA.getValor())) {
243
                                        if (!tipoProdutoLancamento.equals(TipoProduto.CAPA.getValor())) {
232
                                                throw new RuntimeException(cupomSelecionado.getDescricaoDoTipoRegraCupom());
244
                                                throw new RuntimeException(cupomSelecionado.getDescricaoDoTipoRegraCupom());
233
                                        }
245
                                        }
234
                                        if (TipoRegraCupom.APENAS_2CAPAS_C2.getValor().equals(cupomSelecionado.getTipoRegraCupom()) && quantidadeCapas<2) {
246
                                        if (TipoRegraCupom.APENAS_2CAPAS_C2.getValor().equals(cupomSelecionado.getTipoRegraCupom()) && quantidadeCapas<2) {
235
                                                throw new RuntimeException(cupomSelecionado.getDescricaoDoTipoRegraCupom());
247
                                                throw new RuntimeException(cupomSelecionado.getDescricaoDoTipoRegraCupom());
Line 248... Line 260...
248
                               
260
                               
249
                                break;
261
                                break;
250
                        }
262
                        }
251
                }
263
                }
252
               
264
               
-
 
265
        }
-
 
266
       
-
 
267
        private Boolean ehPelicula(String tipoRegraCupom) {
-
 
268
                return TipoRegraCupom.APENAS_PELICULA_TPUSOFT_P1.getValor().equals(tipoRegraCupom) ||
-
 
269
                                TipoRegraCupom.APENAS_PELICULA_TPUSOFTTPASEIRA_P2.getValor().equals(tipoRegraCupom) ||
-
 
270
                                TipoRegraCupom.APENAS_PELICULA_CAMERACOMFRONTAL_P3.getValor().equals(tipoRegraCupom) ||
-
 
271
                                TipoRegraCupom.APENAS_PELICULA_VIDRO_COM_CAPA_P4.getValor().equals(tipoRegraCupom);
-
 
272
        }
-
 
273
       
-
 
274
        private Boolean ehCapa(String tipoRegraCupom) {
-
 
275
                return TipoRegraCupom.APENAS_CAPA_C1.getValor().equals(tipoRegraCupom) ||
-
 
276
                                TipoRegraCupom.APENAS_2CAPAS_C2.getValor().equals(tipoRegraCupom) ||
-
 
277
                                TipoRegraCupom.APENAS_3CAPAS_C3.getValor().equals(tipoRegraCupom) ||
-
 
278
                                TipoRegraCupom.APENAS_CAPA_SILICONE_C4.getValor().equals(tipoRegraCupom);
253
        }
279
        }
254
280
255
}
281
}