销售统计增加分类区分

This commit is contained in:
gong
2025-12-08 16:56:32 +08:00
parent b02eaa851a
commit e53d275ba0
8 changed files with 118 additions and 73 deletions

View File

@@ -8,6 +8,7 @@
SELECT
#{shopId} as shopId,
#{day} as createDay,
prod.category_id AS categoryId,
CASE WHEN detail.is_temporary = 1 THEN -1 ELSE detail.product_id END AS prodId,
CASE WHEN detail.is_temporary = 1 THEN '临时菜' ELSE prod.name END AS productName,
sum(detail.num-detail.return_num) as saleCount,
@@ -17,7 +18,7 @@
FROM
tb_order_info `order`
INNER JOIN tb_order_detail detail ON `order`.id = detail.order_id
LEFT JOIN tb_product prod ON detail.product_id = prod.id
INNER JOIN tb_product prod ON detail.product_id = prod.id
WHERE
`order`.shop_id = #{shopId}
AND `order`.trade_day = #{day}
@@ -25,6 +26,9 @@
<if test="productName != null and productName != ''">
AND detail.product_name LIKE CONCAT('%',#{productName},'%')
</if>
<if test="categoryId != null and categoryId > 0">
AND prod.category_id = #{categoryId}
</if>
GROUP BY prodId
</select>
@@ -41,6 +45,9 @@
<if test="productName != null and productName != ''">
AND prod.name LIKE CONCAT('%',#{productName},'%')
</if>
<if test="categoryId != null and categoryId > 0">
AND prod.category_id = #{categoryId}
</if>
ORDER BY
tb_shop_prod_statistic.sale_count DESC, tb_shop_prod_statistic.prod_id
</select>
@@ -63,6 +70,9 @@
<if test="productName != null and productName != ''">
AND prod.name LIKE CONCAT('%',#{productName},'%')
</if>
<if test="categoryId != null and categoryId > 0">
AND prod.category_id = #{categoryId}
</if>
GROUP BY
tb_shop_prod_statistic.prod_id
ORDER BY
@@ -79,7 +89,7 @@
FROM
tb_order_info `order`
INNER JOIN tb_order_detail detail ON `order`.id = detail.order_id
LEFT JOIN tb_product prod ON detail.product_id = prod.id
INNER JOIN tb_product prod ON detail.product_id = prod.id
WHERE
`order`.shop_id = #{shopId}
AND `order`.trade_day = #{day}
@@ -87,6 +97,9 @@
<if test="productName != null and productName != ''">
AND detail.product_name LIKE CONCAT('%',#{productName},'%')
</if>
<if test="categoryId != null and categoryId > 0">
AND prod.category_id = #{categoryId}
</if>
</select>
<select id="summaryCountSingleDate" resultType="com.czg.order.vo.SaleSummaryCountVo">
SELECT
@@ -103,6 +116,9 @@
<if test="productName != null and productName != ''">
AND prod.name LIKE CONCAT('%',#{productName},'%')
</if>
<if test="categoryId != null and categoryId > 0">
AND prod.category_id = #{categoryId}
</if>
</select>
<select id="summaryCountDateRange" resultType="com.czg.order.vo.SaleSummaryCountVo">
@@ -121,6 +137,9 @@
<if test="productName != null and productName != ''">
AND prod.name LIKE CONCAT('%',#{productName},'%')
</if>
<if test="categoryId != null and categoryId > 0">
AND prod.category_id = #{categoryId}
</if>
</select>