account-service http://jira.mfd.msk:8088/browse/CLS-272 ClientCodeService, TradingClearingRegistryService
This commit is contained in:
parent
2a873a22b3
commit
e224a4ffb7
2 changed files with 37 additions and 1 deletions
|
|
@ -34,6 +34,7 @@ import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||||
import ru.spcex.platform.imdg.api.Imdg;
|
import ru.spcex.platform.imdg.api.Imdg;
|
||||||
import ru.spcex.platform.imdg.api.ImdgId;
|
import ru.spcex.platform.imdg.api.ImdgId;
|
||||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||||
|
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||||
import ru.spcex.platform.utils.error.ClearingBaseException;
|
import ru.spcex.platform.utils.error.ClearingBaseException;
|
||||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||||
|
|
@ -111,6 +112,33 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Проверки
|
||||||
|
* 3.5.1 если не была найдена запись в tradingClearingRegistry по companyId, moneyAccountId, depoAccountId и tradingClearingRegistryType=B (п 3.5.1)
|
||||||
|
* 3.5.2 если не заполнены поля moneyAccountId ИЛИ moneyAccountId и depoAccountId
|
||||||
|
* @param userRequest
|
||||||
|
* @param moneyAccountId req.getMoneyAccountId()
|
||||||
|
* @param depoAccountId req.getDepoAccountId()
|
||||||
|
* @param companyId req.getCompanyId()
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
RequestInfoUpdate crossValidate(BaseRequest<?> userRequest, Long moneyAccountId, Long depoAccountId, Long companyId) {
|
||||||
|
if (moneyAccountId == null) { // Если не заполнены moneyAccountId ИЛИ moneyAccountId и depoAccountId
|
||||||
|
EnumMessage error = null;
|
||||||
|
if (companyId == null) {
|
||||||
|
error = new EnumMessage(AccountError.RequiredFieldEmpty, "companyId");
|
||||||
|
} else {
|
||||||
|
TradingClearingRegistry tcr = tradingClearingRegistryMap.getSingleObjectByFieldValues(Map.of("companyId", companyId));
|
||||||
|
if (tcr==null) {
|
||||||
|
error=new EnumMessage(AccountError.TradingClearingRegistryNotFound, companyId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (error != null) {
|
||||||
|
return requestHelper.makeErrorResponse(userRequest, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
protected RequestInfoUpdate clientCodeNew(BaseRequest<ClientCodeNewRequest> userRequest) {
|
protected RequestInfoUpdate clientCodeNew(BaseRequest<ClientCodeNewRequest> userRequest) {
|
||||||
log.debug("ClientCodeNewRequest received {}", userRequest.getId());
|
log.debug("ClientCodeNewRequest received {}", userRequest.getId());
|
||||||
|
|
@ -122,6 +150,9 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
||||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||||
|
|
||||||
ClientCodeNewRequest req = userRequest.getRequestPayload();
|
ClientCodeNewRequest req = userRequest.getRequestPayload();
|
||||||
|
// дополнительная проверка
|
||||||
|
requestInfoUpdate = crossValidate(userRequest, req.getMoneyAccountId(), req.getDepoAccountId(), req.getCompanyId());
|
||||||
|
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||||
|
|
||||||
boolean doCreateTCR = checkNeedCreateTCR(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
boolean doCreateTCR = checkNeedCreateTCR(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||||
if (doCreateTCR) {
|
if (doCreateTCR) {
|
||||||
|
|
@ -155,6 +186,9 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
||||||
|
|
||||||
|
|
||||||
ClientCodeNewRequest req = userRequest.getRequestPayload();
|
ClientCodeNewRequest req = userRequest.getRequestPayload();
|
||||||
|
// дополнительная проверка
|
||||||
|
requestInfoUpdate = crossValidate(userRequest, req.getMoneyAccountId(), req.getDepoAccountId(), req.getCompanyId());
|
||||||
|
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||||
|
|
||||||
boolean doCreateTCR = checkNeedCreateTCR(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
boolean doCreateTCR = checkNeedCreateTCR(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||||
if (doCreateTCR) {
|
if (doCreateTCR) {
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,9 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
||||||
tradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());
|
tradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());
|
||||||
|
|
||||||
String tradingRegistryType;
|
String tradingRegistryType;
|
||||||
if (depoAccount != null) {
|
if (req.getTradingClearingRegistryType()!=null) {
|
||||||
|
tradingRegistryType = req.getTradingClearingRegistryType();
|
||||||
|
} else if (depoAccount != null) {
|
||||||
tradingRegistryType = depoAccount.getDepoAccountType();
|
tradingRegistryType = depoAccount.getDepoAccountType();
|
||||||
} else {
|
} else {
|
||||||
if (clearingAccount != null) tradingRegistryType = clearingAccount.getClearingAccountType();
|
if (clearingAccount != null) tradingRegistryType = clearingAccount.getClearingAccountType();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue