diff --git a/clickhouse/docker-entrypoint-initdb.d/init-db.sh b/clickhouse/docker-entrypoint-initdb.d/init-db.sh index 0e23b0c..b863f72 100644 --- a/clickhouse/docker-entrypoint-initdb.d/init-db.sh +++ b/clickhouse/docker-entrypoint-initdb.d/init-db.sh @@ -90,56 +90,17 @@ clickhouse client -n <<-EOSQL CREATE DATABASE IF NOT EXISTS fraud; -DROP TABLE IF EXISTS fraud.fraud_payment; + DROP TABLE IF EXISTS fraud.fraud_payment; -create table fraud.fraud_payment ( + create table fraud.fraud_payment ( -timestamp Date, - id String, - eventTime UInt64, - eventTimeHour UInt64, + timestamp Date, + id String, + eventTime UInt64, + eventTimeHour UInt64, - fraudType String, - comment String, - - email String, - ip String, - fingerprint String, - - bin String, - maskedPan String, - cardToken String, - paymentSystem String, - paymentTool String, - - terminal String, - providerId String, - bankCountry String, - - partyId String, - shopId String, - - amount UInt64, - currency String, - - status Enum8('pending' = 1, 'processed' = 2, 'captured' = 3, 'cancelled' = 4, 'failed' = 5), - errorReason String, - errorCode String, - paymentCountry String -) ENGINE = MergeTree() -PARTITION BY toYYYYMM (timestamp) -ORDER BY (eventTimeHour, partyId, shopId, paymentTool, status, currency, providerId, fingerprint, cardToken, eventTime, id); - - - DROP TABLE IF EXISTS fraud.refund; - - create table fraud.refund - ( - timestamp Date, - eventTime UInt64, - eventTimeHour UInt64, - - id String, + fraudType String, + comment String, email String, ip String, @@ -161,13 +122,13 @@ ORDER BY (eventTimeHour, partyId, shopId, paymentTool, status, currency, provide amount UInt64, currency String, - status Enum8('pending' = 1, 'succeeded' = 2, 'failed' = 3), + status Enum8('pending' = 1, 'processed' = 2, 'captured' = 3, 'cancelled' = 4, 'failed' = 5), errorReason String, errorCode String, - paymentId String - ) ENGINE = ReplacingMergeTree() + paymentCountry String + ) ENGINE = MergeTree() PARTITION BY toYYYYMM (timestamp) - ORDER BY (eventTimeHour, partyId, shopId, status, currency, providerId, fingerprint, cardToken, id, paymentId); + ORDER BY (eventTimeHour, partyId, shopId, paymentTool, status, currency, providerId, fingerprint, cardToken, eventTime, id); DROP TABLE IF EXISTS fraud.payment; @@ -207,45 +168,6 @@ ORDER BY (eventTimeHour, partyId, shopId, paymentTool, status, currency, provide PARTITION BY toYYYYMM (timestamp) ORDER BY (eventTimeHour, partyId, shopId, paymentTool, status, currency, providerId, fingerprint, cardToken, id); - DROP TABLE IF EXISTS fraud.chargeback; - - create table fraud.chargeback - ( - timestamp Date, - eventTime UInt64, - eventTimeHour UInt64, - - id String, - - email String, - ip String, - fingerprint String, - - bin String, - maskedPan String, - cardToken String, - paymentSystem String, - paymentTool String, - - terminal String, - providerId String, - bankCountry String, - - partyId String, - shopId String, - - amount UInt64, - currency String, - - status Enum8('accepted' = 1, 'rejected' = 2, 'cancelled' = 3), - - category Enum8('fraud' = 1, 'dispute' = 2, 'authorisation' = 3, 'processing_error' = 4), - chargebackCode String, - paymentId String - ) ENGINE = ReplacingMergeTree() - PARTITION BY toYYYYMM (timestamp) - ORDER BY (eventTimeHour, partyId, shopId, category, status, currency, providerId, fingerprint, cardToken, id, paymentId); - DROP TABLE IF EXISTS fraud.refund; create table fraud.refund @@ -378,4 +300,306 @@ ORDER BY (eventTimeHour, partyId, shopId, paymentTool, status, currency, provide ALTER TABLE fraud.payment ADD COLUMN mobile UInt8; ALTER TABLE fraud.payment ADD COLUMN recurrent UInt8; + + DROP TABLE IF EXISTS fraud.withdrawal; + + create table fraud.withdrawal + ( + timestamp Date, + eventTime UInt64, + eventTimeHour UInt64, + + id String, + + amount UInt64, + currency String, + + bin String, + maskedPan String, + cardToken String, + paymentSystem String, + paymentTool String, + bankName String, + cardHolderName String, + issuerCountry String, + + cryptoWalletId String, + cryptoWalletCurrency String, + + terminal String, + providerId String, + bankCountry String, + + identityId String, + accountId String, + accountCurrency String, + + status Enum8('pending' = 1, 'succeeded' = 2, 'failed' = 3), + errorReason String, + errorCode String + + ) ENGINE = ReplacingMergeTree() + PARTITION BY toYYYYMM (timestamp) + ORDER BY (eventTimeHour, identityId, status, currency, paymentSystem, providerId, cardToken, id); + + INSERT INTO fraud.payment (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, + currency, status, errorReason, id, ip, bin, maskedPan, paymentTool, cardToken) + VALUES + ('2020-05-06', 1588761208,1588759200000, 'group_1','2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 10500, 'RUB', 'processed', '','1DkraVdGJfs.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05'); + INSERT INTO fraud.payment (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, + currency, status, errorReason, id, ip, bin, maskedPan, paymentTool, cardToken) + VALUES + ('2020-05-06', 1588761208,1588759200000, 'group_1','2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 10500, 'RUB', 'captured', '','1DkraVdGJfs.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05'); + INSERT INTO fraud.payment (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, + currency, status, errorReason, id, ip, bin, maskedPan, paymentTool, cardToken) + VALUES + ('2020-05-06', 1588761208,1588759200000, 'group_1','2035728', 'email_2', '5bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'processed', '','1DkraVdGJfs.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05'); + INSERT INTO fraud.payment (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, + currency, status, errorReason, id, ip, bin, maskedPan, paymentTool, cardToken) + VALUES + ('2020-05-06', 1588761208,1588759200000, 'group_1','2035728', 'email_2', '5bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'captured', '','1DkraVdGJfs.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05'); + INSERT INTO fraud.payment (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, + currency, status, errorReason, id, ip, bin, maskedPan, paymentTool, cardToken) + VALUES + ('2020-05-06', 1588761208,1588759200000, 'partyId_2','2035728', 'email_2', '4bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'processed', '','1DkraVdGJfs.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05'); + INSERT INTO fraud.payment (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, + currency, status, errorReason, id, ip, bin, maskedPan, paymentTool, cardToken) + VALUES + ('2020-05-06', 1588761208,1588759200000, 'partyId_2','2035728', 'email_2', '4bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'captured', '','1DkraVdGJfs.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05'); + INSERT INTO fraud.payment (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, + currency, status, errorReason, id, ip, bin, maskedPan, paymentTool, cardToken) + VALUES + ('2019-12-05', 1587761208,1587759200000, 'group_1','2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'processed', '','1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05'); + INSERT INTO fraud.payment (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, + currency, status, errorReason, id, ip, bin, maskedPan, paymentTool, cardToken) + VALUES + ('2019-12-05', 1587761208,1587759200000, 'group_1','2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'captured', '','1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05'); + INSERT INTO fraud.payment (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, + currency, status, errorReason, id, ip, bin, maskedPan, paymentTool, cardToken) + VALUES + ('2019-12-05', 1587761208,1587759200000, 'group_1','2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'processed', '','1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05'); + INSERT INTO fraud.payment (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, + currency, status, errorReason, id, ip, bin, maskedPan, paymentTool, cardToken) + VALUES + ('2019-12-05', 1587761208,1587759200000, 'group_1','2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'captured', '','1DkratTwbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05'); + INSERT INTO fraud.payment (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, + currency, status, errorReason, id, ip, bin, maskedPan, paymentTool, cardToken) + VALUES + ('2019-12-05', 1587761208,1587759200000, 'group_1','2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'captured', '','1DkratTrpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05'); + INSERT INTO fraud.payment (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, + currency, status, errorReason, id, ip, bin, maskedPan, paymentTool, cardToken) + VALUES + ('2019-12-05', 1587761208,1587759200000, 'group_1','2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'captured', '','1DkratTwbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05'); + INSERT INTO fraud.payment (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, + currency, status, errorReason, id, ip, bin, maskedPan, paymentTool, cardToken) + VALUES + ('2019-12-05', 1587761208,1587759200000, 'group_1','2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'captured', '','1Dkragfbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05'); + + INSERT INTO fraud.chargeback + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, paymentId) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 10500, 'RUB', 'rejected', '1DkraVdGJbs.1', '204.26.61.110', '666', '3125', 'bank_card','477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '1111vbd'); + INSERT INTO fraud.chargeback + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, paymentId) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 10500, 'RUB', 'rejected', '1DkraVdGJfs.1', '204.26.61.110', '666', '3125', 'bank_card','477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '1111vba'); + INSERT INTO fraud.chargeback + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, paymentId) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email_2', '5bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'rejected', '1VMI0gIoAy0.2', '204.26.61.110', '666', '3125', 'bank_card','477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '1111vbc'); + INSERT INTO fraud.chargeback + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, paymentId) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email_2', '5bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'cancelled', '1VMI3GwdR5s.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '1111vbf'); + INSERT INTO fraud.chargeback + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, paymentId) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'partyId_2', '2035728', 'email_2', '4bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'accepted', '1DkraVdGJfr.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '1111vbe'); + INSERT INTO fraud.chargeback + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, paymentId) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'partyId_2', '2035729', 'email_2', '4bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'accepted', '1DkraVdGJfs.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '1111vbp'); + INSERT INTO fraud.chargeback + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, paymentId) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'cancelled', '1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '1111vbdss'); + INSERT INTO fraud.chargeback + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, paymentId) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'cancelled', '1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '1111vbz'); + INSERT INTO fraud.chargeback + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, paymentId) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'accepted', '1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '1111vbuc'); + INSERT INTO fraud.chargeback + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, paymentId) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'rejected', '1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '1111vbtt'); + + INSERT INTO fraud.fraud_payment + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, fraudType, comment) + VALUES ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 10500, 'RUB', 'captured', '1DkraVdGJbs.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', 'fraud', ''); + INSERT INTO fraud.fraud_payment + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, fraudType, comment) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 10500, 'RUB', 'captured', '1DkraVdGJfs.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', 'fraud', ''); + INSERT INTO fraud.fraud_payment + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, fraudType, comment) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email_2', '5bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'captured', '1VMI0gIoAy0.2', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', 'fraud', 'comment'); + INSERT INTO fraud.fraud_payment + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, fraudType, comment) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email_2', '5bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'cancelled', '1VMI3GwdR5s.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', 'fraud', ''); + INSERT INTO fraud.fraud_payment + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, fraudType, comment) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'partyId_2', '2035728', 'email_2', '4bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'processed', '1DkraVdGJfr.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', 'fraud', ''); + INSERT INTO fraud.fraud_payment + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, fraudType, comment) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'partyId_2', '2035729', 'email_2', '4bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'processed', '1DkraVdGJfs.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', 'fraud', ''); + INSERT INTO fraud.fraud_payment + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, fraudType, comment) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'processed', '1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', 'fraud', 'comment'); + INSERT INTO fraud.fraud_payment + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, fraudType, comment) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'cancelled', '1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', 'fraud', ''); + INSERT INTO fraud.fraud_payment + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, fraudType, comment) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'pending', '1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', 'fraud', ''); + INSERT INTO fraud.fraud_payment + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, fraudType, comment) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'partyId_2', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'failed', '1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', 'fraud', ''); + + INSERT INTO fraud.events_unique + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, mobile, paymentId, + ip, bin, maskedPan, cardToken, resultStatus, checkedRule, checkedTemplate, bankCountry, invoiceId, bankName) + VALUES ('2020-06-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 10500, 'RUB', 1, '2PkraBdGJbs.1', '204.26.61.110', '666', '3125', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'ACCEPT', '', 'RULE_NOT_CHECKED', 'RUS', '1111vbd', 'SBER'); + INSERT INTO fraud.events_unique + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, mobile, paymentId, + ip, bin, maskedPan, cardToken, resultStatus, checkedRule, checkedTemplate, bankCountry, invoiceId, bankName) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 10500, 'RUB', 1, '1DkraVdGJbs.1', '204.26.61.110', '666', '3125', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'ACCEPT', '', 'RULE_NOT_CHECKED', 'RUS', '1111vbd', 'SBER'); + INSERT INTO fraud.events_unique + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, mobile, paymentId, + ip, bin, maskedPan, cardToken, resultStatus, checkedRule, checkedTemplate, bankCountry, invoiceId, bankName) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 10500, 'RUB', 0, '1DkraVdGJfs.1', '204.26.61.110', '666', '3125', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'ACCEPT', '', 'RULE_NOT_CHECKED', 'RUS', '1111vba', 'SBER'); + INSERT INTO fraud.events_unique + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, mobile, paymentId, + ip, bin, maskedPan, cardToken, resultStatus, checkedRule, checkedTemplate, bankCountry, invoiceId, bankName) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email_2', '5bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 1, '1VMI0gIoAy0.2', '204.26.61.110', '666', '3125', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'ACCEPT', '', 'RULE_NOT_CHECKED', 'RUS', '1111vbc', 'SBER'); + INSERT INTO fraud.events_unique + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, mobile, paymentId, + ip, bin, maskedPan, cardToken, resultStatus, checkedRule, checkedTemplate, bankCountry, invoiceId, bankName) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email_2', '5bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 1, '1VMI3GwdR5s.1', '204.26.61.110', '666', '3125', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'ACCEPT', '3DS_RULE', '3DS_TEMPLATE', 'RUS', '1111vbf', 'SBER'); + INSERT INTO fraud.events_unique + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, mobile, paymentId, + ip, bin, maskedPan, cardToken, resultStatus, checkedRule, checkedTemplate, bankCountry, invoiceId, bankName) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'partyId_2', '2035728', 'email_2', '4bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 1, '1DkraVdGJfr.1', '204.26.61.110', '666', '3125', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'ACCEPT_AND_NOTIFY', 'count', 'COUNT_TEMPLATE', 'RUS', '1111vbe', 'SBER'); + INSERT INTO fraud.events_unique + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, mobile, paymentId, + ip, bin, maskedPan, cardToken, resultStatus, checkedRule, checkedTemplate, bankCountry, invoiceId, bankName) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'partyId_2', '2035729', 'email_2', '4bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 0, '1DkraVdGJfb.1', '204.26.61.110', '666', '3125', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'ACCEPT_AND_NOTIFY', 'sum', 'SUM_TEMPLATE', 'RUS', '1111vbp', 'SBER'); + INSERT INTO fraud.events_unique + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, mobile, paymentId, + ip, bin, maskedPan, cardToken, resultStatus, checkedRule, checkedTemplate, bankCountry, invoiceId, bankName) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 0, '1DkratTHbpg.1', '204.26.61.110', '666', '3125', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'NORMAL', '', 'RULE_NOT_CHECKED', 'RUS', '1111vbdss', 'SBER'); + INSERT INTO fraud.events_unique + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, mobile, paymentId, + ip, bin, maskedPan, cardToken, resultStatus, checkedRule, checkedTemplate, bankCountry, invoiceId, bankName) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 1, '1DkratTHbpg.1', '204.26.61.110', '666', '3125', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'NORMAL', '', 'RULE_NOT_CHECKED', 'RUS', '1111vbz', 'SBER'); + INSERT INTO fraud.events_unique + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, mobile, paymentId, + ip, bin, maskedPan, cardToken, resultStatus, checkedRule, checkedTemplate, bankCountry, invoiceId, bankName) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'EUR', 0, '1DkratTHbpg.1', '204.26.61.110', '666', '3125', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'NORMAL', 'COUNTRY_RULE', 'COUNTRY_TEMPLATE', 'NED', '1111vbuc', 'SBER'); + INSERT INTO fraud.events_unique + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, mobile, paymentId, + ip, bin, maskedPan, cardToken, resultStatus, checkedRule, checkedTemplate, bankCountry, invoiceId, bankName) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 0, '1DkratTHbpg.1', '204.26.61.110', '666', '3125', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'NOTIFY', '3DS', '3DS_TEMPLATE', 'RUS', '1111vbtt', 'SBER'); + + INSERT INTO fraud.refund + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, errorReason, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, errorCode, paymentId) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 10500, 'RUB', 'succeeded', '', '1DkraVdGJbs.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '', '1111vbd'); + INSERT INTO fraud.refund + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, errorReason, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, errorCode, paymentId) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 10500, 'RUB', 'failed', '', '1DkraVdGJfs.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '', '1111vba'); + INSERT INTO fraud.refund + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, errorReason, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, errorCode, paymentId) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email_2', '5bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'succeeded', '', '1VMI0gIoAy0.2', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '', '1111vbc'); + INSERT INTO fraud.refund + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, errorReason, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, errorCode, paymentId) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'group_1', '2035728', 'email_2', '5bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'failed', '', '1VMI3GwdR5s.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '', '1111vbf'); + INSERT INTO fraud.refund + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, errorReason, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, errorCode, paymentId) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'partyId_2', '2035728', 'email_2', '4bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'succeeded', '', '1DkraVdGJfr.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '', '1111vbe'); + INSERT INTO fraud.refund + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, errorReason, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, errorCode, paymentId) + VALUES + ('2020-05-06', 1588761208, 1588759200000, 'partyId_2', '2035729', 'email_2', '4bef59146f8e4640ab34915f84ddac8b', 50000, 'RUB', 'succeeded', '', '1DkraVdGJfs.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '', '1111vbdxx'); + INSERT INTO fraud.refund + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, errorReason, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, errorCode, paymentId) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'succeeded', '', '1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '', '1111vbdss'); + INSERT INTO fraud.refund + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, errorReason, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, errorCode, paymentId) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'succeeded', '', '1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '', '1111vbz'); + INSERT INTO fraud.refund + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, errorReason, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, errorCode, paymentId) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'failed', '', '1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', '', '1111vbdsuy'); + INSERT INTO fraud.refund + (timestamp, eventTime, eventTimeHour, partyId, shopId, email, fingerprint, amount, currency, status, errorReason, id, + ip, bin, maskedPan, paymentTool, cardToken, paymentSystem, terminal, providerId, bankCountry, errorCode, paymentId) + VALUES + ('2019-12-05', 1587761208, 1587759200000, 'group_1', '2035728', 'email', '4bef59146f8e4640ab34915f84ddac8b', 5000, 'RUB', 'failed', '666', '1DkratTHbpg.1', '204.26.61.110', '666', '3125', 'bank_card', '477bba133c182267fe5f086924abdc5db71f77bfc27f01f2843f2cdc69d89f05', 'VISA', '123', '1', 'RUS', 'Error', '1111vbtt'); + EOSQL diff --git a/docker-compose.yml b/docker-compose.yml index 71a7125..fdc7396 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -74,13 +74,14 @@ services: - "8098:8098" environment: - CLUSTER_NAME=riakts + - WAIT_FOR_ERLANG=500 labels: - "com.basho.riak.cluster.name=riakts" volumes: - /tmp/docker/riak/data:/etc/riak/schemas clickhouse: - image: yandex/clickhouse-server:19.17 + image: yandex/clickhouse-server:19.17.6.36 hostname: clickhouse container_name: clickhouse environment: @@ -91,7 +92,7 @@ services: - 8123:8123 volumes: - ./clickhouse/data:/var/lib/clickhouse - - ./clickhouse/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d + - ./clickhouse/docker-entrypoint-initdb.d/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh grafana: image: grafana/grafana:5.1.0 @@ -134,7 +135,7 @@ services: - 8990:8022 wblist: - image: rbkmoney/wb-list-manager:4e1ef72046a43afaa24b34e4e537eef7e2761c74 + image: rbkmoney/wb-list-manager:9676d131d4b6c2d90c0a230c173c07f1de30f298 hostname: wblist container_name: wblist environment: @@ -152,7 +153,7 @@ services: - 8991:8022 fraudbusters: - image: rbkmoney/fraudbusters:f7f0490d81e715921ed88bc4abce0de2d7f9b507 + image: rbkmoney/fraudbusters:9698d6d519f5d2344bd7486dfe7af31d089cd652-epic hostname: fraudbusters container_name: fraudbusters environment: @@ -163,8 +164,9 @@ services: wb.list.service.url: "http://wblist:8022/v1/wb_list" clickhouse.db.url: "jdbc:clickhouse://clickhouse:8123/default" logging.config: "tmp/logback-test.xml" - clickhouse.db.user: '' - clickhouse.db.password: '' + card-token-pool.filePath: "card-tokens" + clickhouse.db.user: 'user' + clickhouse.db.password: 'password' fraud.management.url: 'fb-management:8080' result.full.check.enabled: 'false' spring.profiles.active: 'full-prod' @@ -176,8 +178,10 @@ services: - kafka-setup ports: - 8999:8022 + - 8111:8089 volumes: - ./log-java:/opt/fraudbusters/tmp + - ./card-tokens:/opt/fraudbusters/card-tokens postgres-fb: container_name: postgres_container @@ -195,7 +199,7 @@ services: restart: unless-stopped fb-management: - image: dr2.rbkmoney.com/rbkmoney/fraudbusters-management:8b906501743e6f6bd74681d59d3efa98f9e78dff + image: dr2.rbkmoney.com/rbkmoney/fraudbusters-management:e83f84b1e9dee2fec1b30f4b287cc8e702eb157a hostname: fb-management container_name: fb-management environment: @@ -208,6 +212,7 @@ services: logging.config: "./tmp/logback-test.xml" management.metrics.binders.jvm.enabled: 'false' service.payment.url: 'http://fraudbusters:8022/fraud_payment/v1/' + service.historical.url: 'http://fraudbusters:8022/historical_data/v1/' spring.profiles.active: 'debug' keycloak.enabled: "true" keycloak.realm: "fraudbusters-realm" @@ -226,7 +231,7 @@ services: - ./log-java:/opt/fraudbusters-management/tmp fraudbusters-ui: - image: dr2.rbkmoney.com/rbkmoney/fraudbusters-ui:75a4e93bceea50feb3a6a9fba84ceceb93ddb278 + image: dr2.rbkmoney.com/rbkmoney/fraudbusters-ui:052ef663e0c86d1521ef213b04355da58b0e5cc9 hostname: fraudbusters-ui container_name: fraudbusters-ui ports: