COOPENOMICS  v1
Кооперативная Экономика
table_marketplace_orders.hpp
См. документацию.
1#pragma once
2
3
4#include "../core/ram_payer.hpp"
5#include <eosio/asset.hpp>
6#include <eosio/crypto.hpp>
7#include <eosio/binary_extension.hpp>
8#include <eosio/eosio.hpp>
9#include <string>
10
11#include "../consts.hpp"
12#include "../core/document.hpp"
13#include "../core/utils.hpp"
14
15namespace Marketplace {
16
17using namespace eosio;
18
42namespace OrderStatus {
43 inline constexpr eosio::name ACTIVE = "active"_n;
44 inline constexpr eosio::name ACCEPTED = "accepted"_n;
45 inline constexpr eosio::name SUPPLY_PREPARED = "supplyprep"_n;
46 inline constexpr eosio::name ACCEPTED_TO_COOP = "acceptcoop"_n;
47 inline constexpr eosio::name READY_TO_RECEIVE = "readyrecv"_n;
48 inline constexpr eosio::name ISSUE_PENDING = "issuepend"_n;
49 inline constexpr eosio::name ISSUE_AUTHORIZED = "issueauth"_n;
50 inline constexpr eosio::name ISSUE_ACT1 = "issueact1"_n;
51 inline constexpr eosio::name RECEIVED = "received"_n;
52 inline constexpr eosio::name REFUSED = "refused"_n;
53}
54
69namespace OrderPayoutStatus {
70 inline constexpr eosio::name NONE = "none"_n;
71 inline constexpr eosio::name PENDING = "pending"_n;
72 inline constexpr eosio::name COMPLETED = "completed"_n;
73 inline constexpr eosio::name DECLINED = "declined"_n;
74}
75
92 checksum256 order_hash;
93 eosio::asset amount = asset(0, _root_govern_symbol);
94};
95
148struct [[eosio::table, eosio::contract(MARKETPLACE)]] order {
149 uint64_t id;
150 checksum256 hash;
151 eosio::name coopname;
152 eosio::name orderer;
153 eosio::name offerer;
154 checksum256 offer_hash;
155
156 eosio::name delivery_braname;
157 eosio::name accept_braname;
159
160 eosio::asset quantity = asset(0, _unit_piece);
161 eosio::asset actual_quantity = asset(0, _unit_piece);
162 eosio::asset package_size = asset(0, _unit_piece);
163 eosio::asset unit_price = asset(0, _root_govern_symbol);
164 eosio::asset total_cost = asset(0, _root_govern_symbol);
165 eosio::asset fact_cost = asset(0, _root_govern_symbol);
166
167 uint32_t warranty_period_secs = 0;
168 time_point_sec warranty_until = time_point_sec(0);
169
170 eosio::name status = OrderStatus::ACTIVE;
171 checksum256 batch_hash;
172
175 // Раскладка совместима со строками членской модели на живых стендах: два
176 // слота document2 прежних актов выдачи (issue_act_signiss1/2) заняты актом
177 // 1115 (первая и закрывающая подписи), а заявление и протокол добавлены в
178 // хвост как binary_extension — старые строки читаются без миграции.
181
182 eosio::name payout_status = OrderPayoutStatus::NONE;
184
185 uint64_t return_request_id = 0;
186
193 eosio::asset markdown_cost = asset(0, _root_govern_symbol);
194
204 eosio::asset membership_fee = asset(0, _root_govern_symbol);
205
209 eosio::binary_extension<document2> issue_statement;
212 eosio::binary_extension<document2> issue_protocol;
217 eosio::binary_extension<eosio::asset> payout_withheld;
224 eosio::binary_extension<eosio::asset> accepted_cost;
225
226 // Все timestamp'ы переходов состояний (createorder/accepted/received_to_coop/
227 // ready/received/cancelled) восстанавливаются на бэкенде из blockchain_actions[at]
228 // по соответствующим action'ам — нет смысла держать их в RAM-таблице.
229 // Единственное исключение — warranty_until (выше): нужен on-chain для
230 // submretrn guard `now() < warranty_until` без cross-action lookup.
231
232 uint64_t primary_key() const { return id; }
233 checksum256 by_hash() const { return hash; }
234 uint64_t by_orderer() const { return orderer.value; }
235 uint64_t by_offerer() const { return offerer.value; }
236 uint64_t by_status() const { return status.value; }
237 checksum256 by_batch() const { return batch_hash; }
238 checksum256 by_offer() const { return offer_hash; }
239 uint64_t by_delivery_bra() const { return delivery_braname.value; }
240 uint64_t by_accept_bra() const { return accept_braname.value; }
241};
242
243typedef eosio::multi_index<
244 "orders"_n, order,
245 eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<order, checksum256, &order::by_hash>>,
246 eosio::indexed_by<"byorderer"_n, eosio::const_mem_fun<order, uint64_t, &order::by_orderer>>,
247 eosio::indexed_by<"byofferer"_n, eosio::const_mem_fun<order, uint64_t, &order::by_offerer>>,
248 eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<order, uint64_t, &order::by_status>>,
249 eosio::indexed_by<"bybatch"_n, eosio::const_mem_fun<order, checksum256, &order::by_batch>>,
250 eosio::indexed_by<"byoffer"_n, eosio::const_mem_fun<order, checksum256, &order::by_offer>>,
251 eosio::indexed_by<"bydelivbra"_n, eosio::const_mem_fun<order, uint64_t, &order::by_delivery_bra>>,
252 eosio::indexed_by<"byacceptbra"_n, eosio::const_mem_fun<order, uint64_t, &order::by_accept_bra>>>
254
255} // namespace Marketplace
256
257// Плательщик за оперативную память строк таблицы — правило в lib/core/ram_payer.hpp.
static constexpr eosio::symbol _unit_piece
Definition: consts.hpp:243
static constexpr eosio::symbol _root_govern_symbol
Definition: consts.hpp:236
contract
Definition: eosio.msig_tests.cpp:977
constexpr eosio::name PENDING
Definition: table_marketplace_orders.hpp:71
constexpr eosio::name NONE
Definition: table_marketplace_orders.hpp:70
constexpr eosio::name COMPLETED
Definition: table_marketplace_orders.hpp:72
constexpr eosio::name DECLINED
Definition: table_marketplace_orders.hpp:73
constexpr eosio::name ACCEPTED_TO_COOP
Definition: table_marketplace_orders.hpp:46
constexpr eosio::name ACTIVE
Definition: table_marketplace_orders.hpp:43
constexpr eosio::name REFUSED
пайщик отказался после приёмки, долг поставщику ещё не погашен: запись ждёт payconfirm и стирается им
Definition: table_marketplace_orders.hpp:52
constexpr eosio::name RECEIVED
Definition: table_marketplace_orders.hpp:51
constexpr eosio::name ACCEPTED
Definition: table_marketplace_orders.hpp:44
constexpr eosio::name ISSUE_ACT1
акт подписан заказчиком, ждём закрывающую подпись председателя участка
Definition: table_marketplace_orders.hpp:50
constexpr eosio::name READY_TO_RECEIVE
Definition: table_marketplace_orders.hpp:47
constexpr eosio::name SUPPLY_PREPARED
Definition: table_marketplace_orders.hpp:45
constexpr eosio::name ISSUE_PENDING
заявление о возврате паевого взноса имуществом подано, ждём решение совета
Definition: table_marketplace_orders.hpp:48
constexpr eosio::name ISSUE_AUTHORIZED
протокол совета получен, ждём первую подпись акта заказчиком
Definition: table_marketplace_orders.hpp:49
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:253
Definition: eosio.msig.hpp:34
Адресат перевода по Заявлению 1110: заказ и его доля перевода.
Definition: table_marketplace_orders.hpp:91
eosio::asset amount
Членская часть перевода под этот заказ
Definition: table_marketplace_orders.hpp:93
checksum256 order_hash
Хэш заказа, который оплачивает эта часть перевода
Definition: table_marketplace_orders.hpp:92
On-chain Order — анкер процесса p.mkt.supply.
Definition: table_marketplace_orders.hpp:148
eosio::name orderer
пайщик-заказчик
Definition: table_marketplace_orders.hpp:152
uint64_t by_offerer() const
Definition: table_marketplace_orders.hpp:235
eosio::binary_extension< eosio::asset > payout_withheld
Definition: table_marketplace_orders.hpp:217
checksum256 hash
process_hash для p.mkt.supply
Definition: table_marketplace_orders.hpp:150
document2 acceptance_act_signsupp
АПП приёмки — первая подпись поставщика (signsupp)
Definition: table_marketplace_orders.hpp:173
checksum256 batch_hash
opaque ссылка на consolidated request (off-chain)
Definition: table_marketplace_orders.hpp:171
eosio::binary_extension< eosio::asset > accepted_cost
Definition: table_marketplace_orders.hpp:224
eosio::name coopname
scope-валидация
Definition: table_marketplace_orders.hpp:151
checksum256 by_batch() const
Definition: table_marketplace_orders.hpp:237
eosio::binary_extension< document2 > issue_statement
Definition: table_marketplace_orders.hpp:209
eosio::binary_extension< document2 > issue_protocol
Definition: table_marketplace_orders.hpp:212
eosio::name current_warehouse_braname
текущая точка хранения; signchair: = accept_braname; readyissue: = delivery_braname (фиксация готовно...
Definition: table_marketplace_orders.hpp:158
uint64_t id
внутренний ID
Definition: table_marketplace_orders.hpp:149
eosio::name offerer
пайщик-поставщик из Offer'а (для acceptorder/declineorder/signsupp guard'а)
Definition: table_marketplace_orders.hpp:153
checksum256 by_offer() const
Definition: table_marketplace_orders.hpp:238
eosio::name accept_braname
КУ приёмки от поставщика (заполняется на signsupp); проверка signchair через Branch::is_user_authoriz...
Definition: table_marketplace_orders.hpp:157
uint64_t by_accept_bra() const
Definition: table_marketplace_orders.hpp:240
std::string payout_decline_reason
Заполняется только при payout_status == DECLINED (текст причины из gateway::outdecline)
Definition: table_marketplace_orders.hpp:183
uint64_t by_orderer() const
Definition: table_marketplace_orders.hpp:234
document2 issue_act2
Акт приёма-передачи (1115) — закрывающая подпись председателя участка выдачи (issueact2); слот прежне...
Definition: table_marketplace_orders.hpp:180
document2 issue_act1
Акт приёма-передачи (1115) — первая подпись заказчика (issueact1); слот прежнего issue_act_signiss1.
Definition: table_marketplace_orders.hpp:179
eosio::name delivery_braname
КУ выдачи (выбран пайщиком на createorder); проверка readyissue/issueact2/p.mkt.return через Branch::...
Definition: table_marketplace_orders.hpp:156
uint64_t primary_key() const
Definition: table_marketplace_orders.hpp:232
uint64_t by_delivery_bra() const
Definition: table_marketplace_orders.hpp:239
checksum256 by_hash() const
Definition: table_marketplace_orders.hpp:233
checksum256 offer_hash
ссылка на Offer (off-chain в backend)
Definition: table_marketplace_orders.hpp:154
document2 acceptance_act_signchair
АПП приёмки — финальная подпись председателя приёмного КУ (signchair)
Definition: table_marketplace_orders.hpp:174
uint64_t by_status() const
Definition: table_marketplace_orders.hpp:236
Definition: table_registrator_orgs.hpp:17
Definition: document_core.hpp:27
RAM_PAYER_CLASS(Marketplace::order, cooperative)