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:
wangjia
2026-06-20 07:05:08 +08:00
parent 7bbc944ae2
commit 90d2c8668b
5 changed files with 735 additions and 0 deletions
+12
View File
@@ -278,6 +278,7 @@ func SetupTestDB() *gorm.DB {
warehouse_id INTEGER NOT NULL,
partner_id INTEGER,
operator_id INTEGER NOT NULL,
creator_id INTEGER,
reviewer_id INTEGER,
status TEXT DEFAULT 'draft',
order_date DATETIME,
@@ -295,6 +296,10 @@ func SetupTestDB() *gorm.DB {
order_id INTEGER NOT NULL,
shop_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
product_code TEXT,
product_name TEXT,
series TEXT,
spec TEXT,
quantity REAL NOT NULL,
unit_price REAL DEFAULT 0,
total_price REAL DEFAULT 0,
@@ -314,6 +319,7 @@ func SetupTestDB() *gorm.DB {
warehouse_id INTEGER NOT NULL,
partner_id INTEGER,
operator_id INTEGER NOT NULL,
creator_id INTEGER,
reviewer_id INTEGER,
status TEXT DEFAULT 'draft',
order_date DATETIME,
@@ -331,9 +337,15 @@ func SetupTestDB() *gorm.DB {
order_id INTEGER NOT NULL,
shop_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
product_code TEXT,
product_name TEXT,
series TEXT,
spec TEXT,
quantity REAL NOT NULL,
unit_price REAL DEFAULT 0,
total_price REAL DEFAULT 0,
batch_no TEXT,
production_date DATETIME,
custom_fields TEXT,
remark TEXT
)`,