功能提交

This commit is contained in:
2026-08-18 16:31:55 +08:00
parent d2c532f807
commit 31cf37c528
60 changed files with 2983 additions and 21 deletions
+111
View File
@@ -1304,3 +1304,114 @@ SET @ddl = (SELECT IF(EXISTS (SELECT 1 FROM information_schema.statistics WHERE
PREPARE dropship_add_profile_sku_stmt FROM @ddl; EXECUTE dropship_add_profile_sku_stmt; DEALLOCATE PREPARE dropship_add_profile_sku_stmt;
SET @ddl = (SELECT IF(EXISTS (SELECT 1 FROM information_schema.statistics WHERE table_schema=DATABASE() AND table_name='ll_dropship_sku_inventory' AND index_name='idx_ll_dropship_sku_order'), 'SELECT 1', 'ALTER TABLE ll_dropship_sku_inventory ADD KEY idx_ll_dropship_sku_order(customer_id,order_id,sku_code)'));
PREPARE dropship_add_order_sku_idx_stmt FROM @ddl; EXECUTE dropship_add_order_sku_idx_stmt; DEALLOCATE PREPARE dropship_add_order_sku_idx_stmt;
-- ============================================================================
-- 2026-08-18 / 021 cargo discard application, carton reservation and approval.
-- ============================================================================
USE baiyue_lastleg;
CREATE TABLE IF NOT EXISTS ll_cargo_discard_application (
id BIGINT NOT NULL COMMENT 'Snowflake ID', customer_id VARCHAR(128) NOT NULL,
discard_no VARCHAR(64) NOT NULL, overseas_warehouse_id VARCHAR(128) NOT NULL,
overseas_warehouse_name VARCHAR(255) NULL, inbound_codes VARCHAR(2000) NOT NULL,
total_packages INT NOT NULL, fee_per_package DECIMAL(18,2) NOT NULL,
total_fee DECIMAL(18,2) NOT NULL, currency CHAR(3) NOT NULL DEFAULT 'USD',
status VARCHAR(32) NOT NULL DEFAULT 'PENDING_REVIEW', remark VARCHAR(1000) NULL,
idempotency_key VARCHAR(255) NOT NULL, request_hash CHAR(64) NOT NULL,
created_by VARCHAR(128) NULL, reviewed_by VARCHAR(128) NULL, review_remark VARCHAR(1000) NULL,
reviewed_at DATETIME(3) NULL, created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
PRIMARY KEY(id), UNIQUE KEY uk_ll_cargo_discard_no(customer_id,discard_no),
UNIQUE KEY uk_ll_cargo_discard_key(customer_id,idempotency_key),
KEY idx_ll_cargo_discard_list(customer_id,status,created_at),
KEY idx_ll_cargo_discard_warehouse(customer_id,overseas_warehouse_id,created_at)
) ENGINE=InnoDB COMMENT='Cargo discard application requiring warehouse approval';
CREATE TABLE IF NOT EXISTS ll_cargo_discard_item (
id BIGINT NOT NULL, application_id BIGINT NOT NULL, customer_id VARCHAR(128) NOT NULL,
order_id BIGINT NOT NULL, inbound_code VARCHAR(128) NOT NULL, profile_id BIGINT NOT NULL,
sku_inventory_id BIGINT NOT NULL, sku_code VARCHAR(128) NOT NULL, product_name VARCHAR(255) NULL,
available_packages_snapshot INT NOT NULL, discard_packages INT NOT NULL,
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), PRIMARY KEY(id),
UNIQUE KEY uk_ll_cargo_discard_item(application_id,profile_id,sku_code),
KEY idx_ll_cargo_discard_item_list(customer_id,application_id),
KEY idx_ll_cargo_discard_item_inbound(customer_id,inbound_code,sku_code)
) ENGINE=InnoDB COMMENT='Frozen SKU quantities in a cargo discard application';
CREATE TABLE IF NOT EXISTS ll_cargo_discard_carton (
id BIGINT NOT NULL, application_id BIGINT NOT NULL, item_id BIGINT NOT NULL,
customer_id VARCHAR(128) NOT NULL, carton_id BIGINT NOT NULL, carton_mark VARCHAR(128) NOT NULL,
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), PRIMARY KEY(id),
UNIQUE KEY uk_ll_cargo_discard_carton(application_id,carton_id),
KEY idx_ll_cargo_discard_carton_application(customer_id,application_id,item_id),
KEY idx_ll_cargo_discard_carton_identity(customer_id,carton_id)
) ENGINE=InnoDB COMMENT='Cartons reserved while a cargo discard application awaits review';
CREATE TABLE IF NOT EXISTS ll_cargo_discard_status_history (
id BIGINT NOT NULL, application_id BIGINT NOT NULL, customer_id VARCHAR(128) NOT NULL,
from_status VARCHAR(32) NULL, to_status VARCHAR(32) NOT NULL, operator_id VARCHAR(128) NULL,
remark VARCHAR(1000) NULL, created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), PRIMARY KEY(id),
KEY idx_ll_cargo_discard_history(customer_id,application_id,created_at)
) ENGINE=InnoDB COMMENT='Immutable cargo discard approval history';
-- ============================================================================
-- 2026-08-18 / 022 overseas procurement approval, inventory and outbound flow.
-- ============================================================================
USE baiyue_lastleg;
CREATE TABLE IF NOT EXISTS ll_overseas_procurement_order (
id BIGINT NOT NULL, customer_id VARCHAR(128) NOT NULL, customer_name VARCHAR(255) NULL,
order_no VARCHAR(64) NOT NULL, purchase_category VARCHAR(128) NOT NULL, product_name VARCHAR(255) NOT NULL,
product_specification VARCHAR(500) NULL, product_url VARCHAR(2000) NULL, purchase_quantity BIGINT NOT NULL,
budget_unit_price DECIMAL(18,2) NULL, currency CHAR(3) NOT NULL DEFAULT 'USD', receiving_address VARCHAR(1000) NULL,
contact_name VARCHAR(128) NOT NULL, contact_phone VARCHAR(64) NOT NULL, purchase_warehouse_id VARCHAR(128) NULL,
purchase_warehouse_name VARCHAR(255) NULL, inbound_quantity BIGINT NOT NULL DEFAULT 0, outbound_quantity BIGINT NOT NULL DEFAULT 0,
domestic_carrier VARCHAR(128) NULL, domestic_tracking_no VARCHAR(128) NULL, overseas_carrier VARCHAR(128) NULL,
overseas_tracking_no VARCHAR(128) NULL, estimated_arrival_at DATETIME(3) NULL, status VARCHAR(32) NOT NULL DEFAULT 'PENDING_REVIEW',
remark VARCHAR(1000) NULL, idempotency_key VARCHAR(255) NOT NULL, request_hash CHAR(64) NOT NULL,
created_by VARCHAR(128) NULL, reviewed_by VARCHAR(128) NULL, review_remark VARCHAR(1000) NULL, reviewed_at DATETIME(3) NULL,
version BIGINT NOT NULL DEFAULT 0, created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), PRIMARY KEY(id),
UNIQUE KEY uk_ll_overseas_procurement_order_no(customer_id,order_no), UNIQUE KEY uk_ll_overseas_procurement_order_key(customer_id,idempotency_key),
KEY idx_ll_overseas_procurement_list(customer_id,status,created_at), KEY idx_ll_overseas_procurement_warehouse(customer_id,purchase_warehouse_id,created_at)
) ENGINE=InnoDB COMMENT='Overseas procurement order awaiting business approval';
CREATE TABLE IF NOT EXISTS ll_overseas_procurement_outbound (
id BIGINT NOT NULL, order_id BIGINT NOT NULL, customer_id VARCHAR(128) NOT NULL, quantity BIGINT NOT NULL,
outbound_no VARCHAR(128) NOT NULL, carrier VARCHAR(128) NULL, tracking_no VARCHAR(128) NULL, outbound_at DATETIME(3) NOT NULL,
remark VARCHAR(1000) NULL, created_by VARCHAR(128) NULL, created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), PRIMARY KEY(id),
UNIQUE KEY uk_ll_overseas_procurement_outbound_no(customer_id,order_id,outbound_no), KEY idx_ll_overseas_procurement_outbound_order(customer_id,order_id,outbound_at)
) ENGINE=InnoDB COMMENT='Manual outbound records for overseas procurement inventory';
CREATE TABLE IF NOT EXISTS ll_overseas_procurement_status_history (
id BIGINT NOT NULL, order_id BIGINT NOT NULL, customer_id VARCHAR(128) NOT NULL,
from_status VARCHAR(32) NULL, to_status VARCHAR(32) NOT NULL, operator_id VARCHAR(128) NULL, remark VARCHAR(1000) NULL,
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), PRIMARY KEY(id), KEY idx_ll_overseas_procurement_history(customer_id,order_id,created_at)
) ENGINE=InnoDB COMMENT='Immutable overseas procurement review history';
-- 2026-08-18 / 023 US domestic trucking customer and platform workflow.
USE baiyue_lastleg;
CREATE TABLE IF NOT EXISTS ll_us_truck_order (
id BIGINT NOT NULL, customer_id VARCHAR(128) NOT NULL, order_no VARCHAR(64) NOT NULL,
transport_type VARCHAR(32) NOT NULL, origin VARCHAR(255) NOT NULL, origin_address VARCHAR(500) NULL,
destination VARCHAR(255) NOT NULL, destination_address VARCHAR(500) NULL, container_type VARCHAR(32) NOT NULL,
package_count INT NOT NULL DEFAULT 0, total_weight_kg DECIMAL(18,3) NOT NULL DEFAULT 0,
total_volume_cbm DECIMAL(18,6) NOT NULL DEFAULT 0, budget_amount DECIMAL(18,2) NULL,
currency VARCHAR(3) NOT NULL DEFAULT 'USD', contact_name VARCHAR(128) NOT NULL,
contact_info VARCHAR(128) NOT NULL, requested_date DATE NOT NULL, status VARCHAR(32) NOT NULL,
remark VARCHAR(1000) NULL, idempotency_key VARCHAR(255) NOT NULL, request_hash CHAR(64) NOT NULL,
created_by VARCHAR(128) NULL, version BIGINT NOT NULL DEFAULT 0,
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
PRIMARY KEY(id), UNIQUE KEY uk_ll_us_truck_order_no(customer_id,order_no),
UNIQUE KEY uk_ll_us_truck_order_key(customer_id,idempotency_key),
KEY idx_ll_us_truck_order_list(customer_id,status,created_at),
KEY idx_ll_us_truck_order_date(customer_id,requested_date,created_at)
) ENGINE=InnoDB COMMENT='US domestic trucking customer order';
CREATE TABLE IF NOT EXISTS ll_us_truck_order_status_history (
id BIGINT NOT NULL, order_id BIGINT NOT NULL, customer_id VARCHAR(128) NOT NULL,
from_status VARCHAR(32) NULL, to_status VARCHAR(32) NOT NULL, operator_id VARCHAR(128) NULL,
remark VARCHAR(1000) NULL, created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
PRIMARY KEY(id), KEY idx_ll_us_truck_history(customer_id,order_id,created_at)
) ENGINE=InnoDB COMMENT='Immutable US trucking order status history';