From 5f7aa01ab2f2c6a4946be78f5fb0fb2b7c95f144 Mon Sep 17 00:00:00 2001 From: wany <13995595726@qq.com> Date: Tue, 11 Mar 2025 13:32:56 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/ordertemp/OrderTempService.java | 2 +- .../ssjygl/stat/sale/OrderStatService.java | 28 +++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java index 9d918eb..00fa8b1 100644 --- a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java +++ b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java @@ -140,7 +140,7 @@ public class OrderTempService extends BaseService { } if (supermarket_id != null) { - fromsql += " and t.supermarket_id = ? \n"; + fromsql += " and s.supermarket_id = ? \n"; paraList.add(supermarket_id); } diff --git a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java index 0348dba..ab952d9 100644 --- a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java +++ b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java @@ -547,13 +547,36 @@ public class OrderStatService { params.add(type); } + params.addAll(params); + //2025-03-06更改,解决砂站商品删除后月统计数据查询不到问题 + String selectSql = "select s.id, s.name, s.name2, p.id product_id, p.`name` product_name, ifnull(a.orderCount, 0) as orderCount, ifnull(a.totalPrice, 0) as totalPrice, ifnull(a.weight, 0) as weight\n" + + " from supermarket_product t\n"; + String commonSql = "select t.id, t.product_id, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" + + " from (\n" + + " select t.supermarket_id as id, t.paid, t.total_price, t.weight, t.product_id\n" + + " from order_temp t\n" + + " where t.state = 5 \n" + + " and t.create_time between ? and ? \n" + + saleParams + + " ) t\n" + + " group by t.id, t.product_id\n"; + + String sql = "select m.* from (" + selectSql + "left join (\n" + commonSql + " ) a on a.id = t.supermarket_id and a.product_id = t.product_id\n" + + " left join supermarket s on s.id = t.supermarket_id\n" + + " left join product p on p.id = t.product_id\n" + + "union\n" + + selectSql + "right join (\n" + commonSql + " ) a on a.id = t.supermarket_id and a.product_id = t.product_id\n" + + " left join supermarket s on s.id = a.id\n" + + " left join product p on p.id = a.product_id ) m order by m.id,m.product_id"; + + /** String sql = "select s.id, s.name, s.name2, p.id product_id, p.`name` product_name, ifnull(a.orderCount, 0) as orderCount, ifnull(a.totalPrice, 0) as totalPrice, ifnull(a.weight, 0) as weight\n" + " from supermarket_product t\n" + " left join (\n" + " select t.id, t.product_id, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" + " from (\n" + " select t.supermarket_id as id, t.paid, t.total_price, t.weight, t.product_id\n" + - " from order_temp t LEFT JOIN supermarket s on t.supermarket_id = s.id AND s.type = 0\n" + + " from order_temp t LEFT JOIN supermarket s on t.supermarket_id = s.id \n" + " where t.state = 5 \n" + // " and t.create_time like ? \n" + " and t.create_time between ? and ? \n" + @@ -562,8 +585,7 @@ public class OrderStatService { " group by t.id, t.product_id\n" + " ) a on a.id = t.supermarket_id and a.product_id = t.product_id\n" + " left join supermarket s on s.id = t.supermarket_id\n" + - " left join product p on p.id = t.product_id AND p.del = 0" + - " where s.type = 0"; + " left join product p on p.id = t.product_id AND p.del = 0";*/ List dblist = Db.find(sql, params.toArray());