bug修改

dev
wany 2025-03-11 13:32:56 +08:00
parent b29dde7150
commit 5f7aa01ab2
2 changed files with 26 additions and 4 deletions

View File

@ -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);
}

View File

@ -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<Record> dblist = Db.find(sql, params.toArray());