2016-04-19 15:59:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* Определения предметной области.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
include "base.thrift"
|
|
|
|
|
|
2016-06-16 15:07:06 +00:00
|
|
|
|
namespace java com.rbkmoney.damsel.domain
|
|
|
|
|
namespace erlang domain
|
|
|
|
|
|
2016-06-02 11:38:27 +00:00
|
|
|
|
typedef i32 SchemaRevision
|
|
|
|
|
typedef i64 DataRevision
|
|
|
|
|
|
|
|
|
|
const SchemaRevision SCHEMA_REVISION = 42
|
2016-04-19 15:59:22 +00:00
|
|
|
|
|
|
|
|
|
typedef i32 ObjectID
|
|
|
|
|
|
|
|
|
|
/* Common */
|
|
|
|
|
|
2016-05-24 13:41:25 +00:00
|
|
|
|
// В идеале надо использовать `typedef` над `base.Error`, но сейчас это приводит к ошибкам кодогенератора Go
|
|
|
|
|
struct OperationError {
|
|
|
|
|
/** Уникальный признак ошибки, пригодный для обработки машиной */
|
|
|
|
|
1: required string code;
|
|
|
|
|
/** Описание ошибки, пригодное для восприятия человеком */
|
|
|
|
|
2: optional string description;
|
|
|
|
|
}
|
2016-05-20 16:31:53 +00:00
|
|
|
|
|
2016-04-19 15:59:22 +00:00
|
|
|
|
/** Сумма в минимальных денежных единицах. */
|
|
|
|
|
typedef i64 Amount
|
|
|
|
|
|
|
|
|
|
/** Валюта. */
|
|
|
|
|
struct Currency {
|
|
|
|
|
1: required string name
|
|
|
|
|
2: required string symbolic_code
|
|
|
|
|
3: required i16 numeric_code
|
|
|
|
|
4: required i16 exponent
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct CurrencyRef { 1: required string symbolic_code }
|
|
|
|
|
|
|
|
|
|
struct CurrencyObject {
|
|
|
|
|
1: required CurrencyRef ref
|
2016-04-26 16:01:04 +00:00
|
|
|
|
2: required Currency data
|
2016-04-19 15:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-20 16:31:53 +00:00
|
|
|
|
/** Денежные средства, состоящий из суммы и валюты. */
|
|
|
|
|
struct Funds {
|
2016-05-18 16:27:06 +00:00
|
|
|
|
1: required Amount amount
|
2016-06-02 11:38:27 +00:00
|
|
|
|
2: required Currency currency
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Contractor transactions */
|
|
|
|
|
|
|
|
|
|
struct TransactionInfo {
|
|
|
|
|
1: required string id
|
|
|
|
|
2: optional base.Timestamp timestamp
|
|
|
|
|
3: required base.StringMap extra = []
|
2016-05-18 16:27:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-20 16:31:53 +00:00
|
|
|
|
/* Invoices */
|
|
|
|
|
|
|
|
|
|
typedef base.ID InvoiceID
|
|
|
|
|
typedef base.ID InvoicePaymentID
|
|
|
|
|
typedef binary InvoiceContext
|
2016-06-02 11:38:27 +00:00
|
|
|
|
typedef string PaymentSession
|
2016-07-28 12:01:03 +00:00
|
|
|
|
typedef string Fingerprint
|
|
|
|
|
typedef string IPAddress
|
|
|
|
|
|
2016-05-20 16:31:53 +00:00
|
|
|
|
|
|
|
|
|
struct Invoice {
|
2016-06-16 15:07:06 +00:00
|
|
|
|
1: required InvoiceID id
|
|
|
|
|
2: required base.Timestamp created_at
|
|
|
|
|
3: required DataRevision domain_revision
|
|
|
|
|
4: required InvoiceStatus status
|
|
|
|
|
5: required base.Timestamp due
|
|
|
|
|
6: required string product
|
|
|
|
|
7: optional string description
|
|
|
|
|
8: required Funds cost
|
|
|
|
|
9: required InvoiceContext context
|
2016-05-20 16:31:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-16 15:07:06 +00:00
|
|
|
|
struct InvoiceUnpaid {}
|
|
|
|
|
struct InvoicePaid {}
|
|
|
|
|
struct InvoiceCancelled { 1: required string details }
|
|
|
|
|
struct InvoiceFulfilled { 1: required string details }
|
|
|
|
|
|
|
|
|
|
union InvoiceStatus {
|
|
|
|
|
1: InvoiceUnpaid unpaid
|
|
|
|
|
2: InvoicePaid paid
|
|
|
|
|
3: InvoiceCancelled cancelled
|
|
|
|
|
4: InvoiceFulfilled fulfilled
|
2016-05-20 16:31:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct InvoicePayment {
|
|
|
|
|
1: required InvoicePaymentID id
|
2016-05-26 12:06:07 +00:00
|
|
|
|
2: required base.Timestamp created_at
|
|
|
|
|
3: required InvoicePaymentStatus status
|
2016-06-02 11:38:27 +00:00
|
|
|
|
4: optional TransactionInfo trx
|
2016-06-16 15:07:06 +00:00
|
|
|
|
5: required Payer payer
|
2016-07-28 12:01:03 +00:00
|
|
|
|
8: required Funds cost
|
2016-05-20 16:31:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-16 15:07:06 +00:00
|
|
|
|
struct InvoicePaymentPending {}
|
|
|
|
|
struct InvoicePaymentSucceeded {}
|
|
|
|
|
struct InvoicePaymentFailed { 1: OperationError err }
|
|
|
|
|
|
|
|
|
|
union InvoicePaymentStatus {
|
|
|
|
|
1: InvoicePaymentPending pending
|
|
|
|
|
2: InvoicePaymentSucceeded succeeded
|
|
|
|
|
3: InvoicePaymentFailed failed
|
2016-05-20 16:31:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 12:01:03 +00:00
|
|
|
|
struct Payer {
|
|
|
|
|
1: required PaymentTool payment_tool
|
|
|
|
|
2: required PaymentSession session
|
|
|
|
|
3: required ClientInfo client_info
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ClientInfo {
|
|
|
|
|
1: optional IPAddress ip_address
|
|
|
|
|
2: optional Fingerprint fingerprint
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-05-20 16:31:53 +00:00
|
|
|
|
|
|
|
|
|
/* Cash flows */
|
|
|
|
|
|
2016-04-19 15:59:22 +00:00
|
|
|
|
/** Распределение денежных потоков в системе. */
|
|
|
|
|
struct CashDistribution {
|
|
|
|
|
1: required string name
|
|
|
|
|
2: required string description = ""
|
|
|
|
|
3: required list<CashFlow> flows
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-24 13:41:25 +00:00
|
|
|
|
/** Участник распределения денежных потоков. */
|
|
|
|
|
// Порядок следования `typedef`-`struct` важен для кодогенератора Go
|
|
|
|
|
typedef string CashFlowNode // FIXME: too broad
|
|
|
|
|
|
2016-04-19 15:59:22 +00:00
|
|
|
|
/** Денежный поток между двумя участниками. */
|
|
|
|
|
struct CashFlow {
|
|
|
|
|
1: required CashFlowNode source
|
|
|
|
|
2: required CashFlowNode destination
|
|
|
|
|
3: required CashVolume volume
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Объём денежного потока. */
|
|
|
|
|
union CashVolume {
|
|
|
|
|
1: VolumeFixed fixed
|
|
|
|
|
2: VolumeShare share
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Объём в абсолютных денежных единицах. */
|
|
|
|
|
struct VolumeFixed {
|
|
|
|
|
1: required Amount amount
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Объём в относительных единицах. */
|
|
|
|
|
struct VolumeShare {
|
|
|
|
|
1: required base.Rational parts
|
|
|
|
|
2: optional CashFlowNode of
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct CashDistributionRef { 1: required ObjectID id }
|
|
|
|
|
|
|
|
|
|
struct CashDistributionObject {
|
|
|
|
|
1: required CashDistributionRef ref
|
|
|
|
|
2: required CashDistribution data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Merchants */
|
|
|
|
|
|
|
|
|
|
/** Мерчант. */
|
|
|
|
|
struct Merchant {
|
|
|
|
|
1: optional Contract contract
|
|
|
|
|
2: required list<Shop> shops = []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct MerchantRef { 1: required base.ID id }
|
|
|
|
|
|
|
|
|
|
struct MerchantObject {
|
|
|
|
|
1: required MerchantRef ref
|
|
|
|
|
2: required Merchant data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Contracts */
|
|
|
|
|
|
|
|
|
|
/** Договор с юридическим лицом, в частности с мерчантом. */
|
|
|
|
|
struct Contract {
|
|
|
|
|
1: required string number
|
|
|
|
|
2: required base.Timestamp signed_at
|
2016-04-26 16:01:04 +00:00
|
|
|
|
3: required PartyRef party
|
|
|
|
|
4: required BankAccount account
|
|
|
|
|
5: required list<ContractTerm> terms
|
2016-04-19 15:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 16:01:04 +00:00
|
|
|
|
/** Лицо, выступающее стороной договора. */
|
2016-04-19 15:59:22 +00:00
|
|
|
|
struct Party {
|
2016-04-26 16:01:04 +00:00
|
|
|
|
1: required string registered_name
|
|
|
|
|
2: required LegalEntity legal_entity
|
2016-04-19 15:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Форма юридического лица. */
|
|
|
|
|
union LegalEntity {
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 16:01:04 +00:00
|
|
|
|
struct PartyRef { 1: required ObjectID id }
|
|
|
|
|
|
|
|
|
|
struct PartyObject {
|
|
|
|
|
1: required PartyRef ref
|
|
|
|
|
2: required Party data
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-19 15:59:22 +00:00
|
|
|
|
/** Банковский счёт. */
|
|
|
|
|
struct BankAccount {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Условие договора. */
|
|
|
|
|
union ContractTerm {
|
2016-04-26 16:01:04 +00:00
|
|
|
|
1: CashDistributionTerm cash_distribution
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct CashDistributionTerm {
|
2016-04-19 15:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Shops */
|
|
|
|
|
|
|
|
|
|
/** Магазин мерчанта. */
|
|
|
|
|
struct Shop {
|
|
|
|
|
1: required string name
|
|
|
|
|
2: optional string url
|
|
|
|
|
3: required Category category
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Categories */
|
|
|
|
|
|
|
|
|
|
/** Категория продаваемых товаров или услуг. */
|
|
|
|
|
struct Category {
|
|
|
|
|
1: required string name
|
|
|
|
|
2: required string description = ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct CategoryRef { 1: required ObjectID id }
|
|
|
|
|
|
|
|
|
|
struct CategoryObject {
|
|
|
|
|
1: required CategoryRef ref
|
|
|
|
|
2: required Category data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Payment methods */
|
|
|
|
|
|
2016-04-26 16:01:04 +00:00
|
|
|
|
enum PaymentMethod {
|
|
|
|
|
bank_card = 1 // payment_card?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
union PaymentTool {
|
|
|
|
|
1: BankCard bank_card
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-26 12:06:07 +00:00
|
|
|
|
typedef string Token
|
|
|
|
|
|
|
|
|
|
struct BankCard {
|
|
|
|
|
1: required Token token
|
|
|
|
|
2: required BankCardPaymentSystem payment_system
|
|
|
|
|
3: required string bin
|
|
|
|
|
4: required string masked_pan
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum BankCardPaymentSystem {
|
|
|
|
|
visa
|
|
|
|
|
mastercard
|
|
|
|
|
}
|
2016-04-26 16:01:04 +00:00
|
|
|
|
|
2016-04-19 15:59:22 +00:00
|
|
|
|
/** Способ платежа, категория платёжного средства. */
|
2016-04-26 16:01:04 +00:00
|
|
|
|
struct PaymentMethodDefinition {
|
2016-04-19 15:59:22 +00:00
|
|
|
|
1: required string name
|
|
|
|
|
2: required string description = ""
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 16:01:04 +00:00
|
|
|
|
struct PaymentMethodRef { 1: required PaymentMethod id }
|
2016-04-19 15:59:22 +00:00
|
|
|
|
|
|
|
|
|
struct PaymentMethodObject {
|
|
|
|
|
1: required PaymentMethodRef ref
|
2016-04-26 16:01:04 +00:00
|
|
|
|
2: required PaymentMethodDefinition data
|
2016-04-19 15:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Conditions */
|
|
|
|
|
|
|
|
|
|
/** Условие применимости. */
|
|
|
|
|
struct Condition {
|
|
|
|
|
1: required string name
|
|
|
|
|
2: required string description = ""
|
|
|
|
|
3: required ConditionDef definition
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Варианты условий применимости. */
|
|
|
|
|
union ConditionDef {
|
|
|
|
|
/// basis and combinators
|
|
|
|
|
1: bool value_is
|
|
|
|
|
2: set<ConditionDef> all_of
|
|
|
|
|
3: set<ConditionDef> one_of
|
|
|
|
|
4: ConditionDef is_not
|
|
|
|
|
/// primitives
|
|
|
|
|
5: ConditionRef condition_is
|
|
|
|
|
6: CategoryRef category_is
|
|
|
|
|
7: PaymentMethodRef payment_method_is
|
|
|
|
|
8: FlowRef flow_is
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ConditionRef { 1: required ObjectID id }
|
|
|
|
|
|
|
|
|
|
struct ConditionObject {
|
|
|
|
|
1: required ConditionRef ref
|
|
|
|
|
2: required Condition data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Flows */
|
|
|
|
|
|
|
|
|
|
/** Операция над бизнес-объектом, в частности инвойсом. */
|
|
|
|
|
struct Flow {
|
|
|
|
|
1: required string name
|
|
|
|
|
2: required string description = ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct FlowRef { 1: required ObjectID id }
|
|
|
|
|
|
|
|
|
|
struct FlowObject {
|
|
|
|
|
1: required FlowRef ref
|
|
|
|
|
2: required Flow data
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-02 11:38:27 +00:00
|
|
|
|
/* Proxies */
|
|
|
|
|
|
|
|
|
|
typedef base.StringMap ProxyOptions
|
|
|
|
|
|
|
|
|
|
enum ProxyType {
|
|
|
|
|
provider
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct Proxy {
|
|
|
|
|
1: required ProxyType type
|
|
|
|
|
2: required string url
|
|
|
|
|
3: optional ProxyOptions options
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ProxyRef { 1: required ObjectID id }
|
|
|
|
|
|
|
|
|
|
struct ProxyObject {
|
|
|
|
|
1: required ProxyRef ref
|
|
|
|
|
2: required ProxyObject object
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-19 15:59:22 +00:00
|
|
|
|
/* Merchant prototype */
|
|
|
|
|
|
2016-05-18 16:27:06 +00:00
|
|
|
|
struct MerchantPrototypeRef {}
|
|
|
|
|
|
2016-04-19 15:59:22 +00:00
|
|
|
|
/** Прототип мерчанта по умолчанию. */
|
|
|
|
|
struct MerchantPrototype {
|
2016-05-18 16:27:06 +00:00
|
|
|
|
1: required MerchantPrototypeRef ref
|
|
|
|
|
2: required Merchant data
|
2016-04-19 15:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Type enumerations */
|
|
|
|
|
|
|
|
|
|
union Reference {
|
|
|
|
|
1: CategoryRef category
|
|
|
|
|
2: PaymentMethodRef payment_method
|
|
|
|
|
3: FlowRef flow
|
|
|
|
|
4: CurrencyRef currency
|
|
|
|
|
5: ConditionRef condition
|
|
|
|
|
6: CashDistributionRef cash_distribution
|
2016-04-26 16:01:04 +00:00
|
|
|
|
7: PartyRef party
|
|
|
|
|
8: MerchantPrototypeRef merchant_prototype
|
2016-06-02 11:38:27 +00:00
|
|
|
|
9: ProxyRef proxy
|
2016-04-19 15:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-26 12:06:07 +00:00
|
|
|
|
union DomainObject {
|
2016-04-19 15:59:22 +00:00
|
|
|
|
1: CategoryObject category
|
|
|
|
|
2: PaymentMethodObject payment_method
|
|
|
|
|
3: FlowObject flow
|
|
|
|
|
4: CurrencyObject currency
|
|
|
|
|
5: ConditionObject condition
|
|
|
|
|
6: CashDistributionObject cash_distribution
|
2016-04-26 16:01:04 +00:00
|
|
|
|
7: PartyObject party
|
|
|
|
|
8: MerchantPrototype merchant_prototype
|
2016-06-02 11:38:27 +00:00
|
|
|
|
9: ProxyObject proxy
|
2016-04-19 15:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Domain */
|
|
|
|
|
|
2016-05-26 12:06:07 +00:00
|
|
|
|
typedef map<Reference, DomainObject> Domain
|