From 8352c314f8a15a5caf6dfa2837562f839eeef6c3 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 24 四月 2026 10:13:28 +0800
Subject: [PATCH] feat: 库存管理调整为按照大类进行区分

---
 src/main/resources/mapper/basic/ProductModelMapper.xml |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/main/resources/mapper/basic/ProductModelMapper.xml b/src/main/resources/mapper/basic/ProductModelMapper.xml
index cb80816..9a7e927 100644
--- a/src/main/resources/mapper/basic/ProductModelMapper.xml
+++ b/src/main/resources/mapper/basic/ProductModelMapper.xml
@@ -56,6 +56,22 @@
             <if test="c.parentName != null and c.parentName != ''">
                 AND pt.top_name LIKE CONCAT('%', #{c.parentName}, '%')
             </if>
+            <if test="c.topProductParentId != null and c.topProductParentId > 0">
+                and p.id in (
+                    WITH RECURSIVE product_tree AS (
+                        SELECT id
+                        FROM product
+                        WHERE id = #{c.topProductParentId}
+                        
+                        UNION ALL
+                        
+                        SELECT p.id
+                        FROM product p
+                        INNER JOIN product_tree pt ON p.parent_id = pt.id
+                    )
+                    select id from product_tree
+                )
+            </if>
         </where>
         ORDER BY pm.id DESC
     </select>

--
Gitblit v1.9.3