diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java index ef3b1f8..298b4d7 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java @@ -98,7 +98,7 @@ public class OrderStatService { if (customer_type_id != null && customer_type_id >= 0 && customer_type_id != 99) { temp_sql += " and c.customer_type_id = ? \n"; paraTempList.add(customer_type_id); - } else if(customer_type_id != null && customer_type_id == 99) { // 散户 + } else if (customer_type_id != null && customer_type_id == 99) { // 散户 temp_sql += " and t.customer_id is null \n"; } } @@ -331,9 +331,9 @@ public class OrderStatService { * @return */ public Record monthgrid(String tm, Integer supermarket_id, Integer customer_id, Boolean stat_product, Integer product_id) { - String sql; - String paramsSql = ""; - List paraList = new ArrayList<>(); + String sql; + String paramsSql = ""; + List paraList = new ArrayList<>(); paraList.add(OrderStateEnum.RECEIVED.getStateid()); paraList.add(tm + "%"); @@ -349,12 +349,12 @@ public class OrderStatService { } // 使用实际支付金额统计 - if(stat_product){ - if(product_id != null && product_id > 0){ + if (stat_product) { + if (product_id != null && product_id > 0) { paramsSql += " and t.product_id = ? \n"; paraList.add(product_id); } - sql ="select ifnull(max(t.customer_id), t.customer_name) customer_id, ifnull(t.customer_name, '民用') customer_name, t.supermarket_id, max(s.name) supermarket_name, count(*) cnt, sum(t.total_price) total,t.product_id, t.product_name \n"+ + sql = "select ifnull(max(t.customer_id), t.customer_name) customer_id, ifnull(t.customer_name, '民用') customer_name, t.supermarket_id, max(s.name) supermarket_name, count(*) cnt, sum(t.total_price) total,t.product_id, t.product_name \n" + " from (\n" + " select t.customer_id, t.customer_name , t.supermarket_id, t.paid, t.total_price,t.product_id, t.product_name, 3 type \n" + " from order_temp t\n" + @@ -362,7 +362,7 @@ public class OrderStatService { " and t.create_time like ?\n" + " ) t\n" + " left join supermarket s on s.id = t.supermarket_id\n" + - " where 1 = 1 \n"+ + " where 1 = 1 \n" + paramsSql + " group by t.customer_name, t.supermarket_id, t.product_id, t.product_name"; } else { @@ -513,7 +513,7 @@ public class OrderStatService { * @return */ public List salestat(String tm) { - String sql = "select s.id, s.name, s.name2, p.`name` product_name, ifnull(a.orderCount, 0) as orderCount, ifnull(a.totalPrice, 0) as totalPrice, ifnull(a.weight, 0) as weight\n" + + 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" + @@ -556,69 +556,113 @@ public class OrderStatService { * @param tm * @return */ - public List salestatCustomer(String tm, Integer invoice_type, Boolean stat_product) { + public List salestatCustomer(String tm, Integer invoice_type, Boolean stat_product, Integer customer_id, Integer customer_type_id) { + List paraList = new ArrayList<>(); + paraList.add(OrderStateEnum.RECEIVED.getStateid()); + paraList.add(tm + "%"); - List dblist = null; + String sql; if (invoice_type != null) { - if(stat_product){ - dblist = Db.find("select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType,t.product_name\n" + - " from (\n" + - " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type,t.product_id,t.product_name\n" + - " from order_temp t\n" + - " where t.state = ? \n" + - " and t.invoice_type = ? \n" + - " and t.create_time like ? \n" + - " ) t\n" + - " group by t.customer_name,t.product_id,t.product_name", - OrderStateEnum.RECEIVED.getStateid(), - invoice_type, - tm + "%"); - }else { - dblist = Db.find("select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType\n" + - " from (\n" + - " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type\n" + - " from order_temp t\n" + - " where t.state = ? \n" + - " and t.invoice_type = ? \n" + - " and t.create_time like ? \n" + - " ) t\n" + - " group by t.customer_name", - OrderStateEnum.RECEIVED.getStateid(), - invoice_type, - tm + "%"); + paraList.add(invoice_type); + + if (stat_product) { + sql = "select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType,t.product_id, t.product_name\n" + + " from (\n" + + " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type,t.product_id,t.product_name\n" + + " from order_temp t\n" + + " left join customer c on c.id = t.customer_id \n" + + " where t.state = ? \n" + + " and t.create_time like ? \n" + + " and t.invoice_type = ? \n"; + if (customer_id != null) { + sql += " and c.id = ? \n"; + paraList.add(customer_id); + } else if (customer_type_id != null) { + if (customer_type_id == 99) { + sql += " and t.customer_id is null \n"; + } else { + sql += " and c.customer_type_id = ? \n"; + paraList.add(customer_type_id); + } + } + + sql += " ) t\n" + + " group by t.customer_name,t.product_id,t.product_name"; + + } else { + sql = "select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType\n" + + " from (\n" + + " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type\n" + + " from order_temp t\n" + + " left join customer c on c.id = t.customer_id \n" + + " where t.state = ? \n" + + " and t.create_time like ? \n" + + " and t.invoice_type = ? \n"; + if (customer_id != null) { + sql += " and c.id = ? \n"; + paraList.add(customer_id); + } else if (customer_type_id != null) { + if (customer_type_id == 99) { + sql += " and t.customer_id is null \n"; + } else { + sql += " and c.customer_type_id = ? \n"; + paraList.add(customer_type_id); + } + } + + sql += " ) t\n" + + " group by t.customer_name"; } - - } else { - if(stat_product){ - dblist = Db.find("select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType,t.product_name\n" + - " from (\n" + - " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type,t.product_id,t.product_name\n" + - " from order_temp t\n" + - " where t.state = ? \n" + - " and t.create_time like ? \n" + - " ) t\n" + - " group by t.customer_name,t.product_id,t.product_name", - OrderStateEnum.RECEIVED.getStateid(), - tm + "%" - ); - }else { - dblist = Db.find("select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType\n" + - " from (\n" + - " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type\n" + - " from order_temp t\n" + - " where t.state = ? \n" + - " and t.create_time like ? \n" + - " ) t\n" + - " group by t.customer_name", - OrderStateEnum.RECEIVED.getStateid(), - tm + "%" - ); - } + if (stat_product) { + sql = "select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType,t.product_id,t.product_name\n" + + " from (\n" + + " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type,t.product_id,t.product_name\n" + + " from order_temp t\n" + + " left join customer c on c.id = t.customer_id \n" + + " where t.state = ? \n" + + " and t.create_time like ? \n"; + if (customer_id != null) { + sql += " and c.id = ? \n"; + paraList.add(customer_id); + } else if (customer_type_id != null) { + if (customer_type_id == 99) { + sql += " and t.customer_id is null \n"; + } else { + sql += " and c.customer_type_id = ? \n"; + paraList.add(customer_type_id); + } + } + sql += " ) t\n" + + " group by t.customer_name,t.product_id,t.product_name"; + } else { + sql = "select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType\n" + + " from (\n" + + " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type\n" + + " from order_temp t\n" + + " left join customer c on c.id = t.customer_id \n" + + " where t.state = ? \n" + + " and t.create_time like ? \n"; + if (customer_id != null) { + sql += " and c.id = ? \n"; + paraList.add(customer_id); + } else if (customer_type_id != null) { + if (customer_type_id == 99) { + sql += " and t.customer_id is null \n"; + } else { + sql += " and c.customer_type_id = ? \n"; + paraList.add(customer_type_id); + } + } + + sql += " ) t\n" + + " group by t.customer_name"; + } } - Record total = new Record(); + List dblist = Db.find(sql, paraList.toArray()); + Record total = new Record(); total.set("id", 0); total.set("name", "合计"); total.set("orderCount", 0); @@ -671,6 +715,22 @@ public class OrderStatService { return salestatExport(tm, title, subtitle); } + public Workbook yearsalestatExport(String tm) { + String title = "销售年统计"; + + // 副标题 start + String subtitle = ""; + try { + subtitle += DateTimeUtil.sdfym.get().format(DateTimeUtil.sd.get().parse(tm)); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + + subtitle += title; + + return salestatExport(tm, title, subtitle); + } + /** * 销售日、月统计 @@ -740,8 +800,8 @@ public class OrderStatService { * @param tm * @return */ - public Workbook salestatCustomerExport(String tm, String title, String subtitle, Integer invoice_type, Boolean stat_product) { - List list = salestatCustomer(tm, invoice_type, stat_product); + public Workbook salestatCustomerExport(String tm, String title, String subtitle, Integer invoice_type, Boolean stat_product, Integer customer_id, Integer customer_type_id) { + List list = salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id); Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(title); @@ -797,7 +857,7 @@ public class OrderStatService { } - public Workbook daysalestatCustomerExport(String tm, Integer invoice_type, Boolean stat_product) { + public Workbook daysalestatCustomerExport(String tm, Integer invoice_type, Boolean stat_product, Integer customer_id, Integer customer_type_id) { String title = "销售日统计"; @@ -811,10 +871,10 @@ public class OrderStatService { subtitle += title; - return salestatCustomerExport(tm, title, subtitle, invoice_type, stat_product); + return salestatCustomerExport(tm, title, subtitle, invoice_type, stat_product, customer_id, customer_type_id); } - public Workbook monthsalestatCustomerExport(String tm, Integer invoice_type, Boolean stat_product) { + public Workbook monthsalestatCustomerExport(String tm, Integer invoice_type, Boolean stat_product, Integer customer_id, Integer customer_type_id) { String title = "销售月统计"; // 副标题 start @@ -827,18 +887,19 @@ public class OrderStatService { subtitle += title; - return salestatCustomerExport(tm, title, subtitle, invoice_type, stat_product); + return salestatCustomerExport(tm, title, subtitle, invoice_type, stat_product, customer_id, customer_type_id); } /** * 销售月逐日统计 + * * @param stm * @param etm * @param supermarket_id * @return */ public List mdstat(String stm, String etm, Integer supermarket_id, Boolean stat_product, Integer product_id) { - String sql; + String sql; List paramsArray = new ArrayList<>(); paramsArray.add(OrderStateEnum.RECEIVED.getStateid()); paramsArray.add(stm); @@ -849,7 +910,7 @@ public class OrderStatService { productParams += " and t.supermarket_id = ?\n"; paramsArray.add(supermarket_id); } - if(stat_product){ + if (stat_product) { if (product_id != null && product_id > 0) { productParams += " and t.product_id = ?\n"; paramsArray.add(product_id); @@ -914,6 +975,7 @@ public class OrderStatService { /** * 销售月逐日统计 + * * @param stm * @param etm * @param supermarket_id @@ -998,7 +1060,7 @@ public class OrderStatService { * @return */ public List statTrans(String tm, String stm, String etm, Integer supermarket_id, boolean stat_product, Integer product_id, Integer isprepaid) { - String temp_sql; + String temp_sql; List paraTemp = new ArrayList<>(); if (stat_product) { @@ -1204,24 +1266,24 @@ public class OrderStatService { * @param isprepaid 是否预付费 * @return */ - public List statCustomer(String tm, String stm, String etm, Integer supermarket_id, Integer customer_id, String customer_ids, boolean stat_product, Integer product_id, Integer isprepaid) { + public List statCustomer(String tm, String stm, String etm, Integer supermarket_id, Integer customer_id, String customer_ids, Integer customer_type_id, boolean stat_product, Integer product_id, Integer isprepaid) { String temp_sql = " select t.customer_id, t.customer_name, t.weight, t.total_price, t.sn, t.product_id, t.product_name "; - List paraTemp = new ArrayList<>(); + List paraList = new ArrayList<>(); temp_sql += " from order_temp t\n" + " where t.state = ? \n"; - paraTemp.add(OrderStateEnum.RECEIVED.getStateid()); + paraList.add(OrderStateEnum.RECEIVED.getStateid()); if (supermarket_id != null) { temp_sql += " and t.supermarket_id = ? \n"; - paraTemp.add(supermarket_id); + paraList.add(supermarket_id); } if (customer_id != null) { temp_sql += " and t.customer_id = ? \n"; - paraTemp.add(customer_id); + paraList.add(customer_id); } if (StrKit.notBlank(customer_ids)) { @@ -1239,7 +1301,7 @@ public class OrderStatService { temp_sql += "?"; - paraTemp.add(cid); + paraList.add(cid); } temp_sql += " ) \n"; @@ -1252,16 +1314,16 @@ public class OrderStatService { return new ArrayList<>(); } temp_sql += " and t.create_time between ? and ? \n"; - paraTemp.add(stm); - paraTemp.add(etm); + paraList.add(stm); + paraList.add(etm); } else { temp_sql += " and t.create_time like ? \n"; - paraTemp.add(tm + "%"); + paraList.add(tm + "%"); } if (isprepaid != null) { temp_sql += " and t.isprepaid = ? \n"; - paraTemp.add(isprepaid); + paraList.add(isprepaid); } String sql; @@ -1269,25 +1331,37 @@ public class OrderStatService { if (stat_product) { if (product_id != null) { temp_sql += " and t.product_id = ? \n"; - paraTemp.add(product_id); + paraList.add(product_id); } sql = "select ifnull(a.customer_name, '民用') customer_name, max(a.customer_id) customer_id, sum(a.weight) weight, sum(a.total_price) total_price, count(a.sn) orderCount, a.product_id, max(a.product_name) product_name \n" + " from( \n" + temp_sql + " ) a\n" + - " left join customer c on c.id = a.customer_id \n" + - " group by a.customer_name, a.product_id "; + " left join customer c on c.id = a.customer_id \n"; + + if (customer_id == null && StrKit.isBlank(customer_ids) && customer_type_id != null) { + sql += " where c.customer_type_id = ? \n"; + paraList.add(customer_type_id); + } + + sql += " group by a.customer_name, a.product_id \n"; } else { sql = "select ifnull(a.customer_name, '民用') customer_name, max(a.customer_id) customer_id, sum(a.weight) weight, sum(a.total_price) total_price, count(a.sn) orderCount \n" + " from( \n" + temp_sql + " ) a\n" + - " left join customer c on c.id = a.customer_id \n" + - " group by a.customer_name "; + " left join customer c on c.id = a.customer_id \n"; + + if (customer_id == null && StrKit.isBlank(customer_ids) && customer_type_id != null) { + sql += " where c.customer_type_id = ? \n"; + paraList.add(customer_type_id); + } + + sql += " group by a.customer_name \n"; } - List list = Db.find(sql, paraTemp.toArray()); + List list = Db.find(sql, paraList.toArray()); // 只有一个统计总数为 0 的记录时,删除该记录后返回 if (list != null && list.size() == 1) { @@ -1301,11 +1375,11 @@ public class OrderStatService { return list; } - public Workbook statCustomerExport(String name, String tm, String stm, String etm, Integer supermarket_id, Integer customer_id, String customer_ids, boolean stat_product, Integer product_id, Integer isprepaid) { + public Workbook statCustomerExport(String name, String tm, String stm, String etm, Integer supermarket_id, Integer customer_id, String customer_ids, Integer customer_type_id, boolean stat_product, Integer product_id, Integer isprepaid) { Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(name); - List list = statCustomer(tm, stm, etm, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); + List list = statCustomer(tm, stm, etm, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid); int datalen = list.size(); int end_col = stat_product ? 6 : 5; // 数据共有几列 @@ -1392,7 +1466,7 @@ public class OrderStatService { public List yearStatBySup(String year, Boolean stat_product) { List list; if (StrKit.notBlank(year)) { - if(stat_product){ + if (stat_product) { list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight,a.product_id,a.product_name from supermarket s\n" + "left join (\n" + " select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name from order_temp t\n" + @@ -1400,7 +1474,7 @@ public class OrderStatService { " and t.create_time like ? \n" + " group by t.supermarket_id,t.product_id,t.product_name\n" + ") a on s.id = a.id order by s.id", year + "%"); - }else { + } else { list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight from supermarket s\n" + "left join (\n" + " select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" + @@ -1411,14 +1485,14 @@ public class OrderStatService { } } else { - if(stat_product){ + if (stat_product) { list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight,a.product_id,a.product_name from supermarket s\n" + "left join (\n" + " select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name from order_temp t\n" + " where t.state = 5\n" + " group by t.supermarket_id,t.product_id,t.product_name\n" + ") a on s.id = a.id order by s.id"); - }else { + } else { list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight from supermarket s\n" + "left join (\n" + " select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" + @@ -1497,28 +1571,30 @@ public class OrderStatService { public List yearStatBySup(String stm, String etm, Boolean stat_product, Integer product_id) { List list; - String paramsSql = ""; + String paramsSql = ""; List paramsArray = new ArrayList<>(); paramsArray.add(stm); paramsArray.add(etm); if (stat_product) { - if(product_id != null && product_id > 0){ - paramsSql+=" and t.product_id=? \n"; + if (product_id != null && product_id > 0) { + paramsSql += " and t.product_id=? \n"; paramsArray.add(product_id); } list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight ,a.product_id,a.product_name from supermarket s\n" + "left join (\n" + - " select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name from order_temp t\n" + + " select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name \n" + + " from order_temp t\n" + " where t.state = 5\n" + " and t.create_time >= ? \n" + " and t.create_time <= ? \n" + - paramsSql+ + paramsSql + " group by t.supermarket_id,t.product_id,t.product_name\n" + ") a on s.id = a.id order by s.id", paramsArray.toArray()); - }else { + } else { list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight from supermarket s\n" + "left join (\n" + - " select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" + + " select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight \n" + + " from order_temp t\n" + " where t.state = 5\n" + " and t.create_time >= ? \n" + " and t.create_time <= ? \n" + @@ -1550,7 +1626,7 @@ public class OrderStatService { return list; } - public Workbook yearStatBySupExport(String stm, String etm, Boolean stat_product,Integer product_id) { + public Workbook yearStatBySupExport(String stm, String etm, Boolean stat_product, Integer product_id) { List list = yearStatBySup(stm, etm, stat_product, product_id); Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + etm.substring(0, 10) + "年销售汇总"); @@ -1576,7 +1652,7 @@ public class OrderStatService { } else { row.createCell(a++).setCellValue(""); } - row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_weight")); + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "weight")); row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price")); } @@ -1585,46 +1661,114 @@ public class OrderStatService { return wb; } - public List yearStatByCustomer(String year, Boolean stat_product) { + public List yearStatByCustomer(String year, Boolean stat_product, Integer customer_id, Integer customer_type_id) { List list; if (StrKit.notBlank(year)) { - if(stat_product){ - list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus ,a.product_id,a.product_name from (\n" + - " select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name from order_temp t\n" + + if (stat_product) { + List paraList = new ArrayList<>(); + paraList.add(year + "%"); + String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus ,a.product_id,a.product_name from (\n" + + " select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight,t.product_id,t.product_name, c.name customer_name \n" + + " from order_temp t\n" + + " left join customer c on c.id = t.customer_id\n" + " where t.state = 5\n" + - " and t.create_time like ? \n" + - " group by t.customer_id,t.product_id,t.product_name\n" + + " and t.create_time like ? \n"; + + if (customer_id != null) { + sql += " and c.id = ? \n"; + paraList.add(customer_id); + } else if (customer_type_id != null) { + if (customer_type_id == 99) { + sql += " and t.customer_id is null \n"; + } else { + sql += " and c.customer_type_id = ? \n"; + paraList.add(customer_type_id); + } + } + + sql += " group by t.customer_id,t.product_id,t.product_name\n" + " ) a\n" + - " left join customer c on c.id = a.id\n" + - " left join prepay_customer p on p.customer_id = a.id", year + "%"); - }else { - list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus from (\n" + - " select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" + + " left join prepay_customer p on p.customer_id = a.id"; + list = Db.find(sql, paraList.toArray()); + } else { + List paraList = new ArrayList<>(); + paraList.add(year + "%"); + String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus from (\n" + + " select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight, c.name customer_name \n" + + " from order_temp t\n" + + " left join customer c on c.id = t.customer_id\n" + " where t.state = 5\n" + - " and t.create_time like ? \n" + - " group by t.customer_id\n" + + " and t.create_time like ? \n"; + + if (customer_id != null) { + sql += " and c.id = ? \n"; + paraList.add(customer_id); + } else if (customer_type_id != null) { + if (customer_type_id == 99) { + sql += " and t.customer_id is null \n"; + } else { + sql += " and c.customer_type_id = ? \n"; + paraList.add(customer_type_id); + } + } + + sql += " group by t.customer_id\n" + " ) a\n" + - " left join customer c on c.id = a.id\n" + - " left join prepay_customer p on p.customer_id = a.id", year + "%"); + " left join prepay_customer p on p.customer_id = a.id"; + + list = Db.find(sql, paraList.toArray()); } } else { - if(stat_product){ - list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus,a.product_id,a.product_name from (\n" + - " select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name from order_temp t\n" + - " where t.state = 5\n" + - " group by t.customer_id,t.product_id,t.product_name\n" + + if (stat_product) { + List paraList = new ArrayList<>(); + String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus,a.product_id,a.product_name from (\n" + + " select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight,t.product_id,t.product_name, c.name customer_name \n" + + " from order_temp t\n" + + " left join customer c on c.id = t.customer_id\n" + + " where t.state = 5\n"; + + if (customer_id != null) { + sql += " and c.id = ? \n"; + paraList.add(customer_id); + } else if (customer_type_id != null) { + if (customer_type_id == 99) { + sql += " and t.customer_id is null \n"; + } else { + sql += " and c.customer_type_id = ? \n"; + paraList.add(customer_type_id); + } + } + + sql += " group by t.customer_id,t.product_id,t.product_name\n" + " ) a\n" + - " left join customer c on c.id = a.id\n" + - " left join prepay_customer p on p.customer_id = a.id"); - }else { - list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus from (\n" + - " select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" + - " where t.state = 5\n" + - " group by t.customer_id\n" + + " left join prepay_customer p on p.customer_id = a.id"; + + list = Db.find(sql, paraList.toArray()); + } else { + List paraList = new ArrayList<>(); + String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus from (\n" + + " select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight, c.name customer_name \n" + + " from order_temp t\n" + + " left join customer c on c.id = t.customer_id\n" + + " where t.state = 5\n"; + + if (customer_id != null) { + sql += " and c.id = ? \n"; + paraList.add(customer_id); + } else if (customer_type_id != null) { + if (customer_type_id == 99) { + sql += " and t.customer_id is null \n"; + } else { + sql += " and c.customer_type_id = ? \n"; + paraList.add(customer_type_id); + } + } + + sql += " group by t.customer_id\n" + " ) a\n" + - " left join customer c on c.id = a.id\n" + - " left join prepay_customer p on p.customer_id = a.id"); + " left join prepay_customer p on p.customer_id = a.id"; + list = Db.find(sql, paraList.toArray()); } } @@ -1632,28 +1776,27 @@ public class OrderStatService { Record hj = new Record(); hj.set("id", 0); hj.set("name", "合计"); - hj.set("cnt", 0); - hj.set("total_price", new BigDecimal(0)); - hj.set("total_weight", new BigDecimal(0)); - hj.set("total_weight", new BigDecimal(0)); - hj.set("total_surplus", new BigDecimal(0)); + hj.set("orderCount", 0); + hj.set("totalPrice", new BigDecimal(0)); + hj.set("weight", new BigDecimal(0)); + hj.set("totalSurplus", new BigDecimal(0)); for (Record record : list) { - if (record.get("cnt") != null) { - hj.set("cnt", hj.getInt("cnt") + record.getInt("cnt")); + if (record.get("orderCount") != null) { + hj.set("orderCount", hj.getInt("orderCount") + record.getInt("orderCount")); } - if (record.get("total_price") != null) { - hj.set("total_price", hj.getBigDecimal("total_price").add(record.getBigDecimal("total_price"))); + if (record.get("totalPrice") != null) { + hj.set("totalPrice", hj.getBigDecimal("totalPrice").add(record.getBigDecimal("totalPrice"))); } - if (record.get("total_weight") != null) { - hj.set("total_weight", hj.getBigDecimal("total_weight").add(record.getBigDecimal("total_weight"))); + if (record.get("weight") != null) { + hj.set("weight", hj.getBigDecimal("weight").add(record.getBigDecimal("weight"))); } - if (record.get("total_surplus") != null) { - hj.set("total_surplus", hj.getBigDecimal("total_surplus").add(record.getBigDecimal("total_surplus"))); + if (record.get("totalSurplus") != null) { + hj.set("totalSurplus", hj.getBigDecimal("totalSurplus").add(record.getBigDecimal("totalSurplus"))); } } - hj.set("total_account_surplus", hj.getBigDecimal("total_surplus").add(hj.getBigDecimal("total_price"))); + hj.set("total_account_surplus", hj.getBigDecimal("totalSurplus").add(hj.getBigDecimal("totalPrice"))); list.add(hj); @@ -1661,8 +1804,8 @@ public class OrderStatService { } - public Workbook yearStatByCustomerExport(String year, Boolean stat_product) { - List list = yearStatByCustomer(year, stat_product); + public Workbook yearStatByCustomerExport(String year, Boolean stat_product, Integer customer_id, Integer customer_type_id) { + List list = yearStatByCustomer(year, stat_product, customer_id, customer_type_id); Workbook wb = new XSSFWorkbook(); Sheet sheet; @@ -1697,10 +1840,10 @@ public class OrderStatService { } row.createCell(a++).setCellValue(order.getStr("name")); - row.createCell(a++).setCellValue(order.getInt("cnt")); - row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_weight")); - row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price")); - row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_surplus")); + row.createCell(a++).setCellValue(order.getInt("orderCount")); + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "weight")); + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "totalPrice")); + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "totalSurplus")); } if (hj != null) { @@ -1721,37 +1864,70 @@ public class OrderStatService { } - public List yearStatByCustomer(String stm, String etm, Boolean stat_product, Integer product_id) { + public List yearStatByCustomer(String stm, String etm, Boolean stat_product, Integer product_id, Integer customer_id, Integer customer_type_id) { List list; - String paramsSql = ""; + String paramsSql = ""; List paramsArray = new ArrayList<>(); paramsArray.add(stm); paramsArray.add(etm); - if(stat_product){ - if(product_id != null && product_id > 0){ - paramsSql +=" and t.product_id=? \n"; + if (stat_product) { + if (product_id != null && product_id > 0) { + paramsSql += " and t.product_id=? \n"; paramsArray.add(product_id); } - list = Db.find("select c.id id, ifnull(c.name, '零散') name, a.*, p.surplus total_surplus ,a.product_id,a.product_name from (\n" + - " select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name from order_temp t\n" + + + String sql = "select a.customer_id id, ifnull(a.customer_name, '零散') name, a.*, p.surplus total_surplus ,a.product_id,a.product_name from (\n" + + " select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name, c.id customer_id, c.name customer_name " + + " from order_temp t\n" + + " left join customer c on c.id = t.customer_id \n" + " where t.state = 5\n" + " and t.create_time >= ? \n" + " and t.create_time <= ? \n" + - paramsSql+ - " group by t.customer_id,t.product_id,t.product_name\n" + + paramsSql; + + if (customer_id != null) { + sql += " and c.id = ? \n"; + paramsArray.add(customer_id); + } else if (customer_type_id != null) { + if (customer_type_id == 99) { + sql += " and t.customer_id is null \n"; + } else { + sql += " and c.customer_type_id = ? \n"; + paramsArray.add(customer_type_id); + } + } + + sql += " group by t.customer_id,t.product_id,t.product_name\n" + " ) a\n" + - " left join customer c on c.id = a.id\n" + - " left join prepay_customer p on p.customer_id = a.id", paramsArray.toArray()); - }else { - list = Db.find("select c.id, ifnull(c.name, '零散') name, a.*, p.surplus total_surplus from (\n" + - " select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" + + " left join prepay_customer p on p.customer_id = a.id"; + + list = Db.find(sql, paramsArray.toArray()); + } else { + String sql = "select a.customer_id id, ifnull(a.customer_name, '零散') name, a.*, p.surplus total_surplus from (\n" + + " select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight, c.id customer_id, c.name customer_name" + + " from order_temp t\n" + + " left join customer c on c.id = t.customer_id \n" + " where t.state = 5\n" + " and t.create_time >= ? \n" + - " and t.create_time <= ? \n" + - " group by t.customer_id\n" + + " and t.create_time <= ? \n"; + + if (customer_id != null) { + sql += " and c.id = ? \n"; + paramsArray.add(customer_id); + } else if (customer_type_id != null) { + if (customer_type_id == 99) { + sql += " and t.customer_id is null \n"; + } else { + sql += " and c.customer_type_id = ? \n"; + paramsArray.add(customer_type_id); + } + } + + sql += " group by t.customer_id\n" + " ) a\n" + - " left join customer c on c.id = a.id\n" + - " left join prepay_customer p on p.customer_id = a.id", paramsArray.toArray()); + " left join prepay_customer p on p.customer_id = a.id"; + + list = Db.find(sql, paramsArray.toArray()); } Record hj = new Record(); @@ -1786,8 +1962,8 @@ public class OrderStatService { } - public Workbook yearStatByCustomerExport(String stm, String etm, Boolean stat_product, Integer product_id) { - List list = yearStatByCustomer(stm, etm, stat_product, product_id); + public Workbook yearStatByCustomerExport(String stm, String etm, Boolean stat_product, Integer product_id, Integer customer_id, Integer customer_type_id) { + List list = yearStatByCustomer(stm, etm, stat_product, product_id, customer_id, customer_type_id); Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + stm.substring(0, 10) + "时段销售汇总"); @@ -2008,13 +2184,13 @@ public class OrderStatService { customer_sale_list = Db.find(sql, stm, etm); } - List ids = new ArrayList<>(); - String cidsql = ""; + List ids = new ArrayList<>(); + String cidsql = ""; for (Record r : customer_sale_list) { ids.add(r.getStr("customer_id")); } - if(!ids.isEmpty()){ + if (!ids.isEmpty()) { cidsql = " c.id in(" + StrKit.join(ids, ",") + ") or "; } @@ -2119,21 +2295,21 @@ public class OrderStatService { for (Record r : list) { prepay_total_amount += DataUtil.getDefaultByRecord(r, "prepay_total_amount"); refund_total_amount += DataUtil.getDefaultByRecord(r, "refund_total_amount"); - prepay_surplus += DataUtil.getDefaultByRecord(r, "prepay_surplus"); - weight += DataUtil.getDefaultByRecord(r, "weight"); - total_price += DataUtil.getDefaultByRecord(r, "total_price"); - xsl_1 += DataUtil.getDefaultByRecord(r, "xsl_1"); - xsl_2 += DataUtil.getDefaultByRecord(r, "xsl_2"); - xsl_3 += DataUtil.getDefaultByRecord(r, "xsl_3"); - xsl_4 += DataUtil.getDefaultByRecord(r, "xsl_4"); - xsl_5 += DataUtil.getDefaultByRecord(r, "xsl_5"); - xsl_6 += DataUtil.getDefaultByRecord(r, "xsl_6"); - xse_1 += DataUtil.getDefaultByRecord(r, "xse_1"); - xse_2 += DataUtil.getDefaultByRecord(r, "xse_2"); - xse_3 += DataUtil.getDefaultByRecord(r, "xse_3"); - xse_4 += DataUtil.getDefaultByRecord(r, "xse_4"); - xse_5 += DataUtil.getDefaultByRecord(r, "xse_5"); - xse_6 += DataUtil.getDefaultByRecord(r, "xse_6"); + prepay_surplus += DataUtil.getDefaultByRecord(r, "prepay_surplus"); + weight += DataUtil.getDefaultByRecord(r, "weight"); + total_price += DataUtil.getDefaultByRecord(r, "total_price"); + xsl_1 += DataUtil.getDefaultByRecord(r, "xsl_1"); + xsl_2 += DataUtil.getDefaultByRecord(r, "xsl_2"); + xsl_3 += DataUtil.getDefaultByRecord(r, "xsl_3"); + xsl_4 += DataUtil.getDefaultByRecord(r, "xsl_4"); + xsl_5 += DataUtil.getDefaultByRecord(r, "xsl_5"); + xsl_6 += DataUtil.getDefaultByRecord(r, "xsl_6"); + xse_1 += DataUtil.getDefaultByRecord(r, "xse_1"); + xse_2 += DataUtil.getDefaultByRecord(r, "xse_2"); + xse_3 += DataUtil.getDefaultByRecord(r, "xse_3"); + xse_4 += DataUtil.getDefaultByRecord(r, "xse_4"); + xse_5 += DataUtil.getDefaultByRecord(r, "xse_5"); + xse_6 += DataUtil.getDefaultByRecord(r, "xse_6"); } record.set("prepay_total_amount", prepay_total_amount); @@ -2227,84 +2403,84 @@ public class OrderStatService { public Record yearStatisticsByCustomerId(String year, Integer customer_id, String customer_name, Integer type) { String sql; Record rec; - if (type == 1) { // 固定配额 - if (StrKit.isBlank(year) || customer_id == null) { - log.error("参数错误"); - return null; - } - sql = "SELECT\n" + - " c.*\n" + - "FROM\n" + - " (\n" + - " SELECT\n" + - " a.customer_id,\n" + - " u.name customer_name,\n" + - " a.total_price,\n" + - " a.total_weight, \n" + - " a.total_amount total_amount,\n" + - " r.surplus total_surplus\n" + - " FROM\n" + - " (\n" + - " SELECT\n" + - " ifnull(o.customer_id, - 1) customer_id,\n" + - " count(o.sn) cnt,\n" + - " o.state,\n" + - " o.create_time,\n" + - " p.total_amount total_amount,\n" + - " sum(o.total_price) total_price,\n" + - " sum(o.weight) total_weight\n" + - " FROM\n" + - " order_temp o\n" + - " LEFT JOIN (\n" + - " SELECT\n" + - " d.customer_id,\n" + - " sum(d.amount) total_amount\n" + - " FROM\n" + - " prepay_detail d\n" + - " WHERE\n" + - " d.state = 2\n" + - " AND d.verify_time LIKE ?\n" + - " GROUP BY\n" + - " d.customer_id\n" + - " ) p ON p.customer_id = o.customer_id\n" + - " WHERE\n" + - " o.state = 5\n" + - " AND o.create_time LIKE ?\n" + - " GROUP BY\n" + - " o.customer_id\n" + - " ) a\n" + - " LEFT JOIN customer u ON u.id = a.customer_id\n" + - " LEFT JOIN prepay_customer r ON r.customer_id = a.customer_id\n" + - " ) c\n" + - "WHERE\n" + - " c.`customer_name` IS NOT NULL and c.customer_id = ?"; - rec = Db.findFirst(sql, year + "%", year + "%", customer_id); - } else { // 零散配额 - if (StrKit.isBlank(year) || customer_name == null) { - log.error("参数错误"); - return null; - } - sql = "SELECT\n" + - " a.*\n" + - "FROM\n" + - " (\n" + - " SELECT\n" + - " o.customer_name,\n" + - " count(o.sn) cnt,\n" + - " sum(o.total_price) total_price,\n" + - " sum(o.weight) total_weight\n" + - " FROM\n" + - " order_temp o\n" + - " WHERE\n" + - " o.state = 5\n" + - " AND o.create_time LIKE ?\n" + - " GROUP BY\n" + - " o.customer_id\n" + - " ) a\n" + - "WHERE\n" + - " a.`customer_name` = ?"; - rec = Db.findFirst(sql, year + "%", customer_name); - } + if (type == 1) { // 固定配额 + if (StrKit.isBlank(year) || customer_id == null) { + log.error("参数错误"); + return null; + } + sql = "SELECT\n" + + " c.*\n" + + "FROM\n" + + " (\n" + + " SELECT\n" + + " a.customer_id,\n" + + " u.name customer_name,\n" + + " a.total_price,\n" + + " a.total_weight, \n" + + " a.total_amount total_amount,\n" + + " r.surplus total_surplus\n" + + " FROM\n" + + " (\n" + + " SELECT\n" + + " ifnull(o.customer_id, - 1) customer_id,\n" + + " count(o.sn) cnt,\n" + + " o.state,\n" + + " o.create_time,\n" + + " p.total_amount total_amount,\n" + + " sum(o.total_price) total_price,\n" + + " sum(o.weight) total_weight\n" + + " FROM\n" + + " order_temp o\n" + + " LEFT JOIN (\n" + + " SELECT\n" + + " d.customer_id,\n" + + " sum(d.amount) total_amount\n" + + " FROM\n" + + " prepay_detail d\n" + + " WHERE\n" + + " d.state = 2\n" + + " AND d.verify_time LIKE ?\n" + + " GROUP BY\n" + + " d.customer_id\n" + + " ) p ON p.customer_id = o.customer_id\n" + + " WHERE\n" + + " o.state = 5\n" + + " AND o.create_time LIKE ?\n" + + " GROUP BY\n" + + " o.customer_id\n" + + " ) a\n" + + " LEFT JOIN customer u ON u.id = a.customer_id\n" + + " LEFT JOIN prepay_customer r ON r.customer_id = a.customer_id\n" + + " ) c\n" + + "WHERE\n" + + " c.`customer_name` IS NOT NULL and c.customer_id = ?"; + rec = Db.findFirst(sql, year + "%", year + "%", customer_id); + } else { // 零散配额 + if (StrKit.isBlank(year) || customer_name == null) { + log.error("参数错误"); + return null; + } + sql = "SELECT\n" + + " a.*\n" + + "FROM\n" + + " (\n" + + " SELECT\n" + + " o.customer_name,\n" + + " count(o.sn) cnt,\n" + + " sum(o.total_price) total_price,\n" + + " sum(o.weight) total_weight\n" + + " FROM\n" + + " order_temp o\n" + + " WHERE\n" + + " o.state = 5\n" + + " AND o.create_time LIKE ?\n" + + " GROUP BY\n" + + " o.customer_id\n" + + " ) a\n" + + "WHERE\n" + + " a.`customer_name` = ?"; + rec = Db.findFirst(sql, year + "%", customer_name); + } return rec; } diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java index 0bac123..2fce603 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java @@ -17,16 +17,16 @@ public class OrderStatController extends BaseController { */ @Before(DayValidator.class) public void daydetail() { - String tm = get("tm"); - String truck_license = getUpperCaseVal("truck_license"); - String sn = get("sn"); - Integer supermarket_id = getInt("supermarket_id"); - Integer trans_co_id = getInt("trans_co_id"); - Integer customer_id = getInt("customer_id"); - Integer type = getInt("type"); - Integer isprepaid = getInt("isprepaid"); - Integer product_id = getInt("product_id"); - Integer customer_type_id = getInt("customer_type_id"); + String tm = get("tm"); + String truck_license = getUpperCaseVal("truck_license"); + String sn = get("sn"); + Integer supermarket_id = getInt("supermarket_id"); + Integer trans_co_id = getInt("trans_co_id"); + Integer customer_id = getInt("customer_id"); + Integer type = getInt("type"); + Integer isprepaid = getInt("isprepaid"); + Integer product_id = getInt("product_id"); + Integer customer_type_id = getInt("customer_type_id"); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 @@ -69,8 +69,8 @@ public class OrderStatController extends BaseController { Integer customer_id = getInt("customer_id"); String tm = get("tm"); int export = getInt("export", 0); - Integer product_id = getInt("product_id"); - Boolean stat_product = getBoolean("stat_product",false); + Integer product_id = getInt("product_id"); + Boolean stat_product = getBoolean("stat_product", false); if (export == 0) { renderJson(Result.object(OrderStatService.me.monthgrid(tm, supermarket_id, customer_id, stat_product, product_id))); @@ -117,14 +117,16 @@ public class OrderStatController extends BaseController { */ @Before(DayValidator.class) public void daystatCustomer() { - String tm = get("tm"); - Integer invoice_type = getInt("invoice_type"); - int export = getInt("export", 0); - Boolean stat_product = getBoolean("stat_product",false); + String tm = get("tm"); + Integer invoice_type = getInt("invoice_type"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); + int export = getInt("export", 0); + Boolean stat_product = getBoolean("stat_product", false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product))); + renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id))); } else { - Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm, invoice_type, stat_product); + Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm, invoice_type, stat_product, customer_id, customer_type_id); render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -134,14 +136,16 @@ public class OrderStatController extends BaseController { */ @Before(MonthValidator.class) public void monthstatCustomer() { - String tm = get("tm"); - Integer invoice_type = getInt("invoice_type"); - int export = getInt("export", 0); - Boolean stat_product = getBoolean("stat_product",false); + String tm = get("tm"); + Integer invoice_type = getInt("invoice_type"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); + int export = getInt("export", 0); + Boolean stat_product = getBoolean("stat_product", false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product))); + renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id))); } else { - Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm, invoice_type, stat_product); + Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm, invoice_type, stat_product, customer_id, customer_type_id); render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -155,7 +159,7 @@ public class OrderStatController extends BaseController { String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59" Integer supermarket_id = getInt("supermarket_id"); int export = getInt("export", 0); - Boolean stat_product = getBoolean("stat_product",false); + Boolean stat_product = getBoolean("stat_product", false); Integer product_id = getInt("product_id"); if (export == 0) { @@ -231,19 +235,20 @@ public class OrderStatController extends BaseController { */ @Before(DayValidator.class) public void statDayCustomer() { - String tm = get("tm"); - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 - Integer supermarket_id = getInt("supermarket_id"); - Integer customer_id = getInt("customer_id"); - String customer_ids = get("customer_ids"); - Integer product_id = getInt("product_id"); - boolean stat_product = getBoolean("stat_product", false); - Integer isprepaid = getInt("isprepaid"); + String tm = get("tm"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Integer supermarket_id = getInt("supermarket_id"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); + String customer_ids = get("customer_ids"); + Integer product_id = getInt("product_id"); + boolean stat_product = getBoolean("stat_product", false); + Integer isprepaid = getInt("isprepaid"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid))); + renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid))); } else { - Workbook wb = OrderStatService.me.statCustomerExport("砂站日销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); + Workbook wb = OrderStatService.me.statCustomerExport("砂站日销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid); render(new ExcelRender(tm + "_砂站日" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -253,91 +258,97 @@ public class OrderStatController extends BaseController { */ @Before(MonthValidator.class) public void statMonthCustomer() { - String tm = get("tm"); - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 - Integer supermarket_id = getInt("supermarket_id"); - Integer customer_id = getInt("customer_id"); - String customer_ids = get("customer_ids"); - Integer product_id = getInt("product_id"); - boolean stat_product = getBoolean("stat_product", false); - Integer isprepaid = getInt("isprepaid"); + String tm = get("tm"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Integer supermarket_id = getInt("supermarket_id"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); + String customer_ids = get("customer_ids"); + Integer product_id = getInt("product_id"); + boolean stat_product = getBoolean("stat_product", false); + Integer isprepaid = getInt("isprepaid"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid))); + renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid))); } else { - Workbook wb = OrderStatService.me.statCustomerExport("砂站月销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); + Workbook wb = OrderStatService.me.statCustomerExport("砂站月销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid); render(new ExcelRender(tm + "_砂站月" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @Before(StartAndEndIntervalValidator.class) public void statRangeCustomer() { - String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00" - String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59" - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 - Integer supermarket_id = getInt("supermarket_id"); - Integer customer_id = getInt("customer_id"); - String customer_ids = get("customer_ids"); - Integer product_id = getInt("product_id"); - boolean stat_product = getBoolean("stat_product", false); - Integer isprepaid = getInt("isprepaid"); + String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00" + String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59" + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Integer supermarket_id = getInt("supermarket_id"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); + String customer_ids = get("customer_ids"); + Integer product_id = getInt("product_id"); + boolean stat_product = getBoolean("stat_product", false); + Integer isprepaid = getInt("isprepaid"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.statCustomer(null, stm, etm, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid))); + renderJson(Result.object(OrderStatService.me.statCustomer(null, stm, etm, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid))); } else { - Workbook wb = OrderStatService.me.statCustomerExport("砂站时段销售汇总表", null, stm, etm, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); + Workbook wb = OrderStatService.me.statCustomerExport("砂站时段销售汇总表", null, stm, etm, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid); render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } public void statYearCustomer() { - String tm = get("tm"); - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 - Boolean stat_product = getBoolean("stat_product",false); + String tm = get("tm"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Boolean stat_product = getBoolean("stat_product", false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm, stat_product))); + renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm, stat_product, customer_id, customer_type_id))); } else { - Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm, stat_product); + Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm, stat_product, customer_id, customer_type_id); render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } public void statYearBySup() { - String tm = get("tm"); - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 - Boolean stat_product = getBoolean("stat_product",false); + String tm = get("tm"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Boolean stat_product = getBoolean("stat_product", false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatBySup(tm, stat_product))); + renderJson(Result.object(OrderStatService.me.salestat(tm))); } else { - Workbook wb = OrderStatService.me.yearStatBySupExport(tm, stat_product); + Workbook wb = OrderStatService.me.yearsalestatExport(tm); render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @Before(StartAndEndIntervalValidator.class) public void statRangeAllCustomer() { - String stm = get("stm"); - String etm = get("etm"); - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 - Boolean stat_product = getBoolean("stat_product",false); - Integer product_id = getInt("product_id"); + String stm = get("stm"); + String etm = get("etm"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Boolean stat_product = getBoolean("stat_product", false); + Integer product_id = getInt("product_id"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm, stat_product, product_id))); + renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm, stat_product, product_id, customer_id, customer_type_id))); } else { - Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm, stat_product, product_id); + Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm, stat_product, product_id, customer_id, customer_type_id); render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @Before(StartAndEndIntervalValidator.class) public void statRangeAllSup() { - String stm = get("stm"); - String etm = get("etm"); - Boolean stat_product = getBoolean("stat_product",false); - Integer product_id = getInt("product_id"); - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + String stm = get("stm"); + String etm = get("etm"); + Boolean stat_product = getBoolean("stat_product", false); + Integer product_id = getInt("product_id"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 if (export == 0) { renderJson(Result.object(OrderStatService.me.yearStatBySup(stm, etm, stat_product, product_id))); @@ -351,10 +362,10 @@ public class OrderStatController extends BaseController { * 固定、零散配额指定年的销售统计汇总数据 */ public void yearStatisticsByCustomerId() { - String year = get("year"); - Integer customer_id = getInt("customer_id"); - String customer_name = get("customer_name"); - Integer type = getInt("type"); + String year = get("year"); + Integer customer_id = getInt("customer_id"); + String customer_name = get("customer_name"); + Integer type = getInt("type"); renderJson(Result.object(OrderStatService.me.yearStatisticsByCustomerId(year, customer_id, customer_name, type))); } } diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/jobs/StatSmsJob.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/jobs/StatSmsJob.java index cc38732..a009a78 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/jobs/StatSmsJob.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/jobs/StatSmsJob.java @@ -193,9 +193,15 @@ public class StatSmsJob implements Job { /** * 累计销售汇总,含前日汇总 - * 王乐 2021-08-17 - * 四家客户2020年12月30日、31日两天的销售数据是固定值(4677.26吨、420953.4元) - * 2021年新增客户销售=2021年销售汇总 -四家客户充值金额(2000万)+四家客户2020年12月30日、31日两天的销售数据 + * 王乐 2021-09-22 + * + * 274.62-27.34 + * 21830.32-2011.27 + * + * 新增客户销售的计算公式 + * + * 27.34和2011.27这两个数是固定值 + * 274.62和21830.32这两个数是系统里统计的总数 */ public void statAggr() { Date now = new Date(); @@ -264,8 +270,18 @@ public class StatSmsJob implements Job { } obj.put("aggr_cnt", orderobj.get("aggr_cnt")); - obj.put("aggr_weight", String.format("%.2f万", orderobj.getBigDecimal("aggr_weight").divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP))); - obj.put("aggr_price", String.format("%.2f万", orderobj.getBigDecimal("aggr_price").divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP))); + obj.put("aggr_weight", String.format("%.2f万", + orderobj.getBigDecimal("aggr_weight") + .divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP) + .subtract(new BigDecimal("27.34")) + ) + ); + obj.put("aggr_price", String.format("%.2f万", + orderobj.getBigDecimal("aggr_price") + .divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP) + .subtract(new BigDecimal("2011.27")) + ) + ); obj.put("customer_weight", String.format("%.2f万", revenueobj.getBigDecimal("weight").divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP))); obj.put("customer_price", String.format("%.2f万", revenueobj.getBigDecimal("total_price").divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP))); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java index c688104..f37e0bf 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java @@ -40,10 +40,10 @@ public class OrderStatController extends BaseController { customer_id = tokenuser.getEntityId(); } - Integer type = getInt("type"); - Integer isprepaid = getInt("isprepaid"); - Integer product_id = getInt("product_id"); - Integer customer_type_id = getInt("customer_type_id"); + Integer type = getInt("type"); + Integer isprepaid = getInt("isprepaid"); + Integer product_id = getInt("product_id"); + Integer customer_type_id = getInt("customer_type_id"); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 @@ -84,8 +84,8 @@ public class OrderStatController extends BaseController { public void monthgrid() { Integer supermarket_id = getInt("supermarket_id"); Integer customer_id = getInt("customer_id"); - Integer product_id = getInt("product_id"); - Boolean stat_product = getBoolean("stat_product",false); + Integer product_id = getInt("product_id"); + Boolean stat_product = getBoolean("stat_product", false); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); @@ -145,15 +145,17 @@ public class OrderStatController extends BaseController { */ @Before(DayValidator.class) public void daystatCustomer() { - String tm = get("tm"); - Integer invoice_type = getInt("invoice_type"); - int export = getInt("export", 0); - Boolean stat_product = getBoolean("stat_product",false); + String tm = get("tm"); + Integer invoice_type = getInt("invoice_type"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); + int export = getInt("export", 0); + Boolean stat_product = getBoolean("stat_product", false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product))); + renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id))); } else { - Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm, invoice_type, stat_product); + Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm, invoice_type, stat_product, customer_id, customer_type_id); render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -163,15 +165,17 @@ public class OrderStatController extends BaseController { */ @Before(MonthValidator.class) public void monthstatCustomer() { - String tm = get("tm"); - Integer invoice_type = getInt("invoice_type"); - int export = getInt("export", 0); - Boolean stat_product = getBoolean("stat_product",false); + String tm = get("tm"); + Integer invoice_type = getInt("invoice_type"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); + int export = getInt("export", 0); + Boolean stat_product = getBoolean("stat_product", false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product))); + renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id))); } else { - Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm, invoice_type, stat_product); + Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm, invoice_type, stat_product, customer_id, customer_type_id); render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -184,14 +188,14 @@ public class OrderStatController extends BaseController { String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00" String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59" Integer supermarket_id = getInt("supermarket_id"); - Boolean stat_product = getBoolean("stat_product",false); - Integer product_id = getInt("product_id"); + Boolean stat_product = getBoolean("stat_product", false); + Integer product_id = getInt("product_id"); int export = getInt("export", 0); if (export == 0) { - renderJson(Result.object(OrderStatService.me.mdstat(stm, etm, supermarket_id, stat_product,product_id))); + renderJson(Result.object(OrderStatService.me.mdstat(stm, etm, supermarket_id, stat_product, product_id))); } else { - Workbook wb = OrderStatService.me.mdstatExport(stm, etm, supermarket_id, stat_product,product_id); + Workbook wb = OrderStatService.me.mdstatExport(stm, etm, supermarket_id, stat_product, product_id); render(new ExcelRender(stm.substring(0, 10) + "至" + etm.substring(0, 10) + "_销售月逐日统计_" + System.currentTimeMillis() + ".xlsx", wb)); } @@ -261,11 +265,12 @@ public class OrderStatController extends BaseController { */ @Before(DayValidator.class) public void statDayCustomer() { - String tm = get("tm"); - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 - Integer supermarket_id = getInt("supermarket_id"); - Integer customer_id = getInt("customer_id"); - String customer_ids = get("customer_ids"); + String tm = get("tm"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Integer supermarket_id = getInt("supermarket_id"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); + String customer_ids = get("customer_ids"); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); @@ -274,8 +279,9 @@ public class OrderStatController extends BaseController { renderJson(Result.noauth()); return; } else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) { - customer_id = tokenuser.getEntityId(); - customer_ids = null; + customer_id = tokenuser.getEntityId(); + customer_ids = null; + customer_type_id = null; } Integer product_id = getInt("product_id"); @@ -283,9 +289,9 @@ public class OrderStatController extends BaseController { Integer isprepaid = getInt("isprepaid"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid))); + renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid))); } else { - Workbook wb = OrderStatService.me.statCustomerExport("砂站日销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); + Workbook wb = OrderStatService.me.statCustomerExport("砂站日销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid); render(new ExcelRender(tm + "_砂站日" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -295,11 +301,12 @@ public class OrderStatController extends BaseController { */ @Before(MonthValidator.class) public void statMonthCustomer() { - String tm = get("tm"); - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 - Integer supermarket_id = getInt("supermarket_id"); - Integer customer_id = getInt("customer_id"); - String customer_ids = get("customer_ids"); + String tm = get("tm"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Integer supermarket_id = getInt("supermarket_id"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); + String customer_ids = get("customer_ids"); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); @@ -317,21 +324,22 @@ public class OrderStatController extends BaseController { Integer isprepaid = getInt("isprepaid"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid))); + renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid))); } else { - Workbook wb = OrderStatService.me.statCustomerExport("砂站月销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); + Workbook wb = OrderStatService.me.statCustomerExport("砂站月销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid); render(new ExcelRender(tm + "_砂站月" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @Before(StartAndEndIntervalValidator.class) public void statRangeCustomer() { - String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00" - String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59" - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 - Integer supermarket_id = getInt("supermarket_id"); - Integer customer_id = getInt("customer_id"); - String customer_ids = get("customer_ids"); + String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00" + String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59" + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Integer supermarket_id = getInt("supermarket_id"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); + String customer_ids = get("customer_ids"); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); @@ -349,64 +357,69 @@ public class OrderStatController extends BaseController { Integer isprepaid = getInt("isprepaid"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.statCustomer(null, stm, etm, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid))); + renderJson(Result.object(OrderStatService.me.statCustomer(null, stm, etm, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid))); } else { - Workbook wb = OrderStatService.me.statCustomerExport("砂站时段销售汇总表", null, stm, etm, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); + Workbook wb = OrderStatService.me.statCustomerExport("砂站时段销售汇总表", null, stm, etm, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid); render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } public void statYearCustomer() { - String tm = get("tm"); - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 - Boolean stat_product = getBoolean("stat_product",false); + String tm = get("tm"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Boolean stat_product = getBoolean("stat_product", false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm, stat_product))); + renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm, stat_product, customer_id, customer_type_id))); } else { - Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm, stat_product); + Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm, stat_product, customer_id, customer_type_id); render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } public void statYearBySup() { - String tm = get("tm"); - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 - Boolean stat_product = getBoolean("stat_product",false); + String tm = get("tm"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Boolean stat_product = getBoolean("stat_product", false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatBySup(tm, stat_product))); + renderJson(Result.object(OrderStatService.me.salestat(tm))); } else { - Workbook wb = OrderStatService.me.yearStatBySupExport(tm, stat_product); + Workbook wb = OrderStatService.me.yearsalestatExport(tm); render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @Before(StartAndEndIntervalValidator.class) public void statRangeAllCustomer() { - String stm = get("stm"); - String etm = get("etm"); - Boolean stat_product = getBoolean("stat_product",false); - Integer product_id = getInt("product_id"); - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + String stm = get("stm"); + String etm = get("etm"); + Boolean stat_product = getBoolean("stat_product", false); + Integer product_id = getInt("product_id"); + Integer customer_id = getInt("customer_id"); + Integer customer_type_id = getInt("customer_type_id"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm, stat_product, product_id))); + renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm, stat_product, product_id, customer_id, customer_type_id))); } else { - Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm, stat_product,product_id); + Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm, stat_product, product_id, customer_id, customer_type_id); render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @Before(StartAndEndIntervalValidator.class) public void statRangeAllSup() { - String stm = get("stm"); - String etm = get("etm"); - Boolean stat_product = getBoolean("stat_product",false); - Integer product_id = getInt("product_id"); - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + String stm = get("stm"); + String etm = get("etm"); + Boolean stat_product = getBoolean("stat_product", false); + Integer product_id = getInt("product_id"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatBySup(stm, etm, stat_product,product_id))); + renderJson(Result.object(OrderStatService.me.yearStatBySup(stm, etm, stat_product, product_id))); } else { - Workbook wb = OrderStatService.me.yearStatBySupExport(stm, etm, stat_product,product_id); + Workbook wb = OrderStatService.me.yearStatBySupExport(stm, etm, stat_product, product_id); render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -432,10 +445,10 @@ public class OrderStatController extends BaseController { * 固定、零散配额指定年的销售统计汇总数据 */ public void yearStatisticsByCustomerId() { - String year = get("year"); - Integer customer_id = getInt("customer_id"); - String customer_name = get("customer_name"); - Integer type = getInt("type"); + String year = get("year"); + Integer customer_id = getInt("customer_id"); + String customer_name = get("customer_name"); + Integer type = getInt("type"); renderJson(Result.object(OrderStatService.me.yearStatisticsByCustomerId(year, customer_id, customer_name, type))); }