首页统计数据调整

当年销售统计时,不包含预售提货,需要包含当年的预售额合计
    当月销售统计时,不包含预售提货,需要包含当月的预售额合计
    当日销售统计时,不包含预售提货,需要包含当日的预售额合计
dev
wuwenxiong 2022-02-15 10:55:06 +08:00
parent 72aaf684a8
commit e23125c6dd
1 changed files with 24 additions and 23 deletions

View File

@ -126,7 +126,6 @@ group by date
*/ */
public Record stat(Integer supermarket_id) { public Record stat(Integer supermarket_id) {
long st = System.currentTimeMillis();
Record out = new Record(); Record out = new Record();
Date now = new Date(); Date now = new Date();
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
@ -146,54 +145,56 @@ group by date
Date year = c.getTime(); // 当年 Date year = c.getTime(); // 当年
String sql_ordercluster = "select \n" + String sql_ordercluster = "select \n" +
" ifnull(sum(t.weight), 0) total_weight,\n" + " ifnull(sum(g.total_weight), 0) total_weight,\n" +
" ifnull(sum(t.total_price), 0) total_price,\n" + " ifnull(sum(g.total_price), 0) total_price,\n" +
" ifnull(count(t.sn), 0) truck_cnt,\n" + " ifnull(sum(g.truck_cnt), 0) truck_cnt,\n" +
" \n" +
" ifnull(sum(case when t.create_time >= ? then t.weight end ), 0) day_total_weight,\n" +
" ifnull(sum(case when t.create_time >= ? then t.total_price end ), 0) day_total_price,\n" +
" ifnull(sum(case when t.create_time >= ? then 1 else 0 end ), 0) day_truck_cnt\n" +
" \n" +
" from order_temp t\n" +
" where t.state = ?";
String sql_ordercluster_presell = "select \n" +
" ifnull(sum(g.year_total_weight), 0) year_total_weight,\n" + " ifnull(sum(g.year_total_weight), 0) year_total_weight,\n" +
" ifnull(sum(g.year_total_price), 0) year_total_price,\n" + " ifnull(sum(g.year_total_price), 0) year_total_price,\n" +
" ifnull(sum(g.year_truck_cnt), 0) year_truck_cnt,\n" + " ifnull(sum(g.year_truck_cnt), 0) year_truck_cnt,\n" +
" ifnull(sum(g.month_total_weight), 0) month_total_weight,\n" + " ifnull(sum(g.month_total_weight), 0) month_total_weight,\n" +
" ifnull(sum(g.month_total_price), 0) month_total_price,\n" + " ifnull(sum(g.month_total_price), 0) month_total_price,\n" +
" ifnull(sum(g.month_truck_cnt), 0) month_truck_cnt\n" + " ifnull(sum(g.month_truck_cnt), 0) month_truck_cnt,\n" +
" ifnull(sum(g.day_total_weight), 0) day_total_weight,\n" +
" ifnull(sum(g.day_total_price), 0) day_total_price,\n" +
" ifnull(sum(g.day_truck_cnt), 0) day_truck_cnt\n" +
" from \n" + " from \n" +
" (\n" + " (\n" +
" select \n" + " select \n" +
" ifnull(sum(t.weight), 0) total_weight,\n" +
" ifnull(sum(t.total_price), 0) total_price,\n" +
" ifnull(count(t.sn), 0) truck_cnt,\n" +
" ifnull(sum(case when t.create_time >= ? then t.weight end ), 0) year_total_weight,\n" + " ifnull(sum(case when t.create_time >= ? then t.weight end ), 0) year_total_weight,\n" +
" ifnull(sum(case when t.create_time >= ? then t.total_price end ), 0) year_total_price,\n" + " ifnull(sum(case when t.create_time >= ? then t.total_price end ), 0) year_total_price,\n" +
" ifnull(sum(case when t.create_time >= ? then 1 else 0 end ), 0) year_truck_cnt,\n" + " ifnull(sum(case when t.create_time >= ? then 1 else 0 end ), 0) year_truck_cnt,\n" +
" ifnull(sum(case when t.create_time >= ? then t.weight end ), 0) month_total_weight,\n" + " ifnull(sum(case when t.create_time >= ? then t.weight end ), 0) month_total_weight,\n" +
" ifnull(sum(case when t.create_time >= ? then t.total_price end ), 0) month_total_price,\n" + " ifnull(sum(case when t.create_time >= ? then t.total_price end ), 0) month_total_price,\n" +
" ifnull(sum(case when t.create_time >= ? then 1 else 0 end ), 0) month_truck_cnt\n" + " ifnull(sum(case when t.create_time >= ? then 1 else 0 end ), 0) month_truck_cnt,\n" +
" ifnull(sum(case when t.create_time >= ? then t.weight end ), 0) day_total_weight,\n" +
" ifnull(sum(case when t.create_time >= ? then t.total_price end ), 0) day_total_price,\n" +
" ifnull(sum(case when t.create_time >= ? then 1 else 0 end ), 0) day_truck_cnt\n" +
" from order_temp t\n" + " from order_temp t\n" +
" where t.sale_type = 0\n" + " where t.sale_type = 0\n" +
" and t.state = 5\n" + " and t.state = 5\n" +
" union\n" + " union\n" +
" select \n" + " select \n" +
" 0 total_weight,\n" +
" ifnull(sum(p.presell_amount), 0) total_price,\n" +
" 0 truck_cnt,\n" +
" 0 year_total_weight,\n" + " 0 year_total_weight,\n" +
" ifnull(sum(case when p.presell_date >= ? then p.presell_amount end ), 0) year_total_price,\n" + " ifnull(sum(case when p.presell_date >= ? then p.presell_amount end ), 0) year_total_price,\n" +
" 0 year_truck_cnt,\n" + " 0 year_truck_cnt,\n" +
" 0 month_total_weight,\n" + " 0 month_total_weight,\n" +
" ifnull(sum(case when p.presell_date >= ? then p.presell_amount end ), 0) month_total_price,\n" + " ifnull(sum(case when p.presell_date >= ? then p.presell_amount end ), 0) month_total_price,\n" +
" 0 month_truck_cnt\n" + " 0 month_truck_cnt,\n" +
" 0 day_total_weight,\n" +
" ifnull(sum(case when p.presell_date >= ? then p.presell_amount end ), 0) day_total_price,\n" +
" 0 day_truck_cnt\n" +
" from presell_order p\n" + " from presell_order p\n" +
" where p.del = 0\n" + " where p.del = 0\n" +
" ) g"; " ) g";
Record ret = new Record(); Record ocout = Db.findFirst(sql_ordercluster, year, year, year, month, month, month, day, day, day, year, month, day);
Record ocout = Db.findFirst(sql_ordercluster, day, day, day, OrderStateEnum.RECEIVED.getStateid()); out.set("ordercluster", ocout);
Record presell = Db.findFirst(sql_ordercluster_presell, year, year, year, month, month, month, year, month);
ret.setColumns(ocout).setColumns(presell);
out.set("ordercluster", ret);
return out; return out;
} }