private void insertToMsgHist( Transacao tr, String message, StatusType statusType, MessageStatus messageStatus) { Historico hist = new Historico(); hist.setDtCriacao(new Date()); hist.setLa(tr.getLa()); hist.setMensagem(tr.getMensagem()); hist.setTxMensagem(message); hist.setMsisdn(tr.getMsisdn()); hist.setOperadora(tr.getOperadora()); hist.setMessageStatus(messageStatus); hist.setStatusType(statusType); hist.setParceiro(tr.getParceiro()); hist.setValorTarifacao(tr.getValorTarifacao()); hist.setRetentativa(1); hist.setUrl(null); historicoDAO.save(hist); }
private boolean isOptionIn() { String optionInMsg = moRequest.getTextMessage(); String expectedAnswer = configDAO.findByName(OPTION_IN_ANSWER); if (optionInMsg.equalsIgnoreCase(expectedAnswer)) { String originator = moRequest.getOriginationNumber(); Transacao tr = transacaoDAO.findLastByMsisdnAndStatus( originator, TransactionStatus.WAIT_OPTION_IN_ANSWER); if (tr != null) { tr.setTransactionStatus(TransactionStatus.TRANSACTION_AUTHORIZED); transacaoDAO.update(tr); insertToMsgHist( tr, optionInMsg, StatusType.WAIT_OPTION_IN_ANSWER, MessageStatus.TRANSACTION_AUTHORIZED); OptionIn optionIn = optionInDAO.findByTransactionId(tr.getId()); optionIn.setTimeOfAuthorization(Calendar.getInstance().getTime()); optionIn.setIsAuthorized(1); optionInDAO.update(optionIn); logger.info( loggerMessageDAO.getMessageByShortcode( VOUCHER_AUTHORIZED, tr.getCampanha().getKeyword(), tr.getMsisdn(), tr.getId(), dateTimeFormat.format(Calendar.getInstance().getTime()))); List<Transacao> trList = transacaoDAO.findAllByMsisdnAndStatus( originator, TransactionStatus.WAIT_OPTION_IN_ANSWER); for (Transacao t : trList) { t.setTransactionStatus(TransactionStatus.TRANSACTION_CANCELED); transacaoDAO.update(t); insertToMsgHist( t, null, StatusType.WAIT_OPTION_IN_ANSWER, MessageStatus.TRANSACTION_CANCELED); logger.info( loggerMessageDAO.getMessageByShortcode( VOUCHER_CANCELED, tr.getCampanha().getKeyword(), tr.getMsisdn(), tr.getId(), dateTimeFormat.format(Calendar.getInstance().getTime()))); } return true; } else { return false; } } return false; }