diff --git a/src/main/java/com/imyeyu/api/modules/gao/vo/GaoProductStockProductView.java b/src/main/java/com/imyeyu/api/modules/gao/vo/GaoProductStockProductView.java index ed4ee30..1941fee 100644 --- a/src/main/java/com/imyeyu/api/modules/gao/vo/GaoProductStockProductView.java +++ b/src/main/java/com/imyeyu/api/modules/gao/vo/GaoProductStockProductView.java @@ -32,6 +32,9 @@ public class GaoProductStockProductView { /// 可库存 SKU 数量 private Long skuCount; + /// 产品仅有一个可库存 SKU 时的 SKU ID + private String skuId; + /// 库存数量,使用基础单位 private BigDecimal onHandQuantity; diff --git a/src/main/resources/mapper/timi-server/gao/GaoProductStockMapper.xml b/src/main/resources/mapper/timi-server/gao/GaoProductStockMapper.xml index 8da1e16..f668887 100644 --- a/src/main/resources/mapper/timi-server/gao/GaoProductStockMapper.xml +++ b/src/main/resources/mapper/timi-server/gao/GaoProductStockMapper.xml @@ -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`