|
|
@ -280,4 +280,50 @@ |
|
|
where shop_id = #{shopId,jdbcType=VARCHAR} |
|
|
where shop_id = #{shopId,jdbcType=VARCHAR} |
|
|
and category_name = '默认分类' |
|
|
and category_name = '默认分类' |
|
|
</select> |
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getCategoryListByShopId" parameterType="java.lang.String" resultType="cc.hiver.mall.entity.ProductCategory"> |
|
|
|
|
|
SELECT |
|
|
|
|
|
sum( count ) AS count, |
|
|
|
|
|
sum( stockCount ) AS stockCount, |
|
|
|
|
|
dd.id, |
|
|
|
|
|
dd.category_name, |
|
|
|
|
|
dd.shop_id, |
|
|
|
|
|
dd.create_by, |
|
|
|
|
|
dd.create_time, |
|
|
|
|
|
dd.update_by, |
|
|
|
|
|
dd.update_time, |
|
|
|
|
|
dd.del_flag |
|
|
|
|
|
FROM |
|
|
|
|
|
t_product_category dd |
|
|
|
|
|
LEFT JOIN ( |
|
|
|
|
|
SELECT |
|
|
|
|
|
count( * ) AS count, |
|
|
|
|
|
sum( COALESCE ( ss.stock_count, 0 ) ) AS stockCount, |
|
|
|
|
|
t.category_id |
|
|
|
|
|
FROM |
|
|
|
|
|
t_product t |
|
|
|
|
|
LEFT JOIN ( |
|
|
|
|
|
SELECT |
|
|
|
|
|
sum( CASE WHEN s.stock_count < 0 THEN 0 ELSE s.stock_count END ) AS stock_count, |
|
|
|
|
|
shop_id, |
|
|
|
|
|
product_id |
|
|
|
|
|
FROM |
|
|
|
|
|
t_stock s |
|
|
|
|
|
GROUP BY |
|
|
|
|
|
shop_id, |
|
|
|
|
|
product_id |
|
|
|
|
|
) ss ON ss.product_id = t.id |
|
|
|
|
|
AND ss.shop_id = t.shop_id |
|
|
|
|
|
WHERE |
|
|
|
|
|
t.del_flag != '2' |
|
|
|
|
|
AND t.shop_id = #{shopId,jdbcType=VARCHAR} |
|
|
|
|
|
GROUP BY |
|
|
|
|
|
t.id |
|
|
|
|
|
) aa ON dd.id = aa.category_id |
|
|
|
|
|
WHERE |
|
|
|
|
|
dd.shop_id = #{shopId,jdbcType=VARCHAR} |
|
|
|
|
|
GROUP BY |
|
|
|
|
|
dd.id |
|
|
|
|
|
</select> |
|
|
</mapper> |
|
|
</mapper> |