Rev 631 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 623 | blopes | 1 | package br.com.ec.controller; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.ArrayList; |
||
| 5 | import java.util.Date; |
||
| 6 | import java.util.List; |
||
| 7 | |||
| 8 | import javax.inject.Inject; |
||
| 9 | import javax.inject.Named; |
||
| 10 | |||
| 11 | import org.springframework.context.annotation.Scope; |
||
| 12 | |||
| 13 | import br.com.ec.core.generic.GenericService; |
||
| 14 | import br.com.ec.core.util.DataUtils; |
||
| 15 | import br.com.ec.domain.dto.ClienteDTO; |
||
| 16 | import br.com.ec.domain.dto.ComercialPosVendaDTO; |
||
| 17 | import br.com.ec.domain.dto.PosVendaDTO; |
||
| 18 | import br.com.ec.domain.dto.VendaDTO; |
||
| 625 | blopes | 19 | import br.com.ec.domain.model.PosVenda; |
| 629 | blopes | 20 | import br.com.ec.domain.model.tipos.TipoNpsPosVenda; |
| 623 | blopes | 21 | import br.com.ec.domain.model.tipos.TipoPeriodoConsulta; |
| 631 | blopes | 22 | import br.com.ec.domain.model.tipos.TipoPosVendaAtivacao; |
| 624 | blopes | 23 | import br.com.ec.domain.service.LancamentoService; |
| 629 | blopes | 24 | import br.com.ec.domain.service.NpsPosVendaService; |
| 623 | blopes | 25 | import br.com.ec.domain.service.PosVendaService; |
| 26 | import br.com.ec.domain.service.TransferenciaService; |
||
| 27 | import br.com.ec.web.exception.VerificadorLancamentoException; |
||
| 28 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 29 | import br.com.ec.web.generic.AbstractBean; |
||
| 625 | blopes | 30 | import br.com.ec.web.message.LancadorMensagem; |
| 623 | blopes | 31 | |
| 32 | @Named |
||
| 33 | @Scope("view") |
||
| 34 | public class PosVendaBean extends AbstractBean<ComercialPosVendaDTO> implements Serializable { |
||
| 35 | |||
| 36 | private static final long serialVersionUID = 1L; |
||
| 37 | |||
| 38 | private PosVendaService posVendaService; |
||
| 629 | blopes | 39 | private NpsPosVendaService npsPosVendaService; |
| 624 | blopes | 40 | private LancamentoService lancamentoService; |
| 623 | blopes | 41 | |
| 42 | private PosVendaDTO posVendaSelecionado; |
||
| 631 | blopes | 43 | private String tipoPosVendaSelecionado; |
| 623 | blopes | 44 | |
| 625 | blopes | 45 | public static class NpsItem { |
| 46 | private final int nota; |
||
| 47 | private final String icone; |
||
| 48 | private final String estrelas; |
||
| 49 | |||
| 50 | public NpsItem(int nota, String icone, String estrelas) { |
||
| 51 | this.nota = nota; |
||
| 52 | this.icone = icone; |
||
| 53 | this.estrelas = estrelas; |
||
| 54 | } |
||
| 55 | |||
| 56 | public int getNota() { return nota; } |
||
| 57 | public String getIcone() { return icone; } |
||
| 58 | public String getEstrelas() { return estrelas; } |
||
| 59 | } |
||
| 60 | |||
| 623 | blopes | 61 | @Inject |
| 629 | blopes | 62 | public PosVendaBean(PosVendaService posVendaService, NpsPosVendaService npsPosVendaService, LancamentoService lancamentoService) { |
| 623 | blopes | 63 | this.posVendaService = posVendaService; |
| 624 | blopes | 64 | this.lancamentoService = lancamentoService; |
| 629 | blopes | 65 | this.npsPosVendaService = npsPosVendaService; |
| 623 | blopes | 66 | } |
| 67 | |||
| 68 | @Override |
||
| 69 | public GenericService<ComercialPosVendaDTO> getService() { |
||
| 70 | return null; |
||
| 71 | } |
||
| 72 | |||
| 73 | @Override |
||
| 74 | public ComercialPosVendaDTO getId() { |
||
| 75 | return null; |
||
| 76 | } |
||
| 77 | |||
| 78 | @Override |
||
| 79 | public void preCarregamento() { |
||
| 80 | limparEntidade(); |
||
| 81 | } |
||
| 82 | |||
| 83 | @Override |
||
| 84 | public void limparEntidade() { |
||
| 630 | blopes | 85 | consultarPosVenda(); |
| 623 | blopes | 86 | } |
| 87 | |||
| 88 | public PosVendaDTO getPosVendaSelecionado() { |
||
| 89 | return posVendaSelecionado; |
||
| 90 | } |
||
| 91 | public void setPosVendaSelecionado(PosVendaDTO posVendaSelecionado) { |
||
| 92 | this.posVendaSelecionado = posVendaSelecionado; |
||
| 93 | } |
||
| 94 | |||
| 631 | blopes | 95 | public String getTipoPosVendaSelecionado() { |
| 96 | return tipoPosVendaSelecionado; |
||
| 97 | } |
||
| 98 | public void setTipoPosVendaSelecionado(String tipoPosVendaSelecionado) { |
||
| 99 | this.tipoPosVendaSelecionado = tipoPosVendaSelecionado; |
||
| 100 | } |
||
| 101 | |||
| 623 | blopes | 102 | /**************************************************/ |
| 103 | |||
| 104 | public TipoPeriodoConsulta[] getTiposPeriodoConsulta() { |
||
| 105 | return TipoPeriodoConsulta.values(); |
||
| 106 | } |
||
| 107 | |||
| 108 | /**************************************************/ |
||
| 109 | |||
| 110 | public void consultarPosVenda() { |
||
| 111 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 112 | public void execute() { |
||
| 630 | blopes | 113 | setEntidade(posVendaService.consultarPosVendaEmAndamento()); |
| 623 | blopes | 114 | } |
| 115 | }); |
||
| 116 | } |
||
| 117 | |||
| 631 | blopes | 118 | public void detalharPosVendaAgradecimento(PosVendaDTO posVenda) { |
| 623 | blopes | 119 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 120 | public void execute() { |
||
| 624 | blopes | 121 | posVenda.getVendaDTO().setListaLancamentos(lancamentoService.consultarLancamentosDaVenda(posVenda.getVendaDTO().getSequencial())); |
| 630 | blopes | 122 | posVenda.setNpsPosVendaAgradecimento(npsPosVendaService.consultarPorPosVendaEeTipo(posVenda.getSequencial(), TipoNpsPosVenda.ATENDIMENTO_A.getValor())); |
| 623 | blopes | 123 | setPosVendaSelecionado(posVenda); |
| 631 | blopes | 124 | setTipoPosVendaSelecionado(TipoPosVendaAtivacao.AGRADECIMENTO_A1.getValor()); |
| 125 | preDetalhar(getEntidade()); |
||
| 623 | blopes | 126 | } |
| 127 | }); |
||
| 128 | } |
||
| 129 | |||
| 630 | blopes | 130 | public void iniciarAtendimento() { |
| 625 | blopes | 131 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 132 | public void execute() { |
||
| 630 | blopes | 133 | posVendaService.iniciarAtendimento(getPosVendaSelecionado()); |
| 134 | consultarPosVenda(); |
||
| 631 | blopes | 135 | preConsultar(); |
| 136 | LancadorMensagem.lancarSucesso("PÓS-VENDA SALVO COM SUCESSO"); |
||
| 625 | blopes | 137 | } |
| 138 | }); |
||
| 139 | } |
||
| 140 | |||
| 636 | blopes | 141 | public void finalizarAtendimento() { |
| 142 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 143 | public void execute() { |
||
| 144 | posVendaService.finalizarAtendimento(getPosVendaSelecionado()); |
||
| 145 | consultarPosVenda(); |
||
| 146 | preConsultar(); |
||
| 147 | LancadorMensagem.lancarSucesso("PÓS-VENDA FINALIZADO COM SUCESSO"); |
||
| 148 | } |
||
| 149 | }); |
||
| 150 | } |
||
| 151 | |||
| 623 | blopes | 152 | } |