feat: add creator income order tracking\n\nCo-Authored-By: Claude Fable 5 <noreply@anthropic.com>

This commit is contained in:
2026-08-07 09:15:42 +08:00
parent 9504463403
commit 450b9f44b9
7 changed files with 217 additions and 301 deletions
+15 -5
View File
@@ -187,19 +187,29 @@ trait DBMigratorPart2 {
) {$charset_collate};";
dbDelta($sql_order);
// ---------- 9. 收益台账 ----------
// ---------- 9. 作者收益台账 ----------
$sql_revenue = "CREATE TABLE {$prefix}aksrt_revenue (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
user_id BIGINT UNSIGNED NOT NULL,
author_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
order_number VARCHAR(32) NOT NULL DEFAULT '',
amount DECIMAL(10,2) NOT NULL DEFAULT 0,
type VARCHAR(32) NOT NULL DEFAULT 'income',
post_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
buyer_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
currency VARCHAR(8) NOT NULL DEFAULT 'CNY',
original_amount DECIMAL(18,2) NOT NULL DEFAULT 0,
share_ratio DECIMAL(5,2) NOT NULL DEFAULT 0,
author_level TINYINT UNSIGNED NOT NULL DEFAULT 0,
amount DECIMAL(18,2) NOT NULL DEFAULT 0,
type VARCHAR(32) NOT NULL DEFAULT 'order',
status VARCHAR(20) NOT NULL DEFAULT 'pending',
created_at DATETIME NOT NULL,
settled_at DATETIME DEFAULT NULL,
PRIMARY KEY (id),
KEY idx_user (user_id),
UNIQUE KEY uniq_creator_order (author_id, order_number),
KEY idx_author (author_id),
KEY idx_order (order_number),
KEY idx_post (post_id),
KEY idx_buyer (buyer_id),
KEY idx_currency (currency),
KEY idx_status (status),
KEY idx_created (created_at)
) {$charset_collate};";