feat(backend): 历史进销存导入器 cmd/import-history + 单据明细快照列
一次性 CLI 导入旧系统 data/ 入库·出库 总表/详情表到当前库,历史只读(绝不 回放 inventories/inventory_logs)。明细忠实直存不做 SKU 归一:order/item 表 新增 creator_id(制单人)与 product_code/product_name/series/spec 快照列 (出库另补 batch_no/production_date),导入行 product_id 指向共享占位商品。 order_no 天然主键 (shop_id,order_no) 幂等去重,可重复跑。 testutil sqlite DDL 同步补列以保持 service 测试通过。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -273,6 +273,7 @@ CREATE TABLE IF NOT EXISTS `stock_in_orders` (
|
||||
`warehouse_id` BIGINT UNSIGNED NOT NULL,
|
||||
`partner_id` BIGINT UNSIGNED DEFAULT NULL COMMENT '供应商',
|
||||
`operator_id` BIGINT UNSIGNED NOT NULL COMMENT '经办人',
|
||||
`creator_id` BIGINT UNSIGNED DEFAULT NULL COMMENT '制单人',
|
||||
`reviewer_id` BIGINT UNSIGNED DEFAULT NULL COMMENT '审核人',
|
||||
`status` ENUM('draft','pending','approved','rejected') NOT NULL DEFAULT 'draft',
|
||||
`order_date` DATE NOT NULL,
|
||||
@@ -299,6 +300,10 @@ CREATE TABLE IF NOT EXISTS `stock_in_items` (
|
||||
`order_id` BIGINT UNSIGNED NOT NULL,
|
||||
`shop_id` BIGINT UNSIGNED NOT NULL,
|
||||
`product_id` BIGINT UNSIGNED NOT NULL,
|
||||
`product_code` VARCHAR(50) DEFAULT NULL COMMENT '商品编号(源流水号,历史导入)',
|
||||
`product_name` VARCHAR(255) DEFAULT NULL COMMENT '商品名称(历史导入快照)',
|
||||
`series` VARCHAR(100) DEFAULT NULL COMMENT '系列(历史导入快照)',
|
||||
`spec` VARCHAR(100) DEFAULT NULL COMMENT '规格(历史导入快照)',
|
||||
`quantity` DECIMAL(12,3) NOT NULL COMMENT '数量',
|
||||
`unit_price` DECIMAL(16,2) NOT NULL DEFAULT 0 COMMENT '单价',
|
||||
`total_price` DECIMAL(16,2) NOT NULL DEFAULT 0,
|
||||
@@ -323,6 +328,7 @@ CREATE TABLE IF NOT EXISTS `stock_out_orders` (
|
||||
`warehouse_id` BIGINT UNSIGNED NOT NULL,
|
||||
`partner_id` BIGINT UNSIGNED DEFAULT NULL COMMENT '客户',
|
||||
`operator_id` BIGINT UNSIGNED NOT NULL,
|
||||
`creator_id` BIGINT UNSIGNED DEFAULT NULL COMMENT '制单人',
|
||||
`reviewer_id` BIGINT UNSIGNED DEFAULT NULL,
|
||||
`status` ENUM('draft','pending','approved','rejected') NOT NULL DEFAULT 'draft',
|
||||
`order_date` DATE NOT NULL,
|
||||
@@ -349,9 +355,15 @@ CREATE TABLE IF NOT EXISTS `stock_out_items` (
|
||||
`order_id` BIGINT UNSIGNED NOT NULL,
|
||||
`shop_id` BIGINT UNSIGNED NOT NULL,
|
||||
`product_id` BIGINT UNSIGNED NOT NULL,
|
||||
`product_code` VARCHAR(50) DEFAULT NULL COMMENT '商品编号(源流水号,历史导入)',
|
||||
`product_name` VARCHAR(255) DEFAULT NULL COMMENT '商品名称(历史导入快照)',
|
||||
`series` VARCHAR(100) DEFAULT NULL COMMENT '系列(历史导入快照)',
|
||||
`spec` VARCHAR(100) DEFAULT NULL COMMENT '规格(历史导入快照)',
|
||||
`quantity` DECIMAL(12,3) NOT NULL,
|
||||
`unit_price` DECIMAL(16,2) NOT NULL DEFAULT 0,
|
||||
`total_price` DECIMAL(16,2) NOT NULL DEFAULT 0,
|
||||
`batch_no` VARCHAR(50) DEFAULT NULL COMMENT '批次号',
|
||||
`production_date` DATE DEFAULT NULL COMMENT '生产日期',
|
||||
`custom_fields` JSON DEFAULT NULL,
|
||||
`remark` VARCHAR(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
|
||||
Reference in New Issue
Block a user