From 766a852f486ebc0eb884191cb676795c937e80ea Mon Sep 17 00:00:00 2001 From: Inal Arsanukaev Date: Tue, 27 Aug 2019 13:33:08 +0300 Subject: [PATCH] Updated according to fistful-proto (#73) --- pom.xml | 4 ++-- .../destination/DestinationCreatedHandler.java | 10 ++++++++++ .../WithdrawalStatusChangedHandler.java | 8 +++++++- .../WithdrawalSessionCreatedHandler.java | 15 ++++++++++++--- .../WithdrawalSessionFinishedHandler.java | 4 ++++ .../V34__1.0.52_update_fistful_proto.sql | 16 ++++++++++++++++ 6 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 src/main/resources/db/migration/V34__1.0.52_update_fistful_proto.sql diff --git a/pom.xml b/pom.xml index f5572a2..2ca392c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 newway - 1.0.51-SNAPSHOT + 1.0.52-SNAPSHOT jar newway @@ -32,7 +32,7 @@ jdbc:postgresql://localhost:5432/newway 5432 1.320-95ff602 - 1.27-e2c29cb + 1.36-683822a target/sites/jacoco/jacoco.exec target/site/cobertura/coverage.xml diff --git a/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/destination/DestinationCreatedHandler.java b/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/destination/DestinationCreatedHandler.java index f636516..a75a980 100644 --- a/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/destination/DestinationCreatedHandler.java +++ b/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/destination/DestinationCreatedHandler.java @@ -70,13 +70,23 @@ public class DestinationCreatedHandler extends AbstractDestinationHandler { destination.setResourceBankCardToken(bankCard.getToken()); destination.setResourceBankCardBin(bankCard.getBin()); destination.setResourceBankCardMaskedPan(bankCard.getMaskedPan()); + destination.setResourceBankCardBankName(bankCard.getBankName()); + if (bankCard.isSetIssuerCountry()) { + destination.setResourceBankCardIssuerCountry(bankCard.getIssuerCountry().toString()); + } if (bankCard.isSetPaymentSystem()) { destination.setResourceBankCardPaymentSystem(bankCard.getPaymentSystem().toString()); } + if (bankCard.isSetCardType()) { + destination.setResourceBankCardType(bankCard.getCardType().toString()); + } } else if (resource.isSetCryptoWallet()) { CryptoWallet wallet = resource.getCryptoWallet(); destination.setResourceCryptoWalletId(wallet.getId()); destination.setResourceCryptoWalletType(wallet.getCurrency().name()); + if (wallet.isSetData()) { + destination.setResourceCryptoWalletData(wallet.getData().getSetField().getFieldName()); + } } destinationDao.updateNotCurrent(event.getSource()); diff --git a/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/withdrawal/WithdrawalStatusChangedHandler.java b/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/withdrawal/WithdrawalStatusChangedHandler.java index 14584d9..bfa208d 100644 --- a/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/withdrawal/WithdrawalStatusChangedHandler.java +++ b/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/withdrawal/WithdrawalStatusChangedHandler.java @@ -1,6 +1,7 @@ package com.rbkmoney.newway.poller.event_stock.impl.withdrawal; import com.rbkmoney.fistful.withdrawal.Change; +import com.rbkmoney.fistful.withdrawal.Failure; import com.rbkmoney.fistful.withdrawal.SinkEvent; import com.rbkmoney.geck.common.util.TBaseUtil; import com.rbkmoney.geck.common.util.TypeUtil; @@ -14,6 +15,7 @@ import com.rbkmoney.newway.domain.enums.FistfulCashFlowChangeType; import com.rbkmoney.newway.domain.enums.WithdrawalStatus; import com.rbkmoney.newway.domain.tables.pojos.FistfulCashFlow; import com.rbkmoney.newway.domain.tables.pojos.Withdrawal; +import com.rbkmoney.newway.util.JsonUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -54,7 +56,11 @@ public class WithdrawalStatusChangedHandler extends AbstractWithdrawalHandler { withdrawal.setEventOccuredAt(TypeUtil.stringToLocalDateTime(event.getPayload().getOccuredAt())); withdrawal.setWithdrawalId(event.getSource()); withdrawal.setWithdrawalStatus(TBaseUtil.unionFieldToEnum(change.getStatusChanged(), WithdrawalStatus.class)); - + if (change.getStatusChanged().isSetFailed()) { + if (change.getStatusChanged().getFailed().isSetFailure()) { + withdrawal.setWithdrawalStatusFailedFailureJson(JsonUtil.tBaseToJsonString(change.getStatusChanged().getFailed())); + } + } withdrawalDao.updateNotCurrent(event.getSource()); long id = withdrawalDao.save(withdrawal); diff --git a/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/withdrawal_session/WithdrawalSessionCreatedHandler.java b/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/withdrawal_session/WithdrawalSessionCreatedHandler.java index 4a467bc..f8f1443 100644 --- a/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/withdrawal_session/WithdrawalSessionCreatedHandler.java +++ b/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/withdrawal_session/WithdrawalSessionCreatedHandler.java @@ -3,7 +3,7 @@ package com.rbkmoney.newway.poller.event_stock.impl.withdrawal_session; import com.rbkmoney.fistful.base.BankCard; import com.rbkmoney.fistful.base.Cash; import com.rbkmoney.fistful.base.CryptoWallet; -import com.rbkmoney.fistful.destination.Resource; +import com.rbkmoney.fistful.base.Resource; import com.rbkmoney.fistful.withdrawal_session.Change; import com.rbkmoney.fistful.withdrawal_session.Session; import com.rbkmoney.fistful.withdrawal_session.SinkEvent; @@ -55,9 +55,8 @@ public class WithdrawalSessionCreatedHandler extends AbstractWithdrawalSessionHa Withdrawal withdrawal = session.getWithdrawal(); withdrawalSession.setWithdrawalId(withdrawal.getId()); - withdrawalSession.setDestinationName(withdrawal.getDestination().getName()); - Resource resource = withdrawal.getDestination().getResource(); + Resource resource = withdrawal.getDestinationResource(); withdrawalSession.setResourceType(TBaseUtil.unionFieldToEnum(resource, DestinationResourceType.class)); if (resource.isSetBankCard()) { BankCard bankCard = resource.getBankCard(); @@ -65,10 +64,20 @@ public class WithdrawalSessionCreatedHandler extends AbstractWithdrawalSessionHa withdrawalSession.setDestinationCardBin(bankCard.getBin()); withdrawalSession.setDestinationCardMaskedPan(bankCard.getMaskedPan()); withdrawalSession.setDestinationCardPaymentSystem(BankCardPaymentSystem.valueOf(bankCard.getPaymentSystem().name())); + withdrawalSession.setResourceBankCardBankName(bankCard.getBankName()); + if (bankCard.isSetIssuerCountry()) { + withdrawalSession.setResourceBankCardIssuerCountry(bankCard.getIssuerCountry().toString()); + } + if (bankCard.isSetCardType()) { + withdrawalSession.setResourceBankCardType(bankCard.getCardType().toString()); + } } else if (resource.isSetCryptoWallet()) { CryptoWallet cryptoWallet = resource.getCryptoWallet(); withdrawalSession.setResourceCryptoWalletId(cryptoWallet.getId()); withdrawalSession.setResourceCryptoWalletType(cryptoWallet.getCurrency().toString()); + if (cryptoWallet.isSetData()) { + withdrawalSession.setResourceCryptoWalletData(cryptoWallet.getData().getSetField().getFieldName()); + } } Cash cash = withdrawal.getCash(); diff --git a/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/withdrawal_session/WithdrawalSessionFinishedHandler.java b/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/withdrawal_session/WithdrawalSessionFinishedHandler.java index fb00c9f..307f1a5 100644 --- a/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/withdrawal_session/WithdrawalSessionFinishedHandler.java +++ b/src/main/java/com/rbkmoney/newway/poller/event_stock/impl/withdrawal_session/WithdrawalSessionFinishedHandler.java @@ -58,6 +58,10 @@ public class WithdrawalSessionFinishedHandler extends AbstractWithdrawalSessionH withdrawalSession.setTranInfoTimestamp(TypeUtil.stringToLocalDateTime(trxInfo.getTimestamp())); } withdrawalSession.setTranInfoJson(JsonUtil.objectToJsonString(trxInfo.getExtra())); + if (trxInfo.isSetAdditionalInfo()) { + withdrawalSession.setTranAdditionalInfoRrn(trxInfo.getAdditionalInfo().getRrn()); + withdrawalSession.setTranAdditionalInfoJson(JsonUtil.tBaseToJsonString(trxInfo.getAdditionalInfo())); + } } withdrawalSessionDao.updateNotCurrent(event.getSource()); diff --git a/src/main/resources/db/migration/V34__1.0.52_update_fistful_proto.sql b/src/main/resources/db/migration/V34__1.0.52_update_fistful_proto.sql new file mode 100644 index 0000000..4abb955 --- /dev/null +++ b/src/main/resources/db/migration/V34__1.0.52_update_fistful_proto.sql @@ -0,0 +1,16 @@ +alter table nw.destination add column resource_crypto_wallet_data character varying; +alter table nw.destination add column resource_bank_card_type character varying; +alter table nw.destination add column resource_bank_card_issuer_country character varying; +alter table nw.destination add column resource_bank_card_bank_name character varying; + +alter table nw.withdrawal_session add column resource_crypto_wallet_data character varying; +alter table nw.withdrawal_session add column resource_bank_card_type character varying; +alter table nw.withdrawal_session add column resource_bank_card_issuer_country character varying; +alter table nw.withdrawal_session add column resource_bank_card_bank_name character varying; +alter table nw.withdrawal_session add column tran_additional_info character varying; +alter table nw.withdrawal_session add column tran_additional_info_rrn character varying; +alter table nw.withdrawal_session add column tran_additional_info_json character varying; + +alter table nw.withdrawal add column withdrawal_status_failed_failure_json character varying; + +alter table nw.withdrawal_session drop column destination_name;