COOPENOMICS  v1
Кооперативная Экономика
table_marketplace_orders.hpp
См. документацию.
1#pragma once
2
3#include <eosio/asset.hpp>
4#include <eosio/crypto.hpp>
5#include <eosio/eosio.hpp>
6#include <string>
7
8#include "../consts.hpp"
9#include "../core/document.hpp"
10#include "../core/utils.hpp"
11
12namespace Marketplace {
13
14using namespace eosio;
15
33namespace OrderStatus {
34 inline constexpr eosio::name ACTIVE = "active"_n;
35 inline constexpr eosio::name ACCEPTED = "accepted"_n;
36 inline constexpr eosio::name SUPPLY_PREPARED = "supplyprep"_n;
37 inline constexpr eosio::name ACCEPTED_TO_COOP = "acceptcoop"_n;
38 inline constexpr eosio::name READY_TO_RECEIVE = "readyrecv"_n;
39 inline constexpr eosio::name RECEIVED = "received"_n;
40}
41
56namespace OrderPayoutStatus {
57 inline constexpr eosio::name NONE = "none"_n;
58 inline constexpr eosio::name PENDING = "pending"_n;
59 inline constexpr eosio::name COMPLETED = "completed"_n;
60 inline constexpr eosio::name DECLINED = "declined"_n;
61}
62
112struct [[eosio::table, eosio::contract(MARKETPLACE)]] order {
113 uint64_t id;
114 checksum256 hash;
115 eosio::name coopname;
116 eosio::name orderer;
117 eosio::name offerer;
118 checksum256 offer_hash;
119
120 eosio::name delivery_braname;
121 eosio::name accept_braname;
123
124 eosio::asset quantity = asset(0, _unit_piece);
125 eosio::asset actual_quantity = asset(0, _unit_piece);
126 eosio::asset package_size = asset(0, _unit_piece);
127 eosio::asset unit_price = asset(0, _root_govern_symbol);
128 eosio::asset total_cost = asset(0, _root_govern_symbol);
129 eosio::asset fact_cost = asset(0, _root_govern_symbol);
130
131 uint32_t warranty_period_secs = 0;
132 time_point_sec warranty_until = time_point_sec(0);
133
134 eosio::name status = OrderStatus::ACTIVE;
135 checksum256 batch_hash;
136
141
142 eosio::name payout_status = OrderPayoutStatus::NONE;
144
145 uint64_t return_request_id = 0;
146
153 eosio::asset markdown_cost = asset(0, _root_govern_symbol);
154
164 eosio::asset membership_fee = asset(0, _root_govern_symbol);
165
166 // Все timestamp'ы переходов состояний (createorder/accepted/received_to_coop/
167 // ready/received/cancelled) восстанавливаются на бэкенде из blockchain_actions[at]
168 // по соответствующим action'ам — нет смысла держать их в RAM-таблице.
169 // Единственное исключение — warranty_until (выше): нужен on-chain для
170 // submretrn guard `now() < warranty_until` без cross-action lookup.
171
172 uint64_t primary_key() const { return id; }
173 checksum256 by_hash() const { return hash; }
174 uint64_t by_orderer() const { return orderer.value; }
175 uint64_t by_offerer() const { return offerer.value; }
176 uint64_t by_status() const { return status.value; }
177 checksum256 by_batch() const { return batch_hash; }
178 checksum256 by_offer() const { return offer_hash; }
179 uint64_t by_delivery_bra() const { return delivery_braname.value; }
180 uint64_t by_accept_bra() const { return accept_braname.value; }
181};
182
183typedef eosio::multi_index<
184 "orders"_n, order,
185 eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<order, checksum256, &order::by_hash>>,
186 eosio::indexed_by<"byorderer"_n, eosio::const_mem_fun<order, uint64_t, &order::by_orderer>>,
187 eosio::indexed_by<"byofferer"_n, eosio::const_mem_fun<order, uint64_t, &order::by_offerer>>,
188 eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<order, uint64_t, &order::by_status>>,
189 eosio::indexed_by<"bybatch"_n, eosio::const_mem_fun<order, checksum256, &order::by_batch>>,
190 eosio::indexed_by<"byoffer"_n, eosio::const_mem_fun<order, checksum256, &order::by_offer>>,
191 eosio::indexed_by<"bydelivbra"_n, eosio::const_mem_fun<order, uint64_t, &order::by_delivery_bra>>,
192 eosio::indexed_by<"byacceptbra"_n, eosio::const_mem_fun<order, uint64_t, &order::by_accept_bra>>>
194
195} // namespace Marketplace
static constexpr eosio::symbol _unit_piece
Definition: consts.hpp:238
static constexpr eosio::symbol _root_govern_symbol
Definition: consts.hpp:231
contract
Definition: eosio.msig_tests.cpp:977
constexpr eosio::name PENDING
Definition: table_marketplace_orders.hpp:58
constexpr eosio::name NONE
Definition: table_marketplace_orders.hpp:57
constexpr eosio::name COMPLETED
Definition: table_marketplace_orders.hpp:59
constexpr eosio::name DECLINED
Definition: table_marketplace_orders.hpp:60
constexpr eosio::name ACCEPTED_TO_COOP
Definition: table_marketplace_orders.hpp:37
constexpr eosio::name ACTIVE
Definition: table_marketplace_orders.hpp:34
constexpr eosio::name RECEIVED
Definition: table_marketplace_orders.hpp:39
constexpr eosio::name ACCEPTED
Definition: table_marketplace_orders.hpp:35
constexpr eosio::name READY_TO_RECEIVE
Definition: table_marketplace_orders.hpp:38
constexpr eosio::name SUPPLY_PREPARED
Definition: table_marketplace_orders.hpp:36
Canonical helpers контракта marketplace (Story 11.1).
Definition: marketplace.hpp:32
eosio::multi_index< "orders"_n, order, eosio::indexed_by<"byhash"_n, eosio::const_mem_fun< order, checksum256, &order::by_hash > >, eosio::indexed_by<"byorderer"_n, eosio::const_mem_fun< order, uint64_t, &order::by_orderer > >, eosio::indexed_by<"byofferer"_n, eosio::const_mem_fun< order, uint64_t, &order::by_offerer > >, eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun< order, uint64_t, &order::by_status > >, eosio::indexed_by<"bybatch"_n, eosio::const_mem_fun< order, checksum256, &order::by_batch > >, eosio::indexed_by<"byoffer"_n, eosio::const_mem_fun< order, checksum256, &order::by_offer > >, eosio::indexed_by<"bydelivbra"_n, eosio::const_mem_fun< order, uint64_t, &order::by_delivery_bra > >, eosio::indexed_by<"byacceptbra"_n, eosio::const_mem_fun< order, uint64_t, &order::by_accept_bra > > > orders_index
Definition: table_marketplace_orders.hpp:193
Definition: eosio.msig.hpp:34
On-chain Order — анкер процесса p.mkt.supply.
Definition: table_marketplace_orders.hpp:112
eosio::name orderer
пайщик-заказчик
Definition: table_marketplace_orders.hpp:116
uint64_t by_offerer() const
Definition: table_marketplace_orders.hpp:175
checksum256 hash
process_hash для p.mkt.supply
Definition: table_marketplace_orders.hpp:114
document2 acceptance_act_signsupp
АПП приёмки — первая подпись поставщика (signsupp)
Definition: table_marketplace_orders.hpp:137
checksum256 batch_hash
opaque ссылка на consolidated request (off-chain)
Definition: table_marketplace_orders.hpp:135
eosio::name coopname
scope-валидация
Definition: table_marketplace_orders.hpp:115
document2 issue_act_signiss2
АПП выдачи — финальная подпись заказчика (signiss2)
Definition: table_marketplace_orders.hpp:140
checksum256 by_batch() const
Definition: table_marketplace_orders.hpp:177
eosio::name current_warehouse_braname
текущая точка хранения; signchair: = accept_braname; signiss1: = delivery_braname (фиксация готовност...
Definition: table_marketplace_orders.hpp:122
uint64_t id
внутренний ID
Definition: table_marketplace_orders.hpp:113
eosio::name offerer
пайщик-поставщик из Offer'а (для acceptorder/declineorder/signsupp guard'а)
Definition: table_marketplace_orders.hpp:117
checksum256 by_offer() const
Definition: table_marketplace_orders.hpp:178
eosio::name accept_braname
КУ приёмки от поставщика (заполняется на signsupp); проверка signchair через Branch::is_user_authoriz...
Definition: table_marketplace_orders.hpp:121
uint64_t by_accept_bra() const
Definition: table_marketplace_orders.hpp:180
std::string payout_decline_reason
Заполняется только при payout_status == DECLINED (текст причины из gateway::outdecline)
Definition: table_marketplace_orders.hpp:143
uint64_t by_orderer() const
Definition: table_marketplace_orders.hpp:174
document2 issue_act_signiss1
АПП выдачи — первая подпись председателя КУ выдачи (signiss1)
Definition: table_marketplace_orders.hpp:139
eosio::name delivery_braname
КУ выдачи (выбран пайщиком на createorder); проверка signiss1/signiss2/p.mkt.return через Branch::is_...
Definition: table_marketplace_orders.hpp:120
uint64_t primary_key() const
Definition: table_marketplace_orders.hpp:172
uint64_t by_delivery_bra() const
Definition: table_marketplace_orders.hpp:179
checksum256 by_hash() const
Definition: table_marketplace_orders.hpp:173
checksum256 offer_hash
ссылка на Offer (off-chain в backend)
Definition: table_marketplace_orders.hpp:118
document2 acceptance_act_signchair
АПП приёмки — финальная подпись председателя приёмного КУ (signchair)
Definition: table_marketplace_orders.hpp:138
uint64_t by_status() const
Definition: table_marketplace_orders.hpp:176
Definition: document_core.hpp:27