优化-4
parent
8f20a3bc7d
commit
6e08312df8
|
|
@ -2726,16 +2726,23 @@ public class OrderStatService {
|
|||
"OR id = 11");
|
||||
|
||||
// 预售金额统计
|
||||
List<Object> paraList = new ArrayList<>();
|
||||
List<Object> paraList1 = new ArrayList<>();
|
||||
List<Object> paraList2 = new ArrayList<>();
|
||||
String paramsSql = "";
|
||||
String paramsSql2 = "";
|
||||
if (!StrKit.isBlank(stm)) {
|
||||
paramsSql += " and p.create_time >= ?\n";
|
||||
paraList.add(stm);
|
||||
paramsSql += " and t.create_time >= ?\n";
|
||||
paramsSql2 += " and p.create_time >= ?\n";
|
||||
paraList1.add(stm);
|
||||
paraList2.add(stm);
|
||||
}
|
||||
if (!StrKit.isBlank(etm)) {
|
||||
paramsSql += " and p.create_time <= ?\n";
|
||||
paraList.add(etm);
|
||||
paramsSql += " and t.create_time <= ?\n";
|
||||
paramsSql2 += " and p.create_time >= ?\n";
|
||||
paraList1.add(etm);
|
||||
paraList2.add(stm);
|
||||
}
|
||||
paraList1.addAll(paraList2);
|
||||
String sql = " SELECT c.name, t.* from (\n" +
|
||||
" select\n" +
|
||||
" g.customer_id,\n" +
|
||||
|
|
@ -2756,35 +2763,27 @@ public class OrderStatService {
|
|||
" ifnull(sum(case when g.supermarket_id = 6 or g.supermarket_id = 8 or g.supermarket_id = 10 then g.pug_amount end), 0) xse_6,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 11 then g.pug_amount end), 0) xse_11\n" +
|
||||
" from (\n" +
|
||||
" SELECT\n" +
|
||||
" p.customer_id,\n" +
|
||||
" p.supermarket_id,\n" +
|
||||
" ifnull(sum(p.presell_amount), 0) presell_amount,\n" +
|
||||
" ifnull(sum(g.total_price), 0) pug_amount\n" +
|
||||
" FROM\n" +
|
||||
" presell_order p\n" +
|
||||
" left join ( \n" +
|
||||
" SELECT\n" +
|
||||
" o.presell_order_id,\n" +
|
||||
" ifnull(SUM(d.total_price), 0) total_price\n" +
|
||||
" FROM\n" +
|
||||
" `order_temp` d\n" +
|
||||
" LEFT JOIN ordercluster o ON d.ordercluster_id = o.id\n" +
|
||||
" WHERE\n" +
|
||||
" d.sale_type = 1\n" +
|
||||
" AND d.state = 5\n" +
|
||||
" GROUP BY\n" +
|
||||
" o.presell_order_id" + ") g on g.presell_order_id = p.id\n" +
|
||||
" WHERE\n" +
|
||||
" p.del = 0\n" +
|
||||
paramsSql +
|
||||
" GROUP BY\n" +
|
||||
" p.customer_id,\n" +
|
||||
" p.supermarket_id\n" +
|
||||
" select a.customer_id, a.supermarket_id, sum(a.presell_amount) presell_amount, sum(a.pug_amount) pug_amount from (\n" +
|
||||
" select t.customer_id, t.supermarket_id, sum(t.presell_amount) presell_amount, 0 pug_amount from presell_order t\n" +
|
||||
" where t.del = 0\n" +
|
||||
paramsSql +
|
||||
" group by t.customer_id, t.supermarket_id\n" +
|
||||
" \n" +
|
||||
" union\n" +
|
||||
" \n" +
|
||||
" select t.customer_id, t.supermarket_id, 0 presell_amount, sum(t.total_price) pug_amount from order_temp t\n" +
|
||||
" left join ordercluster c on c.id = t.ordercluster_id\n" +
|
||||
" left join presell_order p on p.id = c.presell_order_id\n" +
|
||||
" where t.sale_type = 1\n" +
|
||||
" and t.state = 5\n" +
|
||||
paramsSql2 +
|
||||
" group by t.customer_id, t.supermarket_id\n" +
|
||||
" ) a\n" +
|
||||
" group by a.customer_id, a.supermarket_id\n" +
|
||||
" ) g group by g.customer_id \n" +
|
||||
" ) t LEFT JOIN customer c ON c.id = t.customer_id";
|
||||
|
||||
List<Record> list = Db.find(sql, paraList.toArray());
|
||||
List<Record> list = Db.find(sql, paraList1.toArray());
|
||||
List<Record> ret = new ArrayList<>();
|
||||
double all_total_presell_amount = 0.0;
|
||||
double all_total_presell_pug = 0.0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue