Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 635 | blopes | 1 | package br.com.ec.domain.service.posvenda.impl; |
| 2 | |||
| 3 | import org.springframework.beans.factory.annotation.Autowired; |
||
| 4 | import org.springframework.stereotype.Service; |
||
| 5 | |||
| 6 | import br.com.ec.core.generic.AbstractService; |
||
| 7 | import br.com.ec.core.generic.GenericRepository; |
||
| 8 | import br.com.ec.core.util.DataUtils; |
||
| 9 | import br.com.ec.core.util.VerificadorUtil; |
||
| 10 | import br.com.ec.core.validador.Validador; |
||
| 11 | import br.com.ec.domain.model.PosVenda; |
||
| 12 | import br.com.ec.domain.model.Venda; |
||
| 13 | import br.com.ec.domain.service.npsposvenda.NpsPosVendaService; |
||
| 14 | import br.com.ec.domain.service.posvenda.PosVendaService; |
||
| 15 | import br.com.ec.infrastructure.repository.PosVendaRepository; |
||
| 16 | |||
| 17 | @Service |
||
| 18 | public class PosVendaServiceImpl extends AbstractService<PosVenda> implements PosVendaService { |
||
| 19 | |||
| 20 | private NpsPosVendaService npsPosVendaService; |
||
| 21 | private PosVendaRepository posVendaRepository; |
||
| 22 | |||
| 23 | @Autowired |
||
| 24 | public PosVendaServiceImpl(Validador validador, NpsPosVendaService npsPosVendaService, PosVendaRepository posVendaRepository) { |
||
| 25 | super(validador); |
||
| 26 | this.npsPosVendaService = npsPosVendaService; |
||
| 27 | this.posVendaRepository = posVendaRepository; |
||
| 28 | } |
||
| 29 | |||
| 30 | @Override |
||
| 31 | protected GenericRepository<PosVenda> getRepository() { |
||
| 32 | return posVendaRepository; |
||
| 33 | } |
||
| 34 | |||
| 35 | @Override |
||
| 36 | public void iniciarPosVenda(Venda venda) { |
||
| 37 | PosVenda posVenda = new PosVenda(); |
||
| 38 | posVenda.setDataCadastro(DataUtils.getDataAtual()); |
||
| 39 | posVenda.setVenda(venda); |
||
| 40 | if (VerificadorUtil.naoEstaNulo(venda.getCliente())) { |
||
| 41 | if (VerificadorUtil.naoEstaNuloOuVazio(venda.getCliente().getContato())) { |
||
| 42 | posVenda.setCliente(venda.getCliente()); |
||
| 43 | this.cadastrar(posVenda); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 48 | @Override |
||
| 49 | public void excluirPosVenda(Long sequencialVenda) { |
||
| 50 | npsPosVendaService.excluirNpsPosVenda(null, sequencialVenda); |
||
| 51 | posVendaRepository.excluirPosVenda(sequencialVenda); |
||
| 52 | } |
||
| 53 | |||
| 54 | } |