diff --git a/src/main/java/org/sadtech/bot/core/domain/content/attachment/Attachment.java b/src/main/java/org/sadtech/bot/core/domain/content/attachment/Attachment.java index fef3973..12698de 100644 --- a/src/main/java/org/sadtech/bot/core/domain/content/attachment/Attachment.java +++ b/src/main/java/org/sadtech/bot/core/domain/content/attachment/Attachment.java @@ -2,7 +2,7 @@ package org.sadtech.bot.core.domain.content.attachment; public abstract class Attachment { - AttachmentType type; + protected AttachmentType type; public AttachmentType getType() { return type; diff --git a/src/main/java/org/sadtech/bot/core/service/impl/AccountServiceImpl.java b/src/main/java/org/sadtech/bot/core/service/impl/AccountServiceImpl.java index 2a370e4..e13d53c 100644 --- a/src/main/java/org/sadtech/bot/core/service/impl/AccountServiceImpl.java +++ b/src/main/java/org/sadtech/bot/core/service/impl/AccountServiceImpl.java @@ -23,18 +23,26 @@ public class AccountServiceImpl implements AccountService { @Override public Boolean pay(Integer accountId, Integer extinguishedPersonId, Double sum) { Account account = accountRepository.findById(accountId); - if (account.getTotalSum().equals(sum)) { - account.setAccountStatus(AccountStatus.CLOSED); - account.setExtinguishedPersonId(extinguishedPersonId); - accountRepository.edit(accountId, account); + if (validStatus(account.getAccountStatus())) { + if (account.getTotalSum().equals(sum)) { + account.setAccountStatus(AccountStatus.CLOSED); + account.setExtinguishedPersonId(extinguishedPersonId); + accountRepository.edit(accountId, account); + } else { + account.setAccountStatus(AccountStatus.EXCEPTION); + accountRepository.edit(accountId, account); + throw new PaymentException(2, "Неверная сумма"); + } } else { - account.setAccountStatus(AccountStatus.EXCEPTION); - accountRepository.edit(accountId, account); - throw new PaymentException(2, "Неверная сумма"); + throw new PaymentException(3, "Счет уже оплачен"); } return true; } + private boolean validStatus(AccountStatus accountStatus) { + return AccountStatus.EXCEPTION.equals(accountStatus) || AccountStatus.EXPOSED.equals(accountStatus); + } + @Override public Boolean paymentVerification(Integer accountId) { return AccountStatus.CLOSED.equals(accountRepository.findById(accountId).getAccountStatus()); diff --git a/src/main/java/org/sadtech/bot/core/service/impl/RawEventServiceImpl.java b/src/main/java/org/sadtech/bot/core/service/impl/RawEventServiceImpl.java index a61880c..16b7ad7 100644 --- a/src/main/java/org/sadtech/bot/core/service/impl/RawEventServiceImpl.java +++ b/src/main/java/org/sadtech/bot/core/service/impl/RawEventServiceImpl.java @@ -12,9 +12,9 @@ public class RawEventServiceImpl implements RawEventService { private static final Logger log = LoggerFactory.getLogger(RawEventServiceImpl.class); - private final EventRepository eventRepository; + private final EventRepository eventRepository; - public RawEventServiceImpl(EventRepository eventRepository) { + public RawEventServiceImpl(EventRepository eventRepository) { this.eventRepository = eventRepository; }