Updated according to fistful-proto (#73)

This commit is contained in:
Inal Arsanukaev 2019-08-27 13:33:08 +03:00 committed by GitHub
parent 4a449ae4da
commit 766a852f48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 6 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>newway</artifactId>
<version>1.0.51-SNAPSHOT</version>
<version>1.0.52-SNAPSHOT</version>
<packaging>jar</packaging>
<name>newway</name>
@ -32,7 +32,7 @@
<local.pg.url>jdbc:postgresql://localhost:5432/newway</local.pg.url>
<local.pg.port>5432</local.pg.port>
<damsel.version>1.320-95ff602</damsel.version>
<fistful-proto.version>1.27-e2c29cb</fistful-proto.version>
<fistful-proto.version>1.36-683822a</fistful-proto.version>
<sonar.jacoco.reportPath>target/sites/jacoco/jacoco.exec</sonar.jacoco.reportPath>
<sonar.cobertura.reportPath>target/site/cobertura/coverage.xml</sonar.cobertura.reportPath>
</properties>

View File

@ -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());

View File

@ -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);

View File

@ -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();

View File

@ -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());

View File

@ -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;