account-service-v2
This commit is contained in:
parent
ccef108e13
commit
9eec24c4cf
1 changed files with 7 additions and 15 deletions
|
|
@ -121,7 +121,6 @@ public class ClientCodeMessageListener extends QueueConsumer implements Initiali
|
|||
|
||||
//unwrap запроса
|
||||
for (Map.Entry<TkrAccount, ValidationResult> entry : accountsAfterValidation.entrySet()) {
|
||||
ClientCodeNewRequest clientCodeNewRequest = new ClientCodeNewRequest();
|
||||
TkrAccount tkrAccount = entry.getKey();
|
||||
ValidationResult validationResult = entry.getValue();
|
||||
log.debug("Creating new clientCode by tkr account: {}", tkrAccount.getClientCode());
|
||||
|
|
@ -132,18 +131,20 @@ public class ClientCodeMessageListener extends QueueConsumer implements Initiali
|
|||
Long depoAccountId = depoAccount.map(Account::getId).orElse(null);
|
||||
Map<String, Account> accountByCurrency = validator.getStored(ClientCodeStoreObjects.MAPPED_TO_CURRENCY_ACCOUNTS);
|
||||
|
||||
clientCodeNewRequest.setCompanyId(company.getId());
|
||||
clientCodeNewRequest.setCode(tkrAccount.getClientCode());
|
||||
clientCodeNewRequest.setDepoAccountId(depoAccountId);
|
||||
Account moneyAccount = accountByCurrency.get(CurrencyCode.RUB.getKey());
|
||||
clientCodeNewRequest.setMoneyAccountId(moneyAccount.getId());
|
||||
|
||||
List<Long> foreignCurrencyList = accountByCurrency.entrySet()
|
||||
.stream()
|
||||
.filter(currencyCodeAccountEntry -> !CurrencyCode.RUB.equalsByKey(currencyCodeAccountEntry.getKey()))
|
||||
.map(currencyCodeAccountEntry -> currencyCodeAccountEntry.getValue().getId())
|
||||
.toList();
|
||||
|
||||
ClientCodeNewRequest clientCodeNewRequest = new ClientCodeNewRequest();
|
||||
clientCodeNewRequest.setCompanyId(company.getId());
|
||||
clientCodeNewRequest.setCode(tkrAccount.getClientCode());
|
||||
clientCodeNewRequest.setDepoAccountId(depoAccountId);
|
||||
clientCodeNewRequest.setMoneyAccountId(moneyAccount.getId());
|
||||
clientCodeNewRequest.setCurrencyAccountList(foreignCurrencyList);
|
||||
|
||||
clientCodeFacade.createClientCode(clientCodeNewRequest, validator);
|
||||
|
||||
TradingClearingRegistry tradingClearingRegistry = selectTradingClearingRegistry(company.getId(),
|
||||
|
|
@ -168,15 +169,6 @@ public class ClientCodeMessageListener extends QueueConsumer implements Initiali
|
|||
return DefaultResponses.build(clientCodeNewRequest.getId(), DefaultResponses.SUCCESS);
|
||||
}
|
||||
|
||||
private RequestInfoUpdate makeErrorResponse(BaseRequest<ClientCodeNewRequest> clientCodeNewRequest,
|
||||
ValidationResult validationResult) {
|
||||
RequestInfoUpdate requestInfoUpdate = new RequestInfoUpdate();
|
||||
requestInfoUpdate.setId(clientCodeNewRequest.getId());
|
||||
requestInfoUpdate.setStatus(Status.Error);
|
||||
validationResult.errorMsg().ifPresent(requestInfoUpdate::setMessage);
|
||||
return requestInfoUpdate;
|
||||
}
|
||||
|
||||
private TradingClearingRegistry selectTradingClearingRegistry(Long companyId, Long moneyAccountId, Long depoAccountId) {
|
||||
Map<String, Comparable<?>> query = new HashMap<>();
|
||||
query.put("companyId", companyId);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue