功能提交
This commit is contained in:
@@ -928,3 +928,134 @@ CREATE TABLE IF NOT EXISTS ll_dropship_carton_ledger (
|
||||
occurred_at DATETIME(3) NOT NULL, created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), PRIMARY KEY(id),
|
||||
UNIQUE KEY uk_ll_dropship_ledger_key(customer_id,idempotency_key), KEY idx_ll_dropship_ledger_sku(customer_id,sku_code,carton_mark)
|
||||
) ENGINE=InnoDB COMMENT='Immutable dropship SKU/carton-mark package ledger';
|
||||
|
||||
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';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS ll_overseas_procurement_order (
|
||||
id BIGINT NOT NULL COMMENT 'Snowflake ID', 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';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS ll_us_truck_order (
|
||||
id BIGINT NOT NULL COMMENT 'Snowflake primary key',
|
||||
customer_id VARCHAR(128) NOT NULL COMMENT 'Trusted tenant identifier',
|
||||
order_no VARCHAR(64) NOT NULL COMMENT 'US trucking order number',
|
||||
transport_type VARCHAR(32) NOT NULL COMMENT 'PORT_PICKUP/WAREHOUSE_TO_WAREHOUSE/WAREHOUSE_TO_DOOR',
|
||||
origin VARCHAR(255) NOT NULL COMMENT 'Origin city, port or state',
|
||||
origin_address VARCHAR(500) NULL COMMENT 'Origin street address',
|
||||
destination VARCHAR(255) NOT NULL COMMENT 'Destination city, warehouse or state',
|
||||
destination_address VARCHAR(500) NULL COMMENT 'Destination street, terminal or warehouse address',
|
||||
container_type VARCHAR(32) NOT NULL COMMENT 'Container or truck equipment type',
|
||||
package_count INT NOT NULL DEFAULT 0 COMMENT 'Package count',
|
||||
total_weight_kg DECIMAL(18,3) NOT NULL DEFAULT 0 COMMENT 'Total weight in kilograms',
|
||||
total_volume_cbm DECIMAL(18,6) NOT NULL DEFAULT 0 COMMENT 'Total volume in cubic meters',
|
||||
budget_amount DECIMAL(18,2) NULL COMMENT 'Customer budget total',
|
||||
currency VARCHAR(3) NOT NULL DEFAULT 'USD' COMMENT 'ISO currency code',
|
||||
contact_name VARCHAR(128) NOT NULL COMMENT 'Shipment contact name',
|
||||
contact_info VARCHAR(128) NOT NULL COMMENT 'Phone, email or messaging account',
|
||||
requested_date DATE NOT NULL COMMENT 'Requested pickup or service date',
|
||||
status VARCHAR(32) NOT NULL COMMENT 'Current business status',
|
||||
remark VARCHAR(1000) NULL COMMENT 'Order remark',
|
||||
idempotency_key VARCHAR(255) NOT NULL COMMENT 'Customer request idempotency key',
|
||||
request_hash CHAR(64) NOT NULL COMMENT 'SHA-256 request hash',
|
||||
created_by VARCHAR(128) NULL COMMENT 'Creating user identifier',
|
||||
version BIGINT NOT NULL DEFAULT 0 COMMENT 'Optimistic concurrency version',
|
||||
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 COMMENT 'Snowflake primary key',
|
||||
order_id BIGINT NOT NULL COMMENT 'US trucking order ID',
|
||||
customer_id VARCHAR(128) NOT NULL COMMENT 'Trusted tenant identifier',
|
||||
from_status VARCHAR(32) NULL COMMENT 'Previous status',
|
||||
to_status VARCHAR(32) NOT NULL COMMENT 'New status',
|
||||
operator_id VARCHAR(128) NULL COMMENT 'Operator identifier',
|
||||
remark VARCHAR(1000) NULL COMMENT 'Status change note',
|
||||
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';
|
||||
|
||||
Reference in New Issue
Block a user