Рефакторинг
This commit is contained in:
parent
8e5edc1e9e
commit
3184e46d1b
@ -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;
|
||||
|
@ -23,6 +23,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
@Override
|
||||
public Boolean pay(Integer accountId, Integer extinguishedPersonId, Double sum) {
|
||||
Account account = accountRepository.findById(accountId);
|
||||
if (validStatus(account.getAccountStatus())) {
|
||||
if (account.getTotalSum().equals(sum)) {
|
||||
account.setAccountStatus(AccountStatus.CLOSED);
|
||||
account.setExtinguishedPersonId(extinguishedPersonId);
|
||||
@ -32,9 +33,16 @@ public class AccountServiceImpl implements AccountService {
|
||||
accountRepository.edit(accountId, account);
|
||||
throw new PaymentException(2, "Неверная сумма");
|
||||
}
|
||||
} else {
|
||||
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());
|
||||
|
@ -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<JsonObject> eventRepository;
|
||||
|
||||
public RawEventServiceImpl(EventRepository eventRepository) {
|
||||
public RawEventServiceImpl(EventRepository<JsonObject> eventRepository) {
|
||||
this.eventRepository = eventRepository;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user