with skuId for only once sku

This commit is contained in:
Timi
2026-09-22 17:53:45 +08:00
parent 7adea85e1f
commit 1203ccfa4a
2 changed files with 4 additions and 0 deletions
@@ -32,6 +32,9 @@ public class GaoProductStockProductView {
/// 可库存 SKU 数量
private Long skuCount;
/// 产品仅有一个可库存 SKU 时的 SKU ID
private String skuId;
/// 库存数量,使用基础单位
private BigDecimal onHandQuantity;
@@ -84,6 +84,7 @@
p.`name` AS `product_name`,
p.`product_type`,
COUNT(k.`id`) AS `sku_count`,
CASE WHEN COUNT(k.`id`) = 1 THEN MAX(k.`id`) END AS `sku_id`,
COALESCE(SUM(COALESCE(s.`on_hand_quantity`, 0)), 0) AS `on_hand_quantity`,
COALESCE(SUM(COALESCE(s.`reserved_quantity`, 0)), 0) AS `reserved_quantity`,
COALESCE(SUM(COALESCE(s.`on_hand_quantity`, 0) - COALESCE(s.`reserved_quantity`, 0)), 0) AS `available_quantity`