@Override public BankAccountDTO checkSolvability(float amount, Integer bankAccountId) { BankAccountDTO bankAccountDTO = PaymentMapper.convert(bankDao.getBankAccountById(bankAccountId)); if (bankAccountDTO.getBalance() <= amount) { return null; } else { LOGGER.info("$$$ Solvability OK $$$ "); return bankAccountDTO; } }
@Override public BankCardDTO getBankCardByOwner(Integer userId) { LOGGER.info(" $$$ Params to check bank card by userId ==> " + userId + " $$$ "); BankCardDTO bankCardDto = null; EBankCard bankCard = bankDao.getBankCardByOwner(userId); if (bankCard == null) { LOGGER.info("$$$ No bank card found $$$ "); return null; } else { bankCardDto = PaymentMapper.convert(bankCard); return bankCardDto; } }
@Override public String doPayment(BankAccountDTO bankAccount, float amount, Integer idBookingInProgress) { LOGGER.info(" $$$ Do Payment web service $$$ "); if (bankAccount != null) { LOGGER.info(" $$$ Bank account OK -- start credit operation : " + amount + " $$$ "); double balance = bankAccount.getBalance(); double newbalance = balance - amount; bankAccount.setBalance(newbalance); EBankAccount ba = PaymentMapper.convert(bankAccount); bankDao.updateBankAccount(ba); // TODO delete BP only if Payment is OK bookingProgressDao.delete(idBookingInProgress); return "OK"; } else { return "KO"; } }
@Override public BankAccountDTO checkBankCardLinkedBankAccount(Integer bankCardId) { EBankAccount ba = bankDao.getBankAccountByBankCard(bankCardId); LOGGER.info(" $$$ Bank account linked = " + ba.getIdBankAccount() + " $$$ "); return PaymentMapper.convert(bankDao.getBankAccountByBankCard(bankCardId)); }
@Override public UserPaymentDTO login(String login) { EUser user = userDao.loadUserByUsername(login); UserPaymentDTO u = PaymentMapper.convert(user); return u; }