统计添加客户类型筛选

dev
lisai17@sina.com 2021-09-22 14:56:57 +08:00
parent 1446981fd6
commit 4e0227d14c
4 changed files with 647 additions and 431 deletions

View File

@ -513,7 +513,7 @@ public class OrderStatService {
* @return * @return
*/ */
public List<Record> salestat(String tm) { public List<Record> 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" + " from supermarket_product t\n" +
" left join (\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" + " select t.id, t.product_id, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" +
@ -556,68 +556,112 @@ public class OrderStatService {
* @param tm * @param tm
* @return * @return
*/ */
public List<Record> salestatCustomer(String tm, Integer invoice_type, Boolean stat_product) { public List<Record> salestatCustomer(String tm, Integer invoice_type, Boolean stat_product, Integer customer_id, Integer customer_type_id) {
List<Object> paraList = new ArrayList<>();
paraList.add(OrderStateEnum.RECEIVED.getStateid());
paraList.add(tm + "%");
List<Record> dblist = null; String sql;
if (invoice_type != null) { if (invoice_type != null) {
paraList.add(invoice_type);
if (stat_product) { 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" + 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" + " 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" + " 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" + " from order_temp t\n" +
" left join customer c on c.id = t.customer_id \n" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.invoice_type = ? \n" +
" and t.create_time like ? \n" + " and t.create_time like ? \n" +
" ) t\n" + " and t.invoice_type = ? \n";
" group by t.customer_name,t.product_id,t.product_name", if (customer_id != null) {
OrderStateEnum.RECEIVED.getStateid(), sql += " and c.id = ? \n";
invoice_type, paraList.add(customer_id);
tm + "%"); } else if (customer_type_id != null) {
if (customer_type_id == 99) {
sql += " and t.customer_id is null \n";
} else { } 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" + 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" + " 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" + " 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" + " from order_temp t\n" +
" left join customer c on c.id = t.customer_id \n" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.invoice_type = ? \n" +
" and t.create_time like ? \n" + " and t.create_time like ? \n" +
" ) t\n" + " and t.invoice_type = ? \n";
" group by t.customer_name", if (customer_id != null) {
OrderStateEnum.RECEIVED.getStateid(), sql += " and c.id = ? \n";
invoice_type, paraList.add(customer_id);
tm + "%"); } 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 { } else {
if (stat_product) { 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" + 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" + " 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" + " 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" + " from order_temp t\n" +
" left join customer c on c.id = t.customer_id \n" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.create_time like ? \n" + " and t.create_time like ? \n";
" ) t\n" + if (customer_id != null) {
" group by t.customer_name,t.product_id,t.product_name", sql += " and c.id = ? \n";
OrderStateEnum.RECEIVED.getStateid(), paraList.add(customer_id);
tm + "%" } else if (customer_type_id != null) {
); if (customer_type_id == 99) {
sql += " and t.customer_id is null \n";
} else { } 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" + 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" + " 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" + " 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" + " from order_temp t\n" +
" left join customer c on c.id = t.customer_id \n" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.create_time like ? \n" + " and t.create_time like ? \n";
" ) t\n" + if (customer_id != null) {
" group by t.customer_name", sql += " and c.id = ? \n";
OrderStateEnum.RECEIVED.getStateid(), paraList.add(customer_id);
tm + "%" } 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";
}
} }
List<Record> dblist = Db.find(sql, paraList.toArray());
Record total = new Record(); Record total = new Record();
total.set("id", 0); total.set("id", 0);
total.set("name", "合计"); total.set("name", "合计");
@ -671,6 +715,22 @@ public class OrderStatService {
return salestatExport(tm, title, subtitle); 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 * @param tm
* @return * @return
*/ */
public Workbook salestatCustomerExport(String tm, String title, String subtitle, Integer invoice_type, Boolean 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<Record> list = salestatCustomer(tm, invoice_type, stat_product); List<Record> list = salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id);
Workbook wb = new XSSFWorkbook(); Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(title); 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 = "销售日统计"; String title = "销售日统计";
@ -811,10 +871,10 @@ public class OrderStatService {
subtitle += title; 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 = "销售月统计"; String title = "销售月统计";
// 副标题 start // 副标题 start
@ -827,11 +887,12 @@ public class OrderStatService {
subtitle += title; 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 stm
* @param etm * @param etm
* @param supermarket_id * @param supermarket_id
@ -914,6 +975,7 @@ public class OrderStatService {
/** /**
* *
*
* @param stm * @param stm
* @param etm * @param etm
* @param supermarket_id * @param supermarket_id
@ -1204,24 +1266,24 @@ public class OrderStatService {
* @param isprepaid * @param isprepaid
* @return * @return
*/ */
public List<Record> 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<Record> 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 "; String temp_sql = " select t.customer_id, t.customer_name, t.weight, t.total_price, t.sn, t.product_id, t.product_name ";
List<Object> paraTemp = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
temp_sql += " from order_temp t\n" + temp_sql += " from order_temp t\n" +
" where t.state = ? \n"; " where t.state = ? \n";
paraTemp.add(OrderStateEnum.RECEIVED.getStateid()); paraList.add(OrderStateEnum.RECEIVED.getStateid());
if (supermarket_id != null) { if (supermarket_id != null) {
temp_sql += " and t.supermarket_id = ? \n"; temp_sql += " and t.supermarket_id = ? \n";
paraTemp.add(supermarket_id); paraList.add(supermarket_id);
} }
if (customer_id != null) { if (customer_id != null) {
temp_sql += " and t.customer_id = ? \n"; temp_sql += " and t.customer_id = ? \n";
paraTemp.add(customer_id); paraList.add(customer_id);
} }
if (StrKit.notBlank(customer_ids)) { if (StrKit.notBlank(customer_ids)) {
@ -1239,7 +1301,7 @@ public class OrderStatService {
temp_sql += "?"; temp_sql += "?";
paraTemp.add(cid); paraList.add(cid);
} }
temp_sql += " ) \n"; temp_sql += " ) \n";
@ -1252,16 +1314,16 @@ public class OrderStatService {
return new ArrayList<>(); return new ArrayList<>();
} }
temp_sql += " and t.create_time between ? and ? \n"; temp_sql += " and t.create_time between ? and ? \n";
paraTemp.add(stm); paraList.add(stm);
paraTemp.add(etm); paraList.add(etm);
} else { } else {
temp_sql += " and t.create_time like ? \n"; temp_sql += " and t.create_time like ? \n";
paraTemp.add(tm + "%"); paraList.add(tm + "%");
} }
if (isprepaid != null) { if (isprepaid != null) {
temp_sql += " and t.isprepaid = ? \n"; temp_sql += " and t.isprepaid = ? \n";
paraTemp.add(isprepaid); paraList.add(isprepaid);
} }
String sql; String sql;
@ -1269,25 +1331,37 @@ public class OrderStatService {
if (stat_product) { if (stat_product) {
if (product_id != null) { if (product_id != null) {
temp_sql += " and t.product_id = ? \n"; 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" + 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" + " from( \n" +
temp_sql + temp_sql +
" ) a\n" + " ) a\n" +
" left join customer c on c.id = a.customer_id \n" + " left join customer c on c.id = a.customer_id \n";
" group by a.customer_name, a.product_id ";
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 { } 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" + 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" + " from( \n" +
temp_sql + temp_sql +
" ) a\n" + " ) a\n" +
" left join customer c on c.id = a.customer_id \n" + " left join customer c on c.id = a.customer_id \n";
" group by a.customer_name ";
if (customer_id == null && StrKit.isBlank(customer_ids) && customer_type_id != null) {
sql += " where c.customer_type_id = ? \n";
paraList.add(customer_type_id);
} }
List<Record> list = Db.find(sql, paraTemp.toArray()); sql += " group by a.customer_name \n";
}
List<Record> list = Db.find(sql, paraList.toArray());
// 只有一个统计总数为 0 的记录时,删除该记录后返回 // 只有一个统计总数为 0 的记录时,删除该记录后返回
if (list != null && list.size() == 1) { if (list != null && list.size() == 1) {
@ -1301,11 +1375,11 @@ public class OrderStatService {
return list; 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(); Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(name); Sheet sheet = wb.createSheet(name);
List<Record> list = statCustomer(tm, stm, etm, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); List<Record> list = statCustomer(tm, stm, etm, supermarket_id, customer_id, customer_ids, customer_type_id, stat_product, product_id, isprepaid);
int datalen = list.size(); int datalen = list.size();
int end_col = stat_product ? 6 : 5; // 数据共有几列 int end_col = stat_product ? 6 : 5; // 数据共有几列
@ -1508,7 +1582,8 @@ public class OrderStatService {
} }
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" + 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" + "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" + " where t.state = 5\n" +
" and t.create_time >= ? \n" + " and t.create_time >= ? \n" +
" and t.create_time <= ? \n" + " and t.create_time <= ? \n" +
@ -1518,7 +1593,8 @@ public class OrderStatService {
} else { } else {
list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight from supermarket s\n" + list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight from supermarket s\n" +
"left join (\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" + " where t.state = 5\n" +
" and t.create_time >= ? \n" + " and t.create_time >= ? \n" +
" and t.create_time <= ? \n" + " and t.create_time <= ? \n" +
@ -1576,7 +1652,7 @@ public class OrderStatService {
} else { } else {
row.createCell(a++).setCellValue(""); 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")); row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price"));
} }
@ -1585,46 +1661,114 @@ public class OrderStatService {
return wb; return wb;
} }
public List<Record> yearStatByCustomer(String year, Boolean stat_product) { public List<Record> yearStatByCustomer(String year, Boolean stat_product, Integer customer_id, Integer customer_type_id) {
List<Record> list; List<Record> list;
if (StrKit.notBlank(year)) { if (StrKit.notBlank(year)) {
if (stat_product) { if (stat_product) {
list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus ,a.product_id,a.product_name from (\n" + List<Object> paraList = new ArrayList<>();
" 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" + 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" + " where t.state = 5\n" +
" and t.create_time like ? \n" + " and t.create_time like ? \n";
" group by t.customer_id,t.product_id,t.product_name\n" +
" ) a\n" + if (customer_id != null) {
" left join customer c on c.id = a.id\n" + sql += " and c.id = ? \n";
" left join prepay_customer p on p.customer_id = a.id", year + "%"); paraList.add(customer_id);
} else if (customer_type_id != null) {
if (customer_type_id == 99) {
sql += " and t.customer_id is null \n";
} else { } else {
list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus from (\n" + sql += " and c.customer_type_id = ? \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" + paraList.add(customer_type_id);
" where t.state = 5\n" + }
" and t.create_time like ? \n" + }
" group by t.customer_id\n" +
sql += " group by t.customer_id,t.product_id,t.product_name\n" +
" ) a\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", year + "%"); list = Db.find(sql, paraList.toArray());
} else {
List<Object> 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";
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 prepay_customer p on p.customer_id = a.id";
list = Db.find(sql, paraList.toArray());
} }
} else { } else {
if (stat_product) { if (stat_product) {
list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus,a.product_id,a.product_name from (\n" + List<Object> paraList = new ArrayList<>();
" 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 ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus,a.product_id,a.product_name from (\n" +
" where t.state = 5\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" +
" group by t.customer_id,t.product_id,t.product_name\n" + " from order_temp t\n" +
" ) a\n" + " left join customer c on c.id = t.customer_id\n" +
" left join customer c on c.id = a.id\n" + " where t.state = 5\n";
" left join prepay_customer p on p.customer_id = a.id");
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 { } else {
list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus from (\n" + sql += " and c.customer_type_id = ? \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" + paraList.add(customer_type_id);
" where t.state = 5\n" + }
" group by t.customer_id\n" + }
sql += " group by t.customer_id,t.product_id,t.product_name\n" +
" ) a\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());
} else {
List<Object> 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 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(); Record hj = new Record();
hj.set("id", 0); hj.set("id", 0);
hj.set("name", "合计"); hj.set("name", "合计");
hj.set("cnt", 0); hj.set("orderCount", 0);
hj.set("total_price", new BigDecimal(0)); hj.set("totalPrice", new BigDecimal(0));
hj.set("total_weight", new BigDecimal(0)); hj.set("weight", new BigDecimal(0));
hj.set("total_weight", new BigDecimal(0)); hj.set("totalSurplus", new BigDecimal(0));
hj.set("total_surplus", new BigDecimal(0));
for (Record record : list) { for (Record record : list) {
if (record.get("cnt") != null) { if (record.get("orderCount") != null) {
hj.set("cnt", hj.getInt("cnt") + record.getInt("cnt")); hj.set("orderCount", hj.getInt("orderCount") + record.getInt("orderCount"));
} }
if (record.get("total_price") != null) { if (record.get("totalPrice") != null) {
hj.set("total_price", hj.getBigDecimal("total_price").add(record.getBigDecimal("total_price"))); hj.set("totalPrice", hj.getBigDecimal("totalPrice").add(record.getBigDecimal("totalPrice")));
} }
if (record.get("total_weight") != null) { if (record.get("weight") != null) {
hj.set("total_weight", hj.getBigDecimal("total_weight").add(record.getBigDecimal("total_weight"))); hj.set("weight", hj.getBigDecimal("weight").add(record.getBigDecimal("weight")));
} }
if (record.get("total_surplus") != null) { if (record.get("totalSurplus") != null) {
hj.set("total_surplus", hj.getBigDecimal("total_surplus").add(record.getBigDecimal("total_surplus"))); 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); list.add(hj);
@ -1661,8 +1804,8 @@ public class OrderStatService {
} }
public Workbook yearStatByCustomerExport(String year, Boolean stat_product) { public Workbook yearStatByCustomerExport(String year, Boolean stat_product, Integer customer_id, Integer customer_type_id) {
List<Record> list = yearStatByCustomer(year, stat_product); List<Record> list = yearStatByCustomer(year, stat_product, customer_id, customer_type_id);
Workbook wb = new XSSFWorkbook(); Workbook wb = new XSSFWorkbook();
Sheet sheet; Sheet sheet;
@ -1697,10 +1840,10 @@ public class OrderStatService {
} }
row.createCell(a++).setCellValue(order.getStr("name")); row.createCell(a++).setCellValue(order.getStr("name"));
row.createCell(a++).setCellValue(order.getInt("cnt")); row.createCell(a++).setCellValue(order.getInt("orderCount"));
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")); row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "totalPrice"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_surplus")); row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "totalSurplus"));
} }
if (hj != null) { if (hj != null) {
@ -1721,7 +1864,7 @@ public class OrderStatService {
} }
public List<Record> yearStatByCustomer(String stm, String etm, Boolean stat_product, Integer product_id) { public List<Record> yearStatByCustomer(String stm, String etm, Boolean stat_product, Integer product_id, Integer customer_id, Integer customer_type_id) {
List<Record> list; List<Record> list;
String paramsSql = ""; String paramsSql = "";
List<Object> paramsArray = new ArrayList<>(); List<Object> paramsArray = new ArrayList<>();
@ -1732,26 +1875,59 @@ public class OrderStatService {
paramsSql += " and t.product_id=? \n"; paramsSql += " and t.product_id=? \n";
paramsArray.add(product_id); 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" + " where t.state = 5\n" +
" and t.create_time >= ? \n" + " and t.create_time >= ? \n" +
" and t.create_time <= ? \n" + " and t.create_time <= ? \n" +
paramsSql+ paramsSql;
" group by t.customer_id,t.product_id,t.product_name\n" +
" ) a\n" + if (customer_id != null) {
" left join customer c on c.id = a.id\n" + sql += " and c.id = ? \n";
" left join prepay_customer p on p.customer_id = a.id", paramsArray.toArray()); paramsArray.add(customer_id);
} else if (customer_type_id != null) {
if (customer_type_id == 99) {
sql += " and t.customer_id is null \n";
} else { } else {
list = Db.find("select c.id, ifnull(c.name, '零散') name, a.*, p.surplus total_surplus from (\n" + sql += " and c.customer_type_id = ? \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" + paramsArray.add(customer_type_id);
}
}
sql += " group by t.customer_id,t.product_id,t.product_name\n" +
" ) a\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" + " where t.state = 5\n" +
" and t.create_time >= ? \n" + " and t.create_time >= ? \n" +
" and t.create_time <= ? \n" + " and t.create_time <= ? \n";
" group by t.customer_id\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" + " ) 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", paramsArray.toArray());
list = Db.find(sql, paramsArray.toArray());
} }
Record hj = new Record(); Record hj = new Record();
@ -1786,8 +1962,8 @@ public class OrderStatService {
} }
public Workbook yearStatByCustomerExport(String stm, String etm, Boolean stat_product, Integer product_id) { public Workbook yearStatByCustomerExport(String stm, String etm, Boolean stat_product, Integer product_id, Integer customer_id, Integer customer_type_id) {
List<Record> list = yearStatByCustomer(stm, etm, stat_product, product_id); List<Record> list = yearStatByCustomer(stm, etm, stat_product, product_id, customer_id, customer_type_id);
Workbook wb = new XSSFWorkbook(); Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + stm.substring(0, 10) + "时段销售汇总"); Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + stm.substring(0, 10) + "时段销售汇总");

View File

@ -119,12 +119,14 @@ public class OrderStatController extends BaseController {
public void daystatCustomer() { public void daystatCustomer() {
String tm = get("tm"); String tm = get("tm");
Integer invoice_type = getInt("invoice_type"); 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); int export = getInt("export", 0);
Boolean stat_product = getBoolean("stat_product", false); Boolean stat_product = getBoolean("stat_product", false);
if (export == 0) { 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 { } 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)); render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -136,12 +138,14 @@ public class OrderStatController extends BaseController {
public void monthstatCustomer() { public void monthstatCustomer() {
String tm = get("tm"); String tm = get("tm");
Integer invoice_type = getInt("invoice_type"); 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); int export = getInt("export", 0);
Boolean stat_product = getBoolean("stat_product", false); Boolean stat_product = getBoolean("stat_product", false);
if (export == 0) { 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 { } 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)); render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -235,15 +239,16 @@ public class OrderStatController extends BaseController {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer supermarket_id = getInt("supermarket_id"); Integer supermarket_id = getInt("supermarket_id");
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");
Integer customer_type_id = getInt("customer_type_id");
String customer_ids = get("customer_ids"); String customer_ids = get("customer_ids");
Integer product_id = getInt("product_id"); Integer product_id = getInt("product_id");
boolean stat_product = getBoolean("stat_product", false); boolean stat_product = getBoolean("stat_product", false);
Integer isprepaid = getInt("isprepaid"); Integer isprepaid = getInt("isprepaid");
if (export == 0) { 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 { } 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)); render(new ExcelRender(tm + "_砂站日" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -257,15 +262,16 @@ public class OrderStatController extends BaseController {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer supermarket_id = getInt("supermarket_id"); Integer supermarket_id = getInt("supermarket_id");
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");
Integer customer_type_id = getInt("customer_type_id");
String customer_ids = get("customer_ids"); String customer_ids = get("customer_ids");
Integer product_id = getInt("product_id"); Integer product_id = getInt("product_id");
boolean stat_product = getBoolean("stat_product", false); boolean stat_product = getBoolean("stat_product", false);
Integer isprepaid = getInt("isprepaid"); Integer isprepaid = getInt("isprepaid");
if (export == 0) { 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 { } 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)); render(new ExcelRender(tm + "_砂站月" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -277,27 +283,30 @@ public class OrderStatController extends BaseController {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer supermarket_id = getInt("supermarket_id"); Integer supermarket_id = getInt("supermarket_id");
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");
Integer customer_type_id = getInt("customer_type_id");
String customer_ids = get("customer_ids"); String customer_ids = get("customer_ids");
Integer product_id = getInt("product_id"); Integer product_id = getInt("product_id");
boolean stat_product = getBoolean("stat_product", false); boolean stat_product = getBoolean("stat_product", false);
Integer isprepaid = getInt("isprepaid"); Integer isprepaid = getInt("isprepaid");
if (export == 0) { 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 { } 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)); render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
public void statYearCustomer() { public void statYearCustomer() {
String tm = get("tm"); 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 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Boolean stat_product = getBoolean("stat_product", false); Boolean stat_product = getBoolean("stat_product", false);
if (export == 0) { 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 { } 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)); render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -308,9 +317,9 @@ public class OrderStatController extends BaseController {
Boolean stat_product = getBoolean("stat_product", false); Boolean stat_product = getBoolean("stat_product", false);
if (export == 0) { if (export == 0) {
renderJson(Result.object(OrderStatService.me.yearStatBySup(tm, stat_product))); renderJson(Result.object(OrderStatService.me.salestat(tm)));
} else { } else {
Workbook wb = OrderStatService.me.yearStatBySupExport(tm, stat_product); Workbook wb = OrderStatService.me.yearsalestatExport(tm);
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -322,11 +331,13 @@ public class OrderStatController extends BaseController {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Boolean stat_product = getBoolean("stat_product", false); Boolean stat_product = getBoolean("stat_product", false);
Integer product_id = getInt("product_id"); Integer product_id = getInt("product_id");
Integer customer_id = getInt("customer_id");
Integer customer_type_id = getInt("customer_type_id");
if (export == 0) { 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 { } 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)); render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }

View File

@ -193,9 +193,15 @@ public class StatSmsJob implements Job {
/** /**
* *
* 2021-08-17 * 2021-09-22
* 20201230314677.26420953.4 *
* 2021=2021 -2000+2020123031 * 274.62-27.34
* 21830.32-2011.27
*
*
*
* 27.342011.27
* 274.6221830.32
*/ */
public void statAggr() { public void statAggr() {
Date now = new Date(); Date now = new Date();
@ -264,8 +270,18 @@ public class StatSmsJob implements Job {
} }
obj.put("aggr_cnt", orderobj.get("aggr_cnt")); 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_weight", String.format("%.2f万",
obj.put("aggr_price", String.format("%.2f万", orderobj.getBigDecimal("aggr_price").divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP))); 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_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))); obj.put("customer_price", String.format("%.2f万", revenueobj.getBigDecimal("total_price").divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP)));

View File

@ -147,13 +147,15 @@ public class OrderStatController extends BaseController {
public void daystatCustomer() { public void daystatCustomer() {
String tm = get("tm"); String tm = get("tm");
Integer invoice_type = getInt("invoice_type"); 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); int export = getInt("export", 0);
Boolean stat_product = getBoolean("stat_product", false); Boolean stat_product = getBoolean("stat_product", false);
if (export == 0) { 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 { } 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)); render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -165,13 +167,15 @@ public class OrderStatController extends BaseController {
public void monthstatCustomer() { public void monthstatCustomer() {
String tm = get("tm"); String tm = get("tm");
Integer invoice_type = getInt("invoice_type"); 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); int export = getInt("export", 0);
Boolean stat_product = getBoolean("stat_product", false); Boolean stat_product = getBoolean("stat_product", false);
if (export == 0) { 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 { } 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)); render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -265,6 +269,7 @@ public class OrderStatController extends BaseController {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer supermarket_id = getInt("supermarket_id"); Integer supermarket_id = getInt("supermarket_id");
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");
Integer customer_type_id = getInt("customer_type_id");
String customer_ids = get("customer_ids"); String customer_ids = get("customer_ids");
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
@ -276,6 +281,7 @@ public class OrderStatController extends BaseController {
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) { } else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
customer_id = tokenuser.getEntityId(); customer_id = tokenuser.getEntityId();
customer_ids = null; customer_ids = null;
customer_type_id = null;
} }
Integer product_id = getInt("product_id"); Integer product_id = getInt("product_id");
@ -283,9 +289,9 @@ public class OrderStatController extends BaseController {
Integer isprepaid = getInt("isprepaid"); Integer isprepaid = getInt("isprepaid");
if (export == 0) { 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 { } 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)); render(new ExcelRender(tm + "_砂站日" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -299,6 +305,7 @@ public class OrderStatController extends BaseController {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer supermarket_id = getInt("supermarket_id"); Integer supermarket_id = getInt("supermarket_id");
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");
Integer customer_type_id = getInt("customer_type_id");
String customer_ids = get("customer_ids"); String customer_ids = get("customer_ids");
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
@ -317,9 +324,9 @@ public class OrderStatController extends BaseController {
Integer isprepaid = getInt("isprepaid"); Integer isprepaid = getInt("isprepaid");
if (export == 0) { 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 { } 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)); render(new ExcelRender(tm + "_砂站月" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -331,6 +338,7 @@ public class OrderStatController extends BaseController {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer supermarket_id = getInt("supermarket_id"); Integer supermarket_id = getInt("supermarket_id");
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");
Integer customer_type_id = getInt("customer_type_id");
String customer_ids = get("customer_ids"); String customer_ids = get("customer_ids");
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
@ -349,22 +357,24 @@ public class OrderStatController extends BaseController {
Integer isprepaid = getInt("isprepaid"); Integer isprepaid = getInt("isprepaid");
if (export == 0) { 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 { } 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)); render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
public void statYearCustomer() { public void statYearCustomer() {
String tm = get("tm"); 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 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Boolean stat_product = getBoolean("stat_product", false); Boolean stat_product = getBoolean("stat_product", false);
if (export == 0) { 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 { } 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)); render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -374,9 +384,9 @@ public class OrderStatController extends BaseController {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Boolean stat_product = getBoolean("stat_product", false); Boolean stat_product = getBoolean("stat_product", false);
if (export == 0) { if (export == 0) {
renderJson(Result.object(OrderStatService.me.yearStatBySup(tm, stat_product))); renderJson(Result.object(OrderStatService.me.salestat(tm)));
} else { } else {
Workbook wb = OrderStatService.me.yearStatBySupExport(tm, stat_product); Workbook wb = OrderStatService.me.yearsalestatExport(tm);
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -387,11 +397,14 @@ public class OrderStatController extends BaseController {
String etm = get("etm"); String etm = get("etm");
Boolean stat_product = getBoolean("stat_product", false); Boolean stat_product = getBoolean("stat_product", false);
Integer product_id = getInt("product_id"); 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 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
if (export == 0) { 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 { } 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)); render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }