Parcourir la source

fix: 库存流水列表显示商品名称

Xiaogang Liao il y a 1 mois
Parent
commit
f06e875b12

+ 0 - 83
cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java

@@ -7924,87 +7924,4 @@ private void runMigration100() {
 			log.warn("插入membership_benefits种子数据失败: {}", ex.getMessage());
 		}
 	}
-
-		ensureColumn("products", "min_stock_alert", "INT DEFAULT 0 COMMENT '库存预警阈值(低于此值预警)'");
-
-		// 迁移173: 创建库存管理4张表(inventory_transactions/counting_records/inbound_orders/inbound_items)
-		try {
-			jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS inventory_transactions (" +
-					"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
-					"product_id BIGINT COMMENT '商品ID', " +
-					"sku_id BIGINT COMMENT 'SKU ID', " +
-					"type VARCHAR(32) COMMENT '交易类型: INBOUND/OUTBOUND/ADJUSTMENT/TRANSFER/COUNT', " +
-					"direction TINYINT COMMENT '方向: 1=入库, -1=出库', " +
-					"quantity INT NOT NULL COMMENT '数量', " +
-					"before_stock INT COMMENT '操作前库存', " +
-					"after_stock INT COMMENT '操作后库存', " +
-					"reference_type VARCHAR(32) COMMENT '关联业务类型', " +
-					"reference_id BIGINT COMMENT '关联业务ID', " +
-					"operator_id BIGINT COMMENT '操作人ID', " +
-					"remark TEXT COMMENT '备注', " +
-					"created_at DATETIME DEFAULT CURRENT_TIMESTAMP " +
-					") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='库存交易流水表'");
-			log.info("已创建inventory_transactions表");
-		} catch (Exception e) { /* 表已存在,忽略 */ }
-
-		try {
-			jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS inventory_counting_records (" +
-					"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
-					"product_id BIGINT COMMENT '商品ID', " +
-					"sku_id BIGINT COMMENT 'SKU ID', " +
-					"expected_stock INT COMMENT '账面库存', " +
-					"actual_stock INT COMMENT '实际库存', " +
-					"difference INT COMMENT '差异', " +
-					"status VARCHAR(16) DEFAULT 'pending' COMMENT '状态', " +
-					"operator_id BIGINT COMMENT '盘点人ID', " +
-					"remark TEXT COMMENT '备注', " +
-					"created_at DATETIME DEFAULT CURRENT_TIMESTAMP " +
-					") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='库存盘点记录表'");
-			log.info("已创建inventory_counting_records表");
-		} catch (Exception e) { /* 表已存在,忽略 */ }
-
-		try {
-			jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS inventory_inbound_orders (" +
-					"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
-					"order_no VARCHAR(64) NOT NULL COMMENT '入库单号', " +
-					"supplier_id BIGINT COMMENT '供应商ID', " +
-					"supplier_name VARCHAR(100) COMMENT '供应商名称', " +
-					"status VARCHAR(16) DEFAULT 'pending' COMMENT '状态', " +
-					"total_items INT DEFAULT 0 COMMENT '商品种类数', " +
-					"operator_id BIGINT COMMENT '操作人ID', " +
-					"remark TEXT COMMENT '备注', " +
-					"created_at DATETIME DEFAULT CURRENT_TIMESTAMP, " +
-					"updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP " +
-					") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='库存入库单表'");
-			log.info("已创建inventory_inbound_orders表");
-		} catch (Exception e) { /* 表已存在,忽略 */ }
-
-		try {
-			jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS inventory_inbound_items (" +
-					"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
-					"inbound_order_id BIGINT NOT NULL COMMENT '入库单ID', " +
-					"product_id BIGINT NOT NULL COMMENT '商品ID', " +
-					"sku_id BIGINT COMMENT 'SKU ID', " +
-					"quantity INT NOT NULL COMMENT '入库数量', " +
-					"created_at DATETIME DEFAULT CURRENT_TIMESTAMP " +
-					") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='库存入库明细表'");
-			log.info("已创建inventory_inbound_items表");
-		} catch (Exception e) { /* 表已存在,忽略 */ }
-
-		// 迁移174: product_skus 添加 min_stock_alert 和 min_quantity 列(SKU库存预警+最小购买数,配合库存管理模块)
-		ensureColumn("product_skus", "min_stock_alert", "INT DEFAULT 0 COMMENT '库存预警阈值(低于此值预警)'");
-		ensureColumn("product_skus", "min_quantity", "INT DEFAULT 1 COMMENT '最小购买数量限制'");
-
-		// 迁移175: inventory_inbound_orders 添加 inbound_date 和 total_amount 列(入库单扩展)
-		ensureColumn("inventory_inbound_orders", "inbound_date", "DATE COMMENT '入库日期'");
-		ensureColumn("inventory_inbound_orders", "total_amount", "INT DEFAULT 0 COMMENT '入库总金额(分)'");
-
-		// 迁移176: product_orders 添加 shipping_cost 列(快递费)
-		ensureColumn("product_orders", "shipping_cost", "INT DEFAULT 0 COMMENT '快递费(分)'");
-
-		// 迁移177: 添加进价字段(products/product_skus/inventory_inbound_items)
-		ensureColumn("products", "purchase_price", "DECIMAL(10,2) DEFAULT 0.00 COMMENT '进价(分)'");
-		ensureColumn("product_skus", "purchase_price", "DECIMAL(10,2) DEFAULT 0.00 COMMENT '进价(分)'");
-		ensureColumn("inventory_inbound_items", "purchase_price", "DECIMAL(10,2) DEFAULT 0.00 COMMENT '入库单价(分)'");
-	}
 }

