新增全局流水号

This commit is contained in:
2026-08-25 05:33:01 +08:00
parent 90fd59b647
commit 07c4e969c3
33 changed files with 1176 additions and 73 deletions
+48
View File
@@ -70,6 +70,52 @@ trait DBMigratorPart2 {
) ENGINE=InnoDB {$charset_collate};";
dbDelta($sql_asset_entry);
$sql_financial_flow = "CREATE TABLE {$prefix}aksrt_financial_flow (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
flow_number VARCHAR(32) NOT NULL,
operation_key VARCHAR(191) NOT NULL,
event_type VARCHAR(64) NOT NULL,
ref_type VARCHAR(32) DEFAULT NULL,
ref_key VARCHAR(191) DEFAULT NULL,
order_number VARCHAR(32) DEFAULT NULL,
withdrawal_number VARCHAR(32) DEFAULT NULL,
ledger_transaction_id BIGINT UNSIGNED DEFAULT NULL,
provider_transaction_id VARCHAR(128) DEFAULT NULL,
metadata LONGTEXT DEFAULT NULL,
created_at DATETIME(6) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY uniq_flow_number (flow_number),
UNIQUE KEY uniq_flow_operation (operation_key),
UNIQUE KEY uniq_flow_ledger_transaction (ledger_transaction_id),
KEY idx_flow_event_time (event_type, created_at),
KEY idx_flow_order (order_number),
KEY idx_flow_withdrawal (withdrawal_number),
KEY idx_flow_reference (ref_type, ref_key),
KEY idx_flow_provider_transaction (provider_transaction_id)
) ENGINE=InnoDB {$charset_collate};";
dbDelta($sql_financial_flow);
$sql_financial_flow_entry = "CREATE TABLE {$prefix}aksrt_financial_flow_entry (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
flow_id BIGINT UNSIGNED NOT NULL,
line_no SMALLINT UNSIGNED NOT NULL,
user_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
asset VARCHAR(16) NOT NULL,
direction VARCHAR(8) NOT NULL,
entry_type VARCHAR(32) NOT NULL,
delta_minor BIGINT NOT NULL,
balance_after_minor BIGINT UNSIGNED DEFAULT NULL,
counterparty_user_id BIGINT UNSIGNED DEFAULT NULL,
remark VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY uniq_flow_line (flow_id, line_no),
KEY idx_flow_entry_user (user_id, flow_id),
KEY idx_flow_entry_asset (asset, flow_id),
KEY idx_flow_entry_direction (direction, flow_id),
KEY idx_flow_entry_counterparty (counterparty_user_id, flow_id)
) ENGINE=InnoDB {$charset_collate};";
dbDelta($sql_financial_flow_entry);
// ---------- 2. 签到 ----------
$sql_signin = "CREATE TABLE {$prefix}aksrt_signin_log (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -188,6 +234,7 @@ trait DBMigratorPart2 {
// ---------- 10. 提现台账 ----------
$sql_withdrawal = "CREATE TABLE {$prefix}aksrt_withdrawal (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
withdrawal_number VARCHAR(32) NOT NULL,
user_id BIGINT UNSIGNED NOT NULL,
amount DECIMAL(10,2) NOT NULL DEFAULT 0,
gross_amount DECIMAL(10,2) NOT NULL DEFAULT 0,
@@ -199,6 +246,7 @@ trait DBMigratorPart2 {
processed_at DATETIME DEFAULT NULL,
note TEXT DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY uniq_withdrawal_number (withdrawal_number),
UNIQUE KEY uniq_ledger_transaction (ledger_transaction_id),
KEY idx_user (user_id),
KEY idx_user_created (user_id, created_at),