Rev 627 | Rev 630 | Go to most recent revision | 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; |
| 624 | blopes | 22 | import br.com.ec.domain.service.LancamentoService; |
| 629 | blopes | 23 | import br.com.ec.domain.service.NpsPosVendaService; |
| 623 | blopes | 24 | import br.com.ec.domain.service.PosVendaService; |
| 25 | import br.com.ec.domain.service.TransferenciaService; |
||
| 26 | import br.com.ec.web.exception.VerificadorLancamentoException; |
||
| 27 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 28 | import br.com.ec.web.generic.AbstractBean; |
||
| 625 | blopes | 29 | import br.com.ec.web.message.LancadorMensagem; |
| 623 | blopes | 30 | |
| 31 | @Named |
||
| 32 | @Scope("view") |
||
| 33 | public class PosVendaBean extends AbstractBean<ComercialPosVendaDTO> implements Serializable { |
||
| 34 | |||
| 35 | private static final long serialVersionUID = 1L; |
||
| 36 | |||
| 37 | private PosVendaService posVendaService; |
||
| 629 | blopes | 38 | private NpsPosVendaService npsPosVendaService; |
| 624 | blopes | 39 | private LancamentoService lancamentoService; |
| 623 | blopes | 40 | |
| 41 | private PosVendaDTO posVendaSelecionado; |
||
| 42 | |||
| 625 | blopes | 43 | public static class NpsItem { |
| 44 | private final int nota; |
||
| 45 | private final String icone; |
||
| 46 | private final String estrelas; |
||
| 47 | |||
| 48 | public NpsItem(int nota, String icone, String estrelas) { |
||
| 49 | this.nota = nota; |
||
| 50 | this.icone = icone; |
||
| 51 | this.estrelas = estrelas; |
||
| 52 | } |
||
| 53 | |||
| 54 | public int getNota() { return nota; } |
||
| 55 | public String getIcone() { return icone; } |
||
| 56 | public String getEstrelas() { return estrelas; } |
||
| 57 | } |
||
| 58 | |||
| 623 | blopes | 59 | @Inject |
| 629 | blopes | 60 | public PosVendaBean(PosVendaService posVendaService, NpsPosVendaService npsPosVendaService, LancamentoService lancamentoService) { |
| 623 | blopes | 61 | this.posVendaService = posVendaService; |
| 624 | blopes | 62 | this.lancamentoService = lancamentoService; |
| 629 | blopes | 63 | this.npsPosVendaService = npsPosVendaService; |
| 623 | blopes | 64 | } |
| 65 | |||
| 66 | @Override |
||
| 67 | public GenericService<ComercialPosVendaDTO> getService() { |
||
| 68 | return null; |
||
| 69 | } |
||
| 70 | |||
| 71 | @Override |
||
| 72 | public ComercialPosVendaDTO getId() { |
||
| 73 | return null; |
||
| 74 | } |
||
| 75 | |||
| 76 | @Override |
||
| 77 | public void preCarregamento() { |
||
| 78 | limparEntidade(); |
||
| 79 | } |
||
| 80 | |||
| 81 | @Override |
||
| 82 | public void limparEntidade() { |
||
| 83 | setEntidade(iniciarDados()); |
||
| 84 | } |
||
| 85 | |||
| 86 | public PosVendaDTO getPosVendaSelecionado() { |
||
| 87 | return posVendaSelecionado; |
||
| 88 | } |
||
| 89 | public void setPosVendaSelecionado(PosVendaDTO posVendaSelecionado) { |
||
| 90 | this.posVendaSelecionado = posVendaSelecionado; |
||
| 91 | } |
||
| 92 | |||
| 93 | /**************************************************/ |
||
| 94 | |||
| 95 | public TipoPeriodoConsulta[] getTiposPeriodoConsulta() { |
||
| 96 | return TipoPeriodoConsulta.values(); |
||
| 97 | } |
||
| 98 | |||
| 99 | /**************************************************/ |
||
| 100 | |||
| 101 | public void consultarPosVenda() { |
||
| 102 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 103 | public void execute() { |
||
| 104 | // iniciarDados(); |
||
| 105 | ComercialPosVendaDTO comercialDTO = new ComercialPosVendaDTO(); |
||
| 106 | List<PosVendaDTO> listaPosVendaDTO = new ArrayList<PosVendaDTO>(); |
||
| 107 | listaPosVendaDTO.addAll(posVendaService.consultarNaoFinalizadas()); |
||
| 108 | comercialDTO.setListaPosVenda(listaPosVendaDTO); |
||
| 109 | setEntidade(comercialDTO); |
||
| 110 | } |
||
| 111 | }); |
||
| 112 | } |
||
| 113 | |||
| 114 | public void selecionarPosVenda(PosVendaDTO posVenda/* , TipoPosVendaAtivacao tipoAtivacao */) { |
||
| 115 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 116 | public void execute() { |
||
| 117 | // CONSULTAR DETALHES BASEANDO-SE NO TIPO DE ATIVACAO |
||
| 624 | blopes | 118 | posVenda.getVendaDTO().setListaLancamentos(lancamentoService.consultarLancamentosDaVenda(posVenda.getVendaDTO().getSequencial())); |
| 627 | blopes | 119 | // CONSULTAR NPS PÓS-VENDA |
| 629 | blopes | 120 | posVenda.setNpsPosVendaAtendimento(npsPosVendaService.consultarPorPosVendaEeTipo(posVenda.getSequencial(), TipoNpsPosVenda.ATENDIMENTO_A.getValor())); |
| 623 | blopes | 121 | setPosVendaSelecionado(posVenda); |
| 122 | } |
||
| 123 | }); |
||
| 124 | } |
||
| 125 | |||
| 625 | blopes | 126 | public void iniciarSalvarPosVenda() { |
| 127 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 128 | public void execute() { |
||
| 129 | PosVenda posVendaParaAlterar = posVendaService.consultarPorId(new PosVenda(getPosVendaSelecionado().getSequencial())); |
||
| 130 | posVendaParaAlterar.setDataInicio(DataUtils.getDataAtual()); |
||
| 131 | posVendaParaAlterar.setObservacao(getPosVendaSelecionado().getObservacao()); |
||
| 132 | posVendaParaAlterar.setTipoFinalizacao(getPosVendaSelecionado().getTipoFinalizacao()); |
||
| 133 | posVendaService.alterar(posVendaParaAlterar); |
||
| 134 | LancadorMensagem.lancarSucesso("PÓS-VENDA INICIADO COM SUCESSO"); |
||
| 135 | } |
||
| 136 | }); |
||
| 137 | } |
||
| 138 | |||
| 623 | blopes | 139 | private ComercialPosVendaDTO iniciarDados() { |
| 140 | ComercialPosVendaDTO comercialDTO = new ComercialPosVendaDTO(); |
||
| 141 | List<PosVendaDTO> listaPosVendaDTO = new ArrayList<PosVendaDTO>(); |
||
| 142 | listaPosVendaDTO.addAll(posVendaService.consultarNaoFinalizadas()); |
||
| 143 | comercialDTO.setListaPosVenda(listaPosVendaDTO); |
||
| 144 | return comercialDTO; |
||
| 145 | |||
| 146 | /* |
||
| 147 | ComercialPosVendaDTO comercialDTO = new ComercialPosVendaDTO(); |
||
| 148 | List<PosVendaDTO> listaPosVendaDTO = new ArrayList<PosVendaDTO>(); |
||
| 149 | |||
| 150 | PosVendaDTO posVendaDTO = new PosVendaDTO(); |
||
| 151 | VendaDTO vendaDTO = new VendaDTO(); |
||
| 152 | vendaDTO.setSequencial(new Long(123456)); |
||
| 153 | Date data = DataUtils.acrescentarDias(new Date(), -5); |
||
| 154 | vendaDTO.setDataVenda(data); |
||
| 155 | ClienteDTO clienteDTO = new ClienteDTO(); |
||
| 156 | clienteDTO.setNome("BRUNO LOPES PEIXOTO"); |
||
| 157 | clienteDTO.setCpfCnpj("06256954459"); |
||
| 158 | clienteDTO.setContato("82996062514"); |
||
| 159 | vendaDTO.setCliente(clienteDTO); |
||
| 160 | posVendaDTO.setVendaDTO(vendaDTO); |
||
| 161 | posVendaDTO.setDataCadastro(data); |
||
| 162 | listaPosVendaDTO.add(posVendaDTO); |
||
| 163 | |||
| 164 | posVendaDTO = new PosVendaDTO(); |
||
| 165 | vendaDTO = new VendaDTO(); |
||
| 166 | vendaDTO.setSequencial(new Long(321654)); |
||
| 167 | vendaDTO.setDataVenda(new Date()); |
||
| 168 | clienteDTO = new ClienteDTO(); |
||
| 169 | clienteDTO.setNome("BÁRBARA ALVES"); |
||
| 170 | clienteDTO.setCpfCnpj("01234567890"); |
||
| 171 | clienteDTO.setContato("8299990000"); |
||
| 172 | vendaDTO.setCliente(clienteDTO); |
||
| 173 | posVendaDTO.setVendaDTO(vendaDTO); |
||
| 174 | posVendaDTO.setDataCadastro(new Date()); |
||
| 175 | listaPosVendaDTO.add(posVendaDTO); |
||
| 176 | |||
| 177 | comercialDTO.setListaPosVenda(listaPosVendaDTO); |
||
| 178 | |||
| 179 | return comercialDTO; |
||
| 180 | */ |
||
| 181 | } |
||
| 182 | |||
| 183 | } |