修改消费明细列表查询接口
parent
f824b3f4c9
commit
1e6ff6923e
|
|
@ -210,6 +210,7 @@ public class PrepayService {
|
|||
" ,p.order_sn \n" +
|
||||
" ,p.arrive_time \n" +
|
||||
" ,p.type \n" +
|
||||
" ,p.second_weight - p.first_weight net_weight\n" +
|
||||
" ,a.supermarket_id \n" +
|
||||
" ,s.`name` supermarket_name \n" +
|
||||
" ,a.truck_license \n" +
|
||||
|
|
|
|||
|
|
@ -1195,7 +1195,8 @@ public class OrderStatService {
|
|||
// paraTemp.add(tm + "%");
|
||||
|
||||
temp_sql += " and t.create_time between ? and ? \n";
|
||||
addTm(tm, paraTemp); }
|
||||
addTm(tm, paraTemp);
|
||||
}
|
||||
|
||||
if (isprepaid != null) {
|
||||
temp_sql += " and t.isprepaid = ? \n";
|
||||
|
|
@ -1396,7 +1397,7 @@ public class OrderStatService {
|
|||
// paraList.add(tm + "%");
|
||||
temp_sql += " and t.create_time between ? and ? \n";
|
||||
|
||||
addTm(tm,paraList);
|
||||
addTm(tm, paraList);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1553,7 +1554,7 @@ public class OrderStatService {
|
|||
" where t.state = 5\n" +
|
||||
" and t.create_time between ? and ? \n" +
|
||||
" group by t.supermarket_id,t.product_id,t.product_name\n" +
|
||||
") a on s.id = a.id order by s.id", year + "-01-01 00:00:00",year + "-12-31 23:59:59");
|
||||
") a on s.id = a.id order by s.id", year + "-01-01 00:00:00", year + "-12-31 23:59:59");
|
||||
} else {
|
||||
list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight from supermarket s\n" +
|
||||
"left join (\n" +
|
||||
|
|
@ -1561,7 +1562,7 @@ public class OrderStatService {
|
|||
" where t.state = 5\n" +
|
||||
" and t.create_time between ? and ? \n" +
|
||||
" group by t.supermarket_id\n" +
|
||||
") a on s.id = a.id order by s.id", year + "-01-01 00:00:00",year + "-12-31 23:59:59");
|
||||
") a on s.id = a.id order by s.id", year + "-01-01 00:00:00", year + "-12-31 23:59:59");
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -2276,24 +2277,86 @@ public class OrderStatService {
|
|||
saleParam += " and t.sale_type = ? \n";
|
||||
}
|
||||
|
||||
String union_4 = "union select\n" +
|
||||
String union_4 = "";
|
||||
String union_99 = "";
|
||||
String today = "";
|
||||
String endDay = etm.split(" ")[0];
|
||||
if (LocalDate.now().toString().equals(endDay)) {
|
||||
|
||||
union_4 = "union select\n" +
|
||||
" ifnull(t.customer_id, 0) customer_id,\n" +
|
||||
" t.supermarket_id,\n" +
|
||||
" ifnull(sum(t.weight), 0) weight,\n" +
|
||||
" ifnull(sum(t.total_price), 0) total_price\n" +
|
||||
" from order_temp t\n" +
|
||||
" where t.state = 5\n" +
|
||||
" where t.state = 5\n";
|
||||
// " and t.product_id != 4\n" +
|
||||
saleParam +
|
||||
" and t.supermarket_id = 4\n" +
|
||||
|
||||
if (invoice_type != null) {
|
||||
union_4 += "and t.invoice_type = " + invoice_type + " \n";
|
||||
}
|
||||
|
||||
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
union_4 += " and t.sale_type = " + sale_type + " \n";
|
||||
}
|
||||
|
||||
union_4 += " and t.supermarket_id = 4\n" +
|
||||
" and (t.create_time < '2021-09-08 00:00:00'\n" +
|
||||
" or t.create_time > '2021-10-15 23:59:59')\n" +
|
||||
" AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' )" +
|
||||
// " and t.create_time >= ? \n" +
|
||||
// " and t.create_time <= ?\n" +
|
||||
" and (t.create_time < '2021-10-20 00:00:00' or t.create_time > '2021-10-20 23:59:59')\n" +
|
||||
paramsSql +
|
||||
" group by t.customer_id\n";
|
||||
|
||||
union_99 = " union select\n" +
|
||||
" ifnull(t.customer_id, 0) customer_id,\n" +
|
||||
" 99 supermarket_id,\n" +
|
||||
" ifnull(sum(t.weight), 0) weight,\n" +
|
||||
" ifnull(sum(t.total_price), 0) total_price\n" +
|
||||
" from order_temp t\n" +
|
||||
" where t.state = 5\n" ;
|
||||
// " and t.product_id != 4\n" +
|
||||
if (invoice_type != null) {
|
||||
union_99 += "and t.invoice_type = " + invoice_type + " \n";
|
||||
}
|
||||
|
||||
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
union_99 += " and t.sale_type = " + sale_type + " \n";
|
||||
}
|
||||
union_99 += " and t.supermarket_id = 4\n" +
|
||||
" and ((t.create_time >= '2021-09-08 00:00:00' and t.create_time <= '2021-10-15 23:59:59') \n" +
|
||||
" or (t.create_time >= '2021-10-20 00:00:00' and t.create_time <= '2021-10-20 23:59:59'))\n" +
|
||||
" AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' ) \n" +
|
||||
// " and t.create_time >= ? \n" +
|
||||
// " and t.create_time <= ?\n" +
|
||||
" group by t.customer_id\n";
|
||||
|
||||
today = " select\n" +
|
||||
" ifnull(t.customer_id, 0) customer_id,\n" +
|
||||
" t.supermarket_id,\n" +
|
||||
" ifnull(sum(t.weight), 0) weight,\n" +
|
||||
" ifnull(sum(t.total_price), 0) total_price\n" +
|
||||
" from order_temp t\n" +
|
||||
" where t.state = 5\n" ;
|
||||
// " and t.product_id != 4\n" +
|
||||
if (invoice_type != null) {
|
||||
today += "and t.invoice_type = " + invoice_type + " \n";
|
||||
}
|
||||
|
||||
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
today += " and t.sale_type = " + sale_type + " \n";
|
||||
}
|
||||
today += " and t.supermarket_id != 4\n" +
|
||||
" AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' ) \n" +
|
||||
// " and t.create_time>= ? \n" +
|
||||
// " and t.create_time<= ?\n" +
|
||||
// paramsSql +
|
||||
" group by t.customer_id, t.supermarket_id \n " +
|
||||
" union \n ";
|
||||
}
|
||||
|
||||
|
||||
union_4 += " UNION\n" +
|
||||
" SELECT\n" +
|
||||
" ifnull( t.customer_id, 0 ) customer_id,\n" +
|
||||
|
|
@ -2306,28 +2369,14 @@ public class OrderStatService {
|
|||
" t.supermarket_id != 4 \n" +
|
||||
" AND t.date >= ? \n" +
|
||||
" AND t.date <= ? \n" +
|
||||
" and (t.date < '2021-09-08'\n" +
|
||||
" or t.date > '2021-10-15')\n" +
|
||||
" and (t.date < '2021-10-20' or t.date > '2021-10-20')\n" +
|
||||
saleParam +
|
||||
" GROUP BY\n" +
|
||||
" t.customer_id,\n" +
|
||||
" t.supermarket_id";
|
||||
|
||||
String union_99 = " union select\n" +
|
||||
" ifnull(t.customer_id, 0) customer_id,\n" +
|
||||
" 99 supermarket_id,\n" +
|
||||
" ifnull(sum(t.weight), 0) weight,\n" +
|
||||
" ifnull(sum(t.total_price), 0) total_price\n" +
|
||||
" from order_temp t\n" +
|
||||
" where t.state = 5\n" +
|
||||
// " and t.product_id != 4\n" +
|
||||
saleParam +
|
||||
" and t.supermarket_id = 4\n" +
|
||||
" and ((t.create_time >= '2021-09-08 00:00:00' and t.create_time <= '2021-10-15 23:59:59') \n" +
|
||||
" or (t.create_time >= '2021-10-20 00:00:00' and t.create_time <= '2021-10-20 23:59:59'))\n" +
|
||||
" AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' ) \n" +
|
||||
// " and t.create_time >= ? \n" +
|
||||
// " and t.create_time <= ?\n" +
|
||||
paramsSql +
|
||||
" group by t.customer_id\n";
|
||||
|
||||
union_99 += " union SELECT\n" +
|
||||
" ifnull( t.customer_id, 0 ) customer_id,\n" +
|
||||
|
|
@ -2371,26 +2420,12 @@ public class OrderStatService {
|
|||
" ifnull(sum(case when g.supermarket_id = 12 then g.total_price end), 0) xse_12,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 99 then g.total_price end), 0) xse_99\n" +
|
||||
" from (\n" +
|
||||
today +
|
||||
" select\n" +
|
||||
" ifnull(t.customer_id, 0) customer_id,\n" +
|
||||
" t.supermarket_id,\n" +
|
||||
" ifnull(sum(t.weight), 0) weight,\n" +
|
||||
" ifnull(sum(t.total_price), 0) total_price\n" +
|
||||
" from order_temp t\n" +
|
||||
" where t.state = 5\n" +
|
||||
// " and t.product_id != 4\n" +
|
||||
saleParam +
|
||||
" and t.supermarket_id != 4\n" +
|
||||
" AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' ) \n" +
|
||||
// " and t.create_time>= ? \n" +
|
||||
// " and t.create_time<= ?\n" +
|
||||
paramsSql +
|
||||
" group by t.customer_id, t.supermarket_id\n" +
|
||||
" union select\n" +
|
||||
" ifnull(t.customer_id, 0) customer_id,\n" +
|
||||
" t.supermarket_id,\n" +
|
||||
" ifnull(sum(t.weight), 0) weight,\n" +
|
||||
" ifnull(sum(t.total_price), 0) total_price\n" +
|
||||
" from order_end t\n" +
|
||||
" where t.supermarket_id != 4\n" +
|
||||
// " and t.product_id != 4\n" +
|
||||
|
|
@ -2406,13 +2441,14 @@ public class OrderStatService {
|
|||
|
||||
if (invoice_type != null) {
|
||||
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
customer_sale_list = Db.find(sql, sale_type, invoice_type,stm, etm,sale_type, sale_type,invoice_type, stm, etm, sale_type, sale_type,invoice_type, stm, etm, sale_type);
|
||||
customer_sale_list = Db.find(sql, stm, etm, sale_type, stm, etm, sale_type, stm, etm, sale_type);
|
||||
} else {
|
||||
customer_sale_list = Db.find(sql, stm, etm, invoice_type, stm, etm, invoice_type, stm, etm, invoice_type);
|
||||
// customer_sale_list = Db.find(sql, stm, etm, invoice_type, stm, etm, invoice_type, stm, etm, invoice_type);
|
||||
customer_sale_list = Db.find(sql, stm, etm, stm, etm, stm, etm);
|
||||
}
|
||||
} else {
|
||||
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
customer_sale_list = Db.find(sql, sale_type, stm, etm, sale_type, sale_type, stm, etm, sale_type,sale_type, stm, etm, sale_type);
|
||||
customer_sale_list = Db.find(sql,stm, etm, sale_type, stm, etm, sale_type, stm, etm, sale_type);
|
||||
} else {
|
||||
customer_sale_list = Db.find(sql, stm, etm, stm, etm, stm, etm);
|
||||
}
|
||||
|
|
@ -2439,10 +2475,10 @@ public class OrderStatService {
|
|||
// "and t.product_id != 4\n" +
|
||||
" and t.date <= ?\n" +
|
||||
" and t.sale_type = 0\n" +
|
||||
" group by t.customer_id\n" ;
|
||||
" group by t.customer_id\n";
|
||||
|
||||
// 如果是当天的就加上销售订单数据
|
||||
if (LocalDate.now().toString().equals(tm)){
|
||||
if (LocalDate.now().toString().equals(tm)) {
|
||||
tempSql += "UNION select t.customer_id, sum(t.total_price) total_price\n" +
|
||||
" from order_temp t\n" +
|
||||
" where t.customer_id is not null\n" +
|
||||
|
|
@ -2451,7 +2487,7 @@ public class OrderStatService {
|
|||
" and t.create_time <= ?\n" +
|
||||
" and t.state = 5\n" +
|
||||
" and t.sale_type = 0\n" +
|
||||
" group by t.customer_id\n" ;
|
||||
" group by t.customer_id\n";
|
||||
customer_pre_list_params.add(tm + STM_SUFFIX);
|
||||
customer_pre_list_params.add(tm + ETM_SUFFIX);
|
||||
|
||||
|
|
@ -2558,7 +2594,7 @@ public class OrderStatService {
|
|||
// });
|
||||
|
||||
customer_pre_list.sort(Comparator.comparing(o ->
|
||||
Objects.nonNull(o.getInt("customer_type_id"))? CustomerTypeEnum.getSortById(String.valueOf(o.getInt("customer_type_id"))) : Integer.valueOf(-1)));
|
||||
Objects.nonNull(o.getInt("customer_type_id")) ? CustomerTypeEnum.getSortById(String.valueOf(o.getInt("customer_type_id"))) : Integer.valueOf(-1)));
|
||||
|
||||
|
||||
Map<Integer, Record> salemap = new HashMap<>();
|
||||
|
|
@ -2736,7 +2772,7 @@ public class OrderStatService {
|
|||
// });
|
||||
|
||||
typelist.sort(Comparator.comparing(o ->
|
||||
Objects.nonNull(o.getInt("customer_type_id"))? CustomerTypeEnum.getSortById(String.valueOf(o.getInt("customer_type_id"))) : Integer.valueOf(-1)));
|
||||
Objects.nonNull(o.getInt("customer_type_id")) ? CustomerTypeEnum.getSortById(String.valueOf(o.getInt("customer_type_id"))) : Integer.valueOf(-1)));
|
||||
|
||||
Record record = new Record();
|
||||
|
||||
|
|
@ -2990,6 +3026,7 @@ public class OrderStatService {
|
|||
|
||||
/**
|
||||
* 各砂站预售金额、提货额统计
|
||||
*
|
||||
* @param stm
|
||||
* @param etm
|
||||
* @return
|
||||
|
|
@ -3304,6 +3341,7 @@ public class OrderStatService {
|
|||
* }
|
||||
* ]
|
||||
* 砂站年统计
|
||||
*
|
||||
* @param tm
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -3514,7 +3552,7 @@ public class OrderStatService {
|
|||
if (yhMap.size() > 0) {
|
||||
yhList1.addAll(yhMap.values());
|
||||
}
|
||||
} else if(yhMap.size() == 1) {
|
||||
} else if (yhMap.size() == 1) {
|
||||
yhList1.addAll(yhMap.values());
|
||||
}
|
||||
} else {
|
||||
|
|
@ -3750,22 +3788,23 @@ public class OrderStatService {
|
|||
return type == 1 ? retChildren : retList;
|
||||
}
|
||||
|
||||
private void addTm(String tm, List<Object> list){
|
||||
private void addTm(String tm, List<Object> list) {
|
||||
switch (tm.length()) {
|
||||
case 4:{ // 年
|
||||
case 4: { // 年
|
||||
|
||||
list.add(tm + "-01-01 00:00:00");
|
||||
list.add(tm + "-12-31 23:59:59");
|
||||
|
||||
break;
|
||||
}case 7:{ // 月
|
||||
}
|
||||
case 7: { // 月
|
||||
|
||||
list.add(tm + "-01 00:00:00");
|
||||
list.add(tm + "-31 23:59:59");
|
||||
|
||||
break;
|
||||
}
|
||||
case 10:{ // 日
|
||||
case 10: { // 日
|
||||
|
||||
list.add(tm + " 00:00:00");
|
||||
list.add(tm + " 23:59:59");
|
||||
|
|
|
|||
Loading…
Reference in New Issue