Пример #1
0
  @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;
    }
  }
Пример #2
0
 @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";
   }
 }