+ 40 - 2
cfc-backend/src/main/java/com/etotem/cfc/service/InventoryService.java

@@ -187,8 +187,29 @@ public class InventoryService {
             } catch (Exception ignored) {}
         }
         Page<InventoryTransaction> result = transactionMapper.selectPage(pageParam, wrapper);
+        // 补充商品名称
+        List<Map<String, Object>> enrichedRecords = new ArrayList<>();
+        for (InventoryTransaction tx : result.getRecords()) {
+            Map<String, Object> record = new HashMap<>();
+            record.put("id", tx.getId());
+            record.put("productId", tx.getProductId());
+            record.put("skuId", tx.getSkuId());
+            record.put("type", tx.getType());
+            record.put("direction", tx.getDirection());
+            record.put("quantity", tx.getQuantity());
+            record.put("beforeStock", tx.getBeforeStock());
+            record.put("afterStock", tx.getAfterStock());
+            record.put("referenceType", tx.getReferenceType());
+            record.put("referenceId", tx.getReferenceId());
+            record.put("operatorId", tx.getOperatorId());
+            record.put("remark", tx.getRemark());
+            record.put("createdAt", tx.getCreatedAt());
+            Product p = productMapper.selectById(tx.getProductId());
+            record.put("productName", p != null ? p.getName() : null);
+            enrichedRecords.add(record);
+        }
         Map<String, Object> data = new HashMap<>();
-        data.put("records", result.getRecords());
+        data.put("records", enrichedRecords);
         data.put("total", result.getTotal());
         data.put("page", result.getCurrent());
         data.put("size", result.getSize());
@@ -534,8 +555,25 @@ public class InventoryService {
             } catch (Exception ignored) {}
         }
         Page<InventoryTransaction> result = transactionMapper.selectPage(pageParam, wrapper);
+        List<Map<String, Object>> enrichedRecords = new ArrayList<>();
+        for (InventoryTransaction tx : result.getRecords()) {
+            Map<String, Object> record = new HashMap<>();
+            record.put("id", tx.getId());
+            record.put("productId", tx.getProductId());
+            record.put("skuId", tx.getSkuId());
+            record.put("type", tx.getType());
+            record.put("direction", tx.getDirection());
+            record.put("quantity", tx.getQuantity());
+            record.put("beforeStock", tx.getBeforeStock());
+            record.put("afterStock", tx.getAfterStock());
+            record.put("remark", tx.getRemark());
+            record.put("createdAt", tx.getCreatedAt());
+            Product p = productMapper.selectById(tx.getProductId());
+            record.put("productName", p != null ? p.getName() : null);
+            enrichedRecords.add(record);
+        }
         Map<String, Object> data = new HashMap<>();
-        data.put("records", result.getRecords());
+        data.put("records", enrichedRecords);
         data.put("total", result.getTotal());
         data.put("page", result.getCurrent());
         data.put("size", result.getSize());

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-fe14d9465cffed59e10561340067eb14335810eb
+7ff45d885ddf3400b3c7ec381a61323c16bff706

+ 1 - 1
cfc-web/package.json

@@ -1,6 +1,6 @@
 {
   "name": "cfc-web",
-  "version": "1.0.825",
+  "version": "1.0.824",
   "private": true,
   "scripts": {
     "dev": "vue-cli-service serve",

+ 0 - 10
cfc-web/public/CHANGELOG-v1.0.md

@@ -4,16 +4,6 @@
 
 ---
 
-## v1.0.825 (2026-08-05)
-
-### Bug 修复
-- 商品详情页移除会员价展示
-
-### 其他
-- Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
-- 
-
-
 ## v1.0.824 (2026-08-05)
 
 ### 新功能

+ 1 - 11
cfc-web/public/CHANGELOG.md

@@ -1,6 +1,6 @@
 # 更新日志
 
-> 当前版本: v1.0.825
+> 当前版本: v1.0.824
 
 ## 历史版本
 
@@ -8,16 +8,6 @@
 
 ---
 
-## v1.0.825 (2026-08-05)
-
-### Bug 修复
-- 商品详情页移除会员价展示
-
-### 其他
-- Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
-- 
-
-
 ## v1.0.824 (2026-08-05)
 
 ### 新功能