统计添加客户类型筛选
parent
1446981fd6
commit
4e0227d14c
|
|
@ -98,7 +98,7 @@ public class OrderStatService {
|
||||||
if (customer_type_id != null && customer_type_id >= 0 && customer_type_id != 99) {
|
if (customer_type_id != null && customer_type_id >= 0 && customer_type_id != 99) {
|
||||||
temp_sql += " and c.customer_type_id = ? \n";
|
temp_sql += " and c.customer_type_id = ? \n";
|
||||||
paraTempList.add(customer_type_id);
|
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";
|
temp_sql += " and t.customer_id is null \n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -349,12 +349,12 @@ public class OrderStatService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用实际支付金额统计
|
// 使用实际支付金额统计
|
||||||
if(stat_product){
|
if (stat_product) {
|
||||||
if(product_id != null && product_id > 0){
|
if (product_id != null && product_id > 0) {
|
||||||
paramsSql += " and t.product_id = ? \n";
|
paramsSql += " and t.product_id = ? \n";
|
||||||
paraList.add(product_id);
|
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" +
|
" 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" +
|
" 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" +
|
" from order_temp t\n" +
|
||||||
|
|
@ -362,7 +362,7 @@ public class OrderStatService {
|
||||||
" and t.create_time like ?\n" +
|
" and t.create_time like ?\n" +
|
||||||
" ) t\n" +
|
" ) t\n" +
|
||||||
" left join supermarket s on s.id = t.supermarket_id\n" +
|
" left join supermarket s on s.id = t.supermarket_id\n" +
|
||||||
" where 1 = 1 \n"+
|
" where 1 = 1 \n" +
|
||||||
paramsSql +
|
paramsSql +
|
||||||
" group by t.customer_name, t.supermarket_id, t.product_id, t.product_name";
|
" group by t.customer_name, t.supermarket_id, t.product_id, t.product_name";
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -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) {
|
||||||
if(stat_product){
|
paraList.add(invoice_type);
|
||||||
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" +
|
|
||||||
|
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" +
|
" 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) {
|
||||||
}else {
|
if (customer_type_id == 99) {
|
||||||
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 t.customer_id is null \n";
|
||||||
" from (\n" +
|
} else {
|
||||||
" select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type\n" +
|
sql += " and c.customer_type_id = ? \n";
|
||||||
" from order_temp t\n" +
|
paraList.add(customer_type_id);
|
||||||
" 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 + "%");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sql += " ) t\n" +
|
||||||
|
" group by t.customer_name,t.product_id,t.product_name";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
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\n" +
|
||||||
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" +
|
" 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" +
|
" and t.invoice_type = ? \n";
|
||||||
" group by t.customer_name",
|
if (customer_id != null) {
|
||||||
OrderStateEnum.RECEIVED.getStateid(),
|
sql += " and c.id = ? \n";
|
||||||
tm + "%"
|
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) {
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
@ -849,7 +910,7 @@ public class OrderStatService {
|
||||||
productParams += " and t.supermarket_id = ?\n";
|
productParams += " and t.supermarket_id = ?\n";
|
||||||
paramsArray.add(supermarket_id);
|
paramsArray.add(supermarket_id);
|
||||||
}
|
}
|
||||||
if(stat_product){
|
if (stat_product) {
|
||||||
if (product_id != null && product_id > 0) {
|
if (product_id != null && product_id > 0) {
|
||||||
productParams += " and t.product_id = ?\n";
|
productParams += " and t.product_id = ?\n";
|
||||||
paramsArray.add(product_id);
|
paramsArray.add(product_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; // 数据共有几列
|
||||||
|
|
@ -1392,7 +1466,7 @@ public class OrderStatService {
|
||||||
public List<Record> yearStatBySup(String year, Boolean stat_product) {
|
public List<Record> yearStatBySup(String year, Boolean stat_product) {
|
||||||
List<Record> list;
|
List<Record> list;
|
||||||
if (StrKit.notBlank(year)) {
|
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" +
|
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 from order_temp t\n" +
|
||||||
|
|
@ -1400,7 +1474,7 @@ public class OrderStatService {
|
||||||
" and t.create_time like ? \n" +
|
" and t.create_time like ? \n" +
|
||||||
" group by t.supermarket_id,t.product_id,t.product_name\n" +
|
" group by t.supermarket_id,t.product_id,t.product_name\n" +
|
||||||
") a on s.id = a.id order by s.id", year + "%");
|
") 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" +
|
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 from order_temp t\n" +
|
||||||
|
|
@ -1411,14 +1485,14 @@ public class OrderStatService {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} 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" +
|
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 from order_temp t\n" +
|
||||||
" where t.state = 5\n" +
|
" where t.state = 5\n" +
|
||||||
" group by t.supermarket_id,t.product_id,t.product_name\n" +
|
" group by t.supermarket_id,t.product_id,t.product_name\n" +
|
||||||
") a on s.id = a.id order by s.id");
|
") 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" +
|
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 from order_temp t\n" +
|
||||||
|
|
@ -1502,23 +1576,25 @@ public class OrderStatService {
|
||||||
paramsArray.add(stm);
|
paramsArray.add(stm);
|
||||||
paramsArray.add(etm);
|
paramsArray.add(etm);
|
||||||
if (stat_product) {
|
if (stat_product) {
|
||||||
if(product_id != null && product_id > 0){
|
if (product_id != null && product_id > 0) {
|
||||||
paramsSql+=" and t.product_id=? \n";
|
paramsSql += " and t.product_id=? \n";
|
||||||
paramsArray.add(product_id);
|
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" +
|
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" +
|
||||||
paramsSql+
|
paramsSql +
|
||||||
" group by t.supermarket_id,t.product_id,t.product_name\n" +
|
" group by t.supermarket_id,t.product_id,t.product_name\n" +
|
||||||
") a on s.id = a.id order by s.id", paramsArray.toArray());
|
") 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" +
|
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" +
|
||||||
|
|
@ -1550,7 +1626,7 @@ public class OrderStatService {
|
||||||
return list;
|
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<Record> list = yearStatBySup(stm, etm, stat_product, product_id);
|
List<Record> list = yearStatBySup(stm, etm, stat_product, product_id);
|
||||||
Workbook wb = new XSSFWorkbook();
|
Workbook wb = new XSSFWorkbook();
|
||||||
Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + etm.substring(0, 10) + "年销售汇总");
|
Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + etm.substring(0, 10) + "年销售汇总");
|
||||||
|
|
@ -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" +
|
|
||||||
|
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" +
|
" ) 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 {
|
} else {
|
||||||
list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus 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 from order_temp t\n" +
|
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" +
|
" where t.state = 5\n" +
|
||||||
" and t.create_time like ? \n" +
|
" and t.create_time like ? \n";
|
||||||
" group by t.customer_id\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" +
|
" ) 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 {
|
} 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" +
|
||||||
|
" 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" +
|
" ) 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");
|
|
||||||
}else {
|
list = Db.find(sql, paraList.toArray());
|
||||||
list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus from (\n" +
|
} else {
|
||||||
" 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" +
|
List<Object> paraList = new ArrayList<>();
|
||||||
" where t.state = 5\n" +
|
String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus from (\n" +
|
||||||
" group by t.customer_id\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" +
|
" ) 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();
|
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,37 +1864,70 @@ 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<>();
|
||||||
paramsArray.add(stm);
|
paramsArray.add(stm);
|
||||||
paramsArray.add(etm);
|
paramsArray.add(etm);
|
||||||
if(stat_product){
|
if (stat_product) {
|
||||||
if(product_id != null && product_id > 0){
|
if (product_id != null && product_id > 0) {
|
||||||
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" +
|
|
||||||
|
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" +
|
" ) 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());
|
|
||||||
}else {
|
list = Db.find(sql, paramsArray.toArray());
|
||||||
list = Db.find("select c.id, ifnull(c.name, '零散') name, a.*, p.surplus total_surplus from (\n" +
|
} else {
|
||||||
" 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" +
|
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) + "时段销售汇总");
|
||||||
|
|
||||||
|
|
@ -2014,7 +2190,7 @@ public class OrderStatService {
|
||||||
ids.add(r.getStr("customer_id"));
|
ids.add(r.getStr("customer_id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ids.isEmpty()){
|
if (!ids.isEmpty()) {
|
||||||
cidsql = " c.id in(" + StrKit.join(ids, ",") + ") or ";
|
cidsql = " c.id in(" + StrKit.join(ids, ",") + ") or ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ public class OrderStatController extends BaseController {
|
||||||
String tm = get("tm");
|
String tm = get("tm");
|
||||||
int export = getInt("export", 0);
|
int export = getInt("export", 0);
|
||||||
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);
|
||||||
|
|
||||||
if (export == 0) {
|
if (export == 0) {
|
||||||
renderJson(Result.object(OrderStatService.me.monthgrid(tm, supermarket_id, customer_id, stat_product, product_id)));
|
renderJson(Result.object(OrderStatService.me.monthgrid(tm, supermarket_id, customer_id, stat_product, product_id)));
|
||||||
|
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -155,7 +159,7 @@ public class OrderStatController extends BaseController {
|
||||||
String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59"
|
String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59"
|
||||||
Integer supermarket_id = getInt("supermarket_id");
|
Integer supermarket_id = getInt("supermarket_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);
|
||||||
Integer product_id = getInt("product_id");
|
Integer product_id = getInt("product_id");
|
||||||
|
|
||||||
if (export == 0) {
|
if (export == 0) {
|
||||||
|
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -305,12 +314,12 @@ public class OrderStatController extends BaseController {
|
||||||
public void statYearBySup() {
|
public void statYearBySup() {
|
||||||
String tm = get("tm");
|
String tm = get("tm");
|
||||||
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -320,13 +329,15 @@ public class OrderStatController extends BaseController {
|
||||||
String stm = get("stm");
|
String stm = get("stm");
|
||||||
String etm = get("etm");
|
String etm = get("etm");
|
||||||
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -335,7 +346,7 @@ public class OrderStatController extends BaseController {
|
||||||
public void statRangeAllSup() {
|
public void statRangeAllSup() {
|
||||||
String stm = get("stm");
|
String stm = get("stm");
|
||||||
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");
|
||||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -193,9 +193,15 @@ public class StatSmsJob implements Job {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 累计销售汇总,含前日汇总
|
* 累计销售汇总,含前日汇总
|
||||||
* 王乐 2021-08-17
|
* 王乐 2021-09-22
|
||||||
* 四家客户2020年12月30日、31日两天的销售数据是固定值(4677.26吨、420953.4元)
|
*
|
||||||
* 2021年新增客户销售=2021年销售汇总 -四家客户充值金额(2000万)+四家客户2020年12月30日、31日两天的销售数据
|
* 274.62-27.34
|
||||||
|
* 21830.32-2011.27
|
||||||
|
*
|
||||||
|
* 新增客户销售的计算公式
|
||||||
|
*
|
||||||
|
* 27.34和2011.27这两个数是固定值
|
||||||
|
* 274.62和21830.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)));
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ public class OrderStatController extends BaseController {
|
||||||
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 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);
|
||||||
|
|
||||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -184,14 +188,14 @@ public class OrderStatController extends BaseController {
|
||||||
String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00"
|
String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00"
|
||||||
String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59"
|
String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59"
|
||||||
Integer supermarket_id = getInt("supermarket_id");
|
Integer supermarket_id = getInt("supermarket_id");
|
||||||
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");
|
||||||
int export = getInt("export", 0);
|
int export = getInt("export", 0);
|
||||||
|
|
||||||
if (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 {
|
} 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));
|
render(new ExcelRender(stm.substring(0, 10) + "至" + etm.substring(0, 10) + "_销售月逐日统计_" + 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -372,11 +382,11 @@ public class OrderStatController extends BaseController {
|
||||||
public void statYearBySup() {
|
public void statYearBySup() {
|
||||||
String tm = get("tm");
|
String tm = get("tm");
|
||||||
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -385,13 +395,16 @@ public class OrderStatController extends BaseController {
|
||||||
public void statRangeAllCustomer() {
|
public void statRangeAllCustomer() {
|
||||||
String stm = get("stm");
|
String stm = get("stm");
|
||||||
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -400,13 +413,13 @@ public class OrderStatController extends BaseController {
|
||||||
public void statRangeAllSup() {
|
public void statRangeAllSup() {
|
||||||
String stm = get("stm");
|
String stm = get("stm");
|
||||||
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");
|
||||||
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.yearStatBySup(stm, etm, stat_product,product_id)));
|
renderJson(Result.object(OrderStatService.me.yearStatBySup(stm, etm, stat_product, product_id)));
|
||||||
} else {
|
} 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));
|
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue