yaml2

 

logging:

level:
ROOT: WARN
az.kapitalbank.atlas: INFO

management:
endpoints:
web:
exposure:
include: [ "env", "health", "info", "refresh" ]
health:
consul:
enabled: false
vault:
enabled: false

spring:
application:
name: ms-account-transfer-processor
messages:
basename: lib-common-i18n/messages
encoding: UTF-8
cloud:
vault:
enabled: false
consul:
enabled: false
openfeign:
client:
config:
default:
connect-timeout: 5000
read-timeout: 10000
logger-level: FULL
okhttp:
enabled: true

kafka:
bootstrap-servers: globalsearch-pre-kafka-zookeeper01.kapitalbank.az:9092
consumer:
bootstrap-servers: globalsearch-pre-kafka-zookeeper02.kapitalbank.az:9092
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: io.confluent.kafka.serializers.KafkaAvroDeserializer
auto-offset-reset: earliest
properties:
concurrency: 3
retry:
max-attempts: 6
interval: 1000 #ms
schema:
registry:
url: https://pre.schemaregistry.globalsearch.kapitalbank.az
specific:
avro:
reader: true
producer:
bootstrap-servers: globalsearch-pre-kafka-zookeeper02.kapitalbank.az:9092
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: io.confluent.kafka.serializers.KafkaAvroSerializer
properties:
schema:
registry:
url: https://pre.schemaregistry.globalsearch.kapitalbank.az
security:
oauth2:
client:
registration:
keycloak:
provider: keycloak
# client-id: ${CLIENT_ID}
client-id: developers
# client-secret: ${CLIENT_SECRET}
# client-secret: thT2Vzp0ZeaeMREFmEkhxksA54dgilOO
client-secret: crQE5DJTaQe4t2jdpVTLccL9Gegxbjof
scope:
- openid
authorization-grant-type: client_credentials
provider:
keycloak:
token-uri: https://pre.atlas-keycloak.kapitalbank.az/auth/realms/Atlas/protocol/openid-connect/token

kyc:
url: https://pre.integration.kapitalbank.az/api/v1/kyc




<entry key="account.query.findByAccountNumberWithAdditionalInfo">
<![CDATA[
SELECT DISTINCT --account
l.maxvalue as "cards.maxValue",
la.curvalue as "cards.currentValue",
a.account AS "accountNumber",
a.type AS "type",
a.status AS "status",
a.currency AS "currency",
NVL(a.overdraftlimit, 0) AS "overdraftLimit",
NVL(a.tmpoverdraft, 0) AS "tmpOverdraft",
NVL(a.availbalance, 0) AS "availableBalance",
a.debithold AS "debitHold",
a.credithold AS "creditHold",
a.branch AS "branchCode",
a.personid AS "customerId",
p.fio AS "customerFullName",
ai.id AS "institutionId",
ai.name AS "institutionName",
--account attributes
auf.name AS "attributes.id",
auf.textvalue AS "attributes.value",
auf.account AS "attributes.accountNumber",
--account link
ac.acctdescr AS "description",
ac.acctstatus AS "cards.linkStatus",
ac.carddescr AS "cards.description",
--card
ac.account AS "cards.accountNumber",
ce.objectid AS "cards.uid",
ce.externalobjectid AS "cards.externalUID",
c.pan AS "cards.pan",
c.mbr AS "cards.mbr",
c.type AS "cards.type",
c.status AS "cards.status",
c.expdate AS "cards.expiryDate",
c.cardprofile AS "cards.profileId",
c.personid AS "cards.customerId",
p2.fio AS "cards.customerFullName",
c.lasttranid AS "cards.lastTransactionId",
c.lasttrantime AS "cards.lastTransactionDate",
c.branch AS "cards.branchCode",
c.nameoncard AS "cards.nameOnCard",
c.ecstatus AS "cards.ecStatus",
ai.id AS "cards.institutionId",
ai.name AS "cards.institutionName",
--card attributes
cuf.name AS "cards.attributes.id",
cuf.textvalue AS "cards.attributes.value",
--card prefix title
CASE
WHEN c.pan IS NOT NULL THEN
(SELECT cp.id
FROM (SELECT p.id
FROM atlas.mv_ath_prefix p
WHERE INSTR(c.pan, p.prefix, 1) = 1
ORDER BY LENGTH(p.prefix) DESC) cp
WHERE ROWNUM <= 1)
ELSE
NULL
END AS "cards.prefixId",
CASE
WHEN c.pan IS NOT NULL THEN
(SELECT cp.prefix
FROM (SELECT p.prefix
FROM atlas.mv_ath_prefix p
WHERE INSTR(c.pan, p.prefix, 1) = 1
ORDER BY LENGTH(p.prefix) DESC) cp
WHERE ROWNUM <= 1)
ELSE
NULL
END AS "cards.prefix",
CASE
WHEN c.pan IS NOT NULL THEN
(SELECT cp.title
FROM (SELECT p.title
FROM atlas.mv_ath_prefix p
WHERE INSTR(c.pan, p.prefix, 1) = 1
ORDER BY LENGTH(p.prefix) DESC) cp
WHERE ROWNUM <= 1)
ELSE
NULL
END AS "cards.title"
FROM baobab.crd_account a
INNER JOIN baobab.crd_person p
ON p.fiid = a.fiid
AND p.id = a.personid
INNER JOIN baobab.ath_institution ai
ON ai.id = a.fiid
LEFT JOIN baobab.crd_account2card ac
ON ac.fiid = a.fiid
AND ac.account = a.account
LEFT JOIN baobab.crd_card c
ON c.fiid = ac.fiid
AND c.pan = ac.pan
AND c.mbr = ac.mbr
AND c.type IN (1, 3)
LEFT JOIN baobab.crd_cardexternal ce
ON ce.pan = c.pan
AND ce.mbr = c.mbr
LEFT JOIN baobab.crd_person p2
ON p2.fiid = c.fiid
AND p2.id = c.personid
LEFT JOIN baobab.crd_acctuserfields auf
ON auf.fiid = a.fiid
AND auf.account = a.account
LEFT JOIN baobab.crd_carduserfields cuf
ON cuf.pan = c.pan
AND cuf.mbr = c.mbr
LEFT JOIN baobab.crd_limit l
on c.pan = l.pan
LEFT JOIN baobab.crd_limitaccumulator la
ON l.pan = la.pan
AND l.limitid = la.limitid
AND la.limitid = 2084
WHERE a.fiid = 1
AND a.account NOT IN (SELECT ba.account_number FROM atlas.blacklist_account ba)
AND a.account = :accountNumber
]]>
</entry>



package az.kapitalbank.atlas.card.account.domain;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class Card {

private String uid;
private String externalUID;
private String pan;
private Integer mbr;
private Integer institutionId;
private String institutionName;
private CardStatus status;
private CardStatus previousStatus;
private ECommerceStatus ecStatus;
private CardType type;
private Integer profileId;
private String nameOnCard;
private String branchCode;
private LocalDateTime expiryDate;
private Long customerId;
private String customerFullName;
private String description;
private Integer prefixId;
private String prefix;
private String title;
private Long lastTransactionId;
private LocalDateTime lastTransactionDate;
private BigDecimal maxValue;
private BigDecimal currentValue;
private List<CardAttribute> attributes;

}



package az.kapitalbank.atlas.card.account.dto;

import az.kapitalbank.atlas.card.account.domain.CardStatus;
import az.kapitalbank.atlas.card.account.domain.CardType;
import az.kapitalbank.atlas.card.account.domain.ECommerceStatus;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CardDto {

private String uid;
private String externalUID;
private String pan;
private Integer mbr;
private CardStatus status;
private ECommerceStatus ecStatus;
private CardType type;
private Integer profileId;
private String nameOnCard;
private String branchCode;
private LocalDateTime expiryDate;
private Integer customerId;
private String customerFullName;
private Integer prefixId;
private String prefix;
private String title;
private String description;
private LocalDateTime lastTransactionDate;
private Boolean isDigital;
private BigDecimal availableLimit;
private BigDecimal maxValue;
private BigDecimal currentValue;

}



package az.kapitalbank.atlas.card.account.service;

import static az.kapitalbank.atlas.card.account.domain.Attribute.EXT_ACCOUNT_NUMBER;
import static az.kapitalbank.atlas.card.account.domain.Attribute.IBAN;

import az.kapitalbank.atlas.card.account.config.ApplicationProperties;
import az.kapitalbank.atlas.card.account.domain.Account;
import az.kapitalbank.atlas.card.account.domain.Card;
import az.kapitalbank.atlas.card.account.dto.AccountDto;
import az.kapitalbank.atlas.card.account.dto.AttributeDto;
import az.kapitalbank.atlas.card.account.dto.CardDto;
import az.kapitalbank.atlas.card.account.dto.request.AccountSearchFilter;
import az.kapitalbank.atlas.card.account.dto.request.CreateAccountRequest;
import az.kapitalbank.atlas.card.account.dto.request.UpdateAccountAttributeRequest;
import az.kapitalbank.atlas.card.account.dto.request.UpdateAccountRequest;
import az.kapitalbank.atlas.card.account.dto.request.UpdateAccountStatusRequest;
import az.kapitalbank.atlas.card.account.dto.response.CreateAccountResponse;
import az.kapitalbank.atlas.card.account.error.ErrorCodes;
import az.kapitalbank.atlas.card.account.mapper.AccountMapper;
import az.kapitalbank.atlas.card.account.repository.FimiRepository;
import az.kapitalbank.atlas.card.account.repository.OmsRepository;
import az.kapitalbank.atlas.card.account.repository.TwoAccountRepository;
import az.kapitalbank.atlas.lib.common.error.ServiceException;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
public class AccountService {

private final FimiRepository fimiRepository;
private final TwoAccountRepository twoAccountRepository;
private final OmsRepository omsRepository;
private final AccountMapper accountMapper;
private final ApplicationProperties properties;

public CreateAccountResponse create(CreateAccountRequest request) {
log.info("CreateAccount, request: {}", request);
var rqAccount = accountMapper.toRqAccount(request);
var response = accountMapper.toCreateAccountResponse(omsRepository.execTran(rqAccount));

log.info("AccountCreated, accountNumber: {}", response.getAccountNumber());
return response;
}

public void update(String accountNumber, UpdateAccountRequest request) {
log.info("UpdateAccount, request: {}", request);
omsRepository.execTran(accountMapper.toRqAccount(accountNumber, request), true);
}

public void updateAttributes(String accountNumber, UpdateAccountAttributeRequest request) {
log.info("UpdateAttributes, accountNumber: {}, attributes: {}",
accountNumber, request.getAttributes());
omsRepository.execTran(accountMapper.toRqAccount(accountNumber, request), true);
}

public List<AccountDto> findAll(AccountSearchFilter filter) {
if (filter.isCustomerIdDefined()) {
var customerId = filter.getCustomerId();
if (isBlacklistedCustomerId(customerId)) {
return Collections.emptyList();
}

return findAllByCustomerId(customerId);
}

if (filter.isCardUIDDefined()) {
return findAllByCardUID(filter.getCardUID());
}

if (filter.isExternalUIDDefined()) {
return findAllByExternalUID(filter.getExternalUID());
}

if (filter.isIbanDefined()) {
return Collections.singletonList(findByIBAN(filter.getIban()));
}

if (filter.isExtAccountNumberDefined()) {
return findByExtAccountNumber(filter.getExtAccountNumber());
}

return Collections.emptyList();
}

public List<AccountDto> findAllByCustomerId(Integer customerId) {
return accountMapper.toAccountDtoList(twoAccountRepository.findAllByCustomerId(customerId));
}

public List<AccountDto> findAllByCardUID(String cardUID) {
return accountMapper.toAccountDtoList(twoAccountRepository.findAllByCardUID(cardUID));
}

private List<AccountDto> findAllByExternalUID(String externalUID) {
return accountMapper.toAccountDtoList(twoAccountRepository.findAllByExternalUID(externalUID));
}

public AccountDto findByIBAN(String iban) {
var accountNumber = twoAccountRepository
.findAccountNumberByAttribute(IBAN, iban)
.orElseThrow(() -> exAccountNotFound(IBAN, iban));

var account = twoAccountRepository
.findByAccountNumber(accountNumber)
.orElseThrow(() -> exAccountNotFound(accountNumber));

return accountMapper.toAccountDto(account);
}

public List<AccountDto> findByExtAccountNumber(String extAccountNumber) {
var accountNumber =
twoAccountRepository.findAccountNumberByAttribute(EXT_ACCOUNT_NUMBER, extAccountNumber)
.orElseThrow(() -> exAccountNotFound(EXT_ACCOUNT_NUMBER, extAccountNumber));

var account = twoAccountRepository.findByAccountNumber(accountNumber)
.orElseThrow(() -> exAccountNotFound(accountNumber));

return accountMapper.toAccountDtoList(List.of(account));
}

public List<AttributeDto> findAttributesByAccountNumber(String accountNumber) {
return accountMapper.toAttributeDtoList(
twoAccountRepository.findAttributesByAccountNumber(accountNumber));
}

public void updateStatus(String accountNumber, UpdateAccountStatusRequest request) {
log.info("Update account status, accountNumber: {}, status: {}",
accountNumber, request.getStatus());
fimiRepository.updateStatus(
accountMapper.toUpdateAccountStatusRequest(accountNumber, request));
}

public AccountDto findByAccountNumber(String accountNumber, boolean additionalInfo) {
AccountDto accountDto = findByAccountNumberWithAdditionalInfo(accountNumber, additionalInfo);

if (!additionalInfo && accountDto.getCards() != null) {
accountDto.getCards().forEach(card -> card.setIsDigital(null));
}

return accountDto;
}

private AccountDto findByAccountNumberWithAdditionalInfo(String accountNumber,
boolean additionalInfo) {
Account account = (additionalInfo
? twoAccountRepository.findByAccountNumberWithAdditionalInfo(accountNumber)
: twoAccountRepository.findByAccountNumber(accountNumber))
.orElseThrow(() -> exAccountNotFound(accountNumber));

AccountDto accountDto = accountMapper.toAccountDto(account);
BigDecimal balance = account.getAvailableBalance();

accountDto.getCards().forEach(card ->
card.setAvailableLimit(calcAvailableLimit(card, balance)));

return accountDto;
}

private BigDecimal calcAvailableLimit(CardDto card, BigDecimal balance) {
BigDecimal maxValue = card.getMaxValue();
BigDecimal currentValue = card.getCurrentValue();

if (maxValue == null || BigDecimal.ZERO.compareTo(maxValue) == 0) {
return balance;
}
BigDecimal diff = maxValue.subtract(
currentValue != null ? currentValue : BigDecimal.ZERO);
return diff.compareTo(balance) >= 0 ? balance : diff;
}

private boolean isBlacklistedCustomerId(Integer customerId) {
return properties.getCustomerBlacklist()
.stream()
.anyMatch(blacklistedCustomerId -> blacklistedCustomerId.equals(customerId));
}

private ServiceException exAccountNotFound(String accountNumber) {
return ServiceException.of(ErrorCodes.ACCOUNT_NOT_FOUND,
"accountNumber", accountNumber);
}

private ServiceException exAccountNotFound(String id, String value) {
return ServiceException.of(ErrorCodes.ACCOUNT_NOT_FOUND,
id.toLowerCase(), value);
}

}



<entry key="account.query.findByAccountNumberWithAdditionalInfo">
<![CDATA[
SELECT DISTINCT --account
l.maxvalue as "cards.maxValue",
la.curvalue as "cards.currentValue",
a.account AS "accountNumber",
a.type AS "type",
a.status AS "status",
a.currency AS "currency",
NVL(a.overdraftlimit, 0) AS "overdraftLimit",
NVL(a.tmpoverdraft, 0) AS "tmpOverdraft",
NVL(a.availbalance, 0) AS "availableBalance",
a.debithold AS "debitHold",
a.credithold AS "creditHold",
a.branch AS "branchCode",
a.personid AS "customerId",
p.fio AS "customerFullName",
ai.id AS "institutionId",
ai.name AS "institutionName",
--account attributes
auf.name AS "attributes.id",
auf.textvalue AS "attributes.value",
auf.account AS "attributes.accountNumber",
--account link
ac.acctdescr AS "description",
ac.acctstatus AS "cards.linkStatus",
ac.carddescr AS "cards.description",
--card
ac.account AS "cards.accountNumber",
ce.objectid AS "cards.uid",
ce.externalobjectid AS "cards.externalUID",
c.pan AS "cards.pan",
c.mbr AS "cards.mbr",
c.type AS "cards.type",
c.status AS "cards.status",
c.expdate AS "cards.expiryDate",
c.cardprofile AS "cards.profileId",
c.personid AS "cards.customerId",
p2.fio AS "cards.customerFullName",
c.lasttranid AS "cards.lastTransactionId",
c.lasttrantime AS "cards.lastTransactionDate",
c.branch AS "cards.branchCode",
c.nameoncard AS "cards.nameOnCard",
c.ecstatus AS "cards.ecStatus",
ai.id AS "cards.institutionId",
ai.name AS "cards.institutionName",
--card attributes
cuf.name AS "cards.attributes.id",
cuf.textvalue AS "cards.attributes.value",
--card prefix title
CASE
WHEN c.pan IS NOT NULL THEN
(SELECT cp.id
FROM (SELECT p.id
FROM atlas.mv_ath_prefix p
WHERE INSTR(c.pan, p.prefix, 1) = 1
ORDER BY LENGTH(p.prefix) DESC) cp
WHERE ROWNUM <= 1)
ELSE
NULL
END AS "cards.prefixId",
CASE
WHEN c.pan IS NOT NULL THEN
(SELECT cp.prefix
FROM (SELECT p.prefix
FROM atlas.mv_ath_prefix p
WHERE INSTR(c.pan, p.prefix, 1) = 1
ORDER BY LENGTH(p.prefix) DESC) cp
WHERE ROWNUM <= 1)
ELSE
NULL
END AS "cards.prefix",
CASE
WHEN c.pan IS NOT NULL THEN
(SELECT cp.title
FROM (SELECT p.title
FROM atlas.mv_ath_prefix p
WHERE INSTR(c.pan, p.prefix, 1) = 1
ORDER BY LENGTH(p.prefix) DESC) cp
WHERE ROWNUM <= 1)
ELSE
NULL
END AS "cards.title"
FROM baobab.crd_account a
INNER JOIN baobab.crd_person p
ON p.fiid = a.fiid
AND p.id = a.personid
INNER JOIN baobab.ath_institution ai
ON ai.id = a.fiid
LEFT JOIN baobab.crd_account2card ac
ON ac.fiid = a.fiid
AND ac.account = a.account
LEFT JOIN baobab.crd_card c
ON c.fiid = ac.fiid
AND c.pan = ac.pan
AND c.mbr = ac.mbr
AND c.type IN (1, 3)
LEFT JOIN baobab.crd_cardexternal ce
ON ce.pan = c.pan
AND ce.mbr = c.mbr
LEFT JOIN baobab.crd_person p2
ON p2.fiid = c.fiid
AND p2.id = c.personid
LEFT JOIN baobab.crd_acctuserfields auf
ON auf.fiid = a.fiid
AND auf.account = a.account
LEFT JOIN baobab.crd_carduserfields cuf
ON cuf.pan = c.pan
AND cuf.mbr = c.mbr
LEFT JOIN baobab.crd_limit l
on c.pan = l.pan
LEFT JOIN baobab.crd_limitaccumulator la
ON l.pan = la.pan
AND l.limitid = la.limitid
AND la.limitid = 2084
WHERE a.fiid = 1
AND a.account NOT IN (SELECT ba.account_number FROM atlas.blacklist_account ba)
AND a.account = :accountNumber
]]>
</entry>











logging:
level:
ROOT: INFO
az.kapitalbank.commons: DEBUG

management:
endpoints:
web:
exposure:
include: [ "env", "health", "info" ]

spring:
application:
name: ms-file-store
messages:
basename: i18n/messages
encoding: UTF-8
datasource:
# url: jdbc:oracle:thin:@10.0.32.202:1521:commonsvc
url: jdbc:oracle:thin:@//10.242.135.233:1521/commonsvc
driver-class-name: oracle.jdbc.OracleDriver
username: FILE_STORE
# password: ${PASSWORD}
password: s!taht!
# datasource:
# url: jdbc:oracle:thin:@10.0.32.202:1521:commonsvc
# driver-class-name: oracle.jdbc.OracleDriver
# username: FILE_STORE
# password: ${PASSWORD}
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.OracleDialect
liquibase:
change-log: classpath:config/liquibase/db.master-changelog.xml

cloud:
vault:
enabled: false
consul:
enabled: false










Комментарии

Популярные сообщения из этого блога

IoC:ApplicationContext, BeanFactory. Bean

Lesson1: JDK, JVM, JRE

Lesson_2: Operations in Java