Rev 629 | Rev 631 | 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.domain.service.impl; |
| 2 | |||
| 3 | import java.util.List; |
||
| 4 | |||
| 5 | import org.springframework.beans.factory.annotation.Autowired; |
||
| 6 | import org.springframework.stereotype.Service; |
||
| 7 | |||
| 630 | blopes | 8 | import br.com.ec.core.exception.NegocioException; |
| 623 | blopes | 9 | import br.com.ec.core.generic.AbstractService; |
| 10 | import br.com.ec.core.generic.GenericRepository; |
||
| 630 | blopes | 11 | import br.com.ec.core.util.DataUtils; |
| 12 | import br.com.ec.core.util.VerificadorUtil; |
||
| 623 | blopes | 13 | import br.com.ec.core.validador.Validador; |
| 630 | blopes | 14 | import br.com.ec.domain.dto.ComercialPosVendaDTO; |
| 15 | import br.com.ec.domain.dto.NpsPosVendaDTO; |
||
| 623 | blopes | 16 | import br.com.ec.domain.dto.PosVendaDTO; |
| 17 | import br.com.ec.domain.model.PosVenda; |
||
| 630 | blopes | 18 | import br.com.ec.domain.model.tipos.TipoNpsPosVenda; |
| 19 | import br.com.ec.domain.service.NpsPosVendaService; |
||
| 623 | blopes | 20 | import br.com.ec.domain.service.PosVendaService; |
| 21 | import br.com.ec.repository.PosVendaRepository; |
||
| 22 | |||
| 23 | @Service |
||
| 24 | public class PosVendaServiceImpl extends AbstractService<PosVenda> implements PosVendaService { |
||
| 630 | blopes | 25 | |
| 623 | blopes | 26 | private PosVendaRepository posVendaRepository; |
| 630 | blopes | 27 | private NpsPosVendaService npsPosVendaService; |
| 623 | blopes | 28 | |
| 29 | @Autowired |
||
| 630 | blopes | 30 | public PosVendaServiceImpl(Validador validador, PosVendaRepository posVendaRepository, NpsPosVendaService npsPosVendaService) { |
| 623 | blopes | 31 | super(validador); |
| 32 | this.posVendaRepository = posVendaRepository; |
||
| 630 | blopes | 33 | this.npsPosVendaService = npsPosVendaService; |
| 623 | blopes | 34 | } |
| 35 | |||
| 36 | @Override |
||
| 37 | protected GenericRepository<PosVenda> getRepository() { |
||
| 38 | return posVendaRepository; |
||
| 39 | } |
||
| 40 | |||
| 41 | @Override |
||
| 630 | blopes | 42 | public ComercialPosVendaDTO consultarPosVendaEmAndamento() { |
| 43 | ComercialPosVendaDTO comercialPosVendaDTO = new ComercialPosVendaDTO(); |
||
| 44 | List<PosVendaDTO> listaPosVendaNaoFinalizadas = posVendaRepository.consultarNaoFinalizadas(); |
||
| 45 | for (PosVendaDTO posVendaNaoFinalizada : listaPosVendaNaoFinalizadas) { |
||
| 46 | NpsPosVendaDTO npsPosVendaAgradecimento = npsPosVendaService.consultarPorPosVendaEeTipo(posVendaNaoFinalizada.getSequencial(), TipoNpsPosVenda.ATENDIMENTO_A.getValor()); |
||
| 47 | if (VerificadorUtil.naoEstaNulo(npsPosVendaAgradecimento)) { |
||
| 48 | if (VerificadorUtil.estaNulo(npsPosVendaAgradecimento.getDataFinalizacao())) { |
||
| 49 | posVendaNaoFinalizada.setNpsPosVendaAgradecimento(npsPosVendaAgradecimento); |
||
| 50 | comercialPosVendaDTO.getListaPosVendaAgradecimento().add(posVendaNaoFinalizada); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | posVendaNaoFinalizada.setNpsPosVendaAgradecimento(npsPosVendaService.consultarPorPosVendaEeTipo(posVendaNaoFinalizada.getSequencial(), TipoNpsPosVenda.ATENDIMENTO_A.getValor())); |
||
| 54 | } |
||
| 55 | comercialPosVendaDTO.setListaEmAndamento(listaPosVendaNaoFinalizadas); |
||
| 56 | return comercialPosVendaDTO; |
||
| 623 | blopes | 57 | } |
| 58 | |||
| 630 | blopes | 59 | @Override |
| 60 | public void iniciarAtendimento(PosVendaDTO posVendaDTO) { |
||
| 61 | try { |
||
| 62 | PosVenda posVendaParaAlterar = this.consultarPorId(new PosVenda(posVendaDTO.getSequencial())); |
||
| 63 | posVendaParaAlterar.setDataInicio(DataUtils.getDataAtual()); |
||
| 64 | posVendaParaAlterar.setObservacao(posVendaDTO.getObservacao()); |
||
| 65 | posVendaParaAlterar.setTipoFinalizacao(posVendaDTO.getTipoFinalizacao()); |
||
| 66 | // NpsPosVendaDTO npsPosVendaDTO = npsPosVendaService.consultarPorPosVendaEeTipo(posVendaDTO.getSequencial(), TipoNpsPosVenda.ATENDIMENTO_A.getValor()); |
||
| 67 | // NpsPosVenda npsPosVenda = npsPosVendaService.consultarPorId(new NpsPosVenda(npsPosVendaDTO.getSequencial())); |
||
| 68 | // npsPosVendaService.alterar(npsPosVenda); |
||
| 69 | this.alterar(posVendaParaAlterar); |
||
| 70 | } catch (Exception e) { |
||
| 71 | throw new NegocioException(e.getMessage()); |
||
| 72 | } |
||
| 73 | } |
||
| 74 | |||
| 623 | blopes | 75 | } |