lubo 3 meses atrás
pai
commit
902064b61d

+ 5 - 5
ruoyi-shop/src/main/resources/mapper/product/ProductMapper.xml

@@ -221,19 +221,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectStockTenseCount" resultType="java.lang.Integer">
         select count(1)
-        from (select tpsss.stock
+        from (select IFNULL(sum(tpsss.stock),0) as total_stock,tpss.product_id
         from tb_product_sku_set as tpss
         JOIN tb_product as tp on tp.product_id = tpss.product_id
         Join tb_product_sku_set_stock as tpsss
-        on tpss.business_id = tpsss.business_id and tpss.product_id = tpsss.product_id and tpss.sku_hash_code =
-        tpsss.sku_hash_code
+        on tpss.business_id = tpsss.business_id and tpss.product_id = tpsss.product_id and tpss.sku_hash_code =tpsss.sku_hash_code
         <where>
-            tp.del_flag = 0 and tp.audit_status = 10
+            tp.del_flag = 0 and tp.audit_status = 10 and tp.shelved_status = 1
             <if test="businessId != null">
                 AND tp.business_id = #{businessId}
             </if>
         </where>
+        GROUP BY tpss.product_id
         ) as t
-        where t.stock > 5
+        where t.total_stock &lt;= 5
     </select>
 </mapper>