refactor(migration): 整合分销迁移至终态定义并清理零散改表与测试种子数据
This commit is contained in:
@@ -12,6 +12,7 @@ CREATE TABLE distribution_sites (
|
||||
domain VARCHAR(255) NOT NULL,
|
||||
status VARCHAR(16) NOT NULL DEFAULT 'active',
|
||||
display_account_enabled TINYINT(1) NOT NULL DEFAULT 1,
|
||||
settlement_hold_days INT NOT NULL DEFAULT 7 COMMENT '订单完成后结算释放冷却天数,0=立即释放',
|
||||
logo_url VARCHAR(512) NOT NULL DEFAULT '',
|
||||
favicon_url VARCHAR(512) NOT NULL DEFAULT '',
|
||||
banners_json TEXT NULL,
|
||||
@@ -111,12 +112,15 @@ CREATE TABLE distribution_order_financials (
|
||||
split_base_amount_cent BIGINT NOT NULL DEFAULT 0,
|
||||
rounding_adjustment_cent BIGINT NOT NULL DEFAULT 0,
|
||||
settlement_status VARCHAR(24) NOT NULL DEFAULT 'pending',
|
||||
release_at DATETIME(6) NULL COMMENT '预计释放时间(订单完成时间+站点冷却期)',
|
||||
released_at DATETIME(6) NULL COMMENT '实际释放入账时间',
|
||||
settled_at DATETIME NULL,
|
||||
created_at DATETIME NOT NULL,
|
||||
updated_at DATETIME NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_distribution_order_financial_order (order_id),
|
||||
KEY idx_distribution_order_financial_site_status (site_id, settlement_status),
|
||||
KEY idx_distribution_financial_release (settlement_status, release_at),
|
||||
CONSTRAINT fk_distribution_order_financial_order FOREIGN KEY (order_id) REFERENCES rental_orders (id),
|
||||
CONSTRAINT fk_distribution_order_financial_site FOREIGN KEY (site_id) REFERENCES distribution_sites (id),
|
||||
CONSTRAINT fk_distribution_order_financial_rule FOREIGN KEY (rule_version_id) REFERENCES distribution_rule_versions (id)
|
||||
@@ -172,6 +176,7 @@ CREATE TABLE distribution_settlement_items (
|
||||
created_at DATETIME NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_distribution_settlement_item (batch_id, order_id, party_id),
|
||||
UNIQUE KEY uk_distribution_settlement_item_party (order_id, party_id),
|
||||
KEY idx_distribution_settlement_items_order (order_id),
|
||||
CONSTRAINT fk_distribution_settlement_items_batch FOREIGN KEY (batch_id) REFERENCES distribution_settlement_batches (id),
|
||||
CONSTRAINT fk_distribution_settlement_items_order FOREIGN KEY (order_id) REFERENCES rental_orders (id),
|
||||
@@ -286,7 +291,8 @@ INSERT INTO distribution_rule_versions (
|
||||
) VALUES
|
||||
(NULL, 'two_party_distributor_receive', 1, 'active', 0, 40, 35, 0, 0, 0, 25, 'percent', 50, 0, 100, NOW(), NOW()),
|
||||
(NULL, 'two_party_platform_receive', 1, 'active', 35, 0, 0, 40, 0, 0, 25, 'percent', 50, 0, 100, NOW(), NOW()),
|
||||
(NULL, 'three_party', 1, 'active', 0, 0, 0, 0, 35, 40, 25, 'percent', 50, 0, 100, NOW(), NOW());
|
||||
(NULL, 'three_party', 1, 'active', 0, 0, 0, 0, 35, 40, 25, 'percent', 50, 0, 100, NOW(), NOW()),
|
||||
(NULL, 'site_self_sell', 1, 'active', 0, 0, 0, 75, 0, 0, 25, 'percent', 50, 0, 100, NOW(), NOW());
|
||||
|
||||
-- +goose Down
|
||||
|
||||
|
||||
Reference in New Issue
Block a user