统计加入是否预售提货下拉选择

dev
wuwenxiong 2022-01-06 11:32:32 +08:00
parent c456fef6fb
commit 60be64bc14
7 changed files with 291 additions and 149 deletions

View File

@ -65,12 +65,12 @@ public class PresellOrderService extends BaseService {
}
if (StrKit.notBlank(stm)) {
fromsql += " and t.create_time >= ?";
fromsql += " and t.presell_date >= ?";
paraList.add(stm);
}
if (StrKit.notBlank(etm)) {
fromsql += " and t.create_time <= ?";
fromsql += " and t.presell_date <= ?";
paraList.add(etm);
}
@ -143,12 +143,12 @@ public class PresellOrderService extends BaseService {
}
if (StrKit.notBlank(stm)) {
sql += " and t.create_time >= ?";
sql += " and t.presell_date >= ?";
paraList.add(stm);
}
if (StrKit.notBlank(etm)) {
sql += " and t.create_time <= ?";
sql += " and t.presell_date <= ?";
paraList.add(etm);
}

View File

@ -27,7 +27,7 @@ public class CustomerStatService {
public List<Record> checkAccount(String tm, Integer customer_id, Integer customer_type_id) {
String querytm = tm + " 23:59:59";
String sql;
String fromSql;
String selectSql;
String tempSql;
String customerSql = "";
List<Object> paraList = new ArrayList<>();
@ -36,7 +36,7 @@ public class CustomerStatService {
customerSql = " and t.customer_id = ? \n";
}
fromSql = "select t.customer_id id,\n" +
selectSql = "select t.customer_id id,\n" +
" c.`name`,\n" +
" t.surplus,\n" +
" a.total_price,\n" +
@ -44,7 +44,8 @@ public class CustomerStatService {
" a.total_cnt,\n" +
" b.amount,\n" +
" b.refund_amount,\n" +
" b.amount - ifnull(a.total_price,0) - b.refund_amount then_surplus\n";
" b.amount - ifnull(a.total_price,0) - b.refund_amount then_surplus";
tempSql = " select t.customer_id, sum(t.total_price) total_price, sum(t.weight) total_weight, count(t.sn) total_cnt\n" +
" from order_temp t\n" +
" where t.customer_id is not null\n" +
@ -62,10 +63,10 @@ public class CustomerStatService {
paraList.add(customer_id);
paraList.add(customer_id);
sql = fromSql +
sql = selectSql +
" from prepay_customer t\n" +
" left join customer c on c.id= t.customer_id\n" +
" join(\n" +
" left join(\n" +
tempSql +
" ) a on a.customer_id = t.customer_id\n" +
" left join(\n" +
@ -95,15 +96,39 @@ public class CustomerStatService {
" where t.customer_id = ? \n" +
" order by t.customer_id";
return Db.find(sql, paraList.toArray());
String _sql = " select \n" +
" s.id, \n" +
" s.`name`, \n" +
" s.surplus, \n" +
" s.total_price, \n" +
" s.total_weight, \n" +
" s.total_cnt, \n" +
" s.amount, \n" +
" s.refund_amount, \n" +
" ifnull(sum(p.presell_amount), 0) presell_amount, \n" +
" s.then_surplus - ifnull(sum(p.presell_amount), 0) then_surplus\n" +
" from ( " + sql + " ) s left join presell_order p on s.id = p.customer_id where p.del = 0 and s.id = ? group by s.id";
paraList.add(customer_id);
return Db.find(_sql, paraList.toArray());
} else {
paraList.add(querytm);
paraList.add(querytm);
paraList.add(querytm);
sql = fromSql +
sql = "select \n" +
" t.customer_id id,\n" +
" c.`name`,\n" +
" t.surplus,\n" +
" a.total_price,\n" +
" a.total_weight,\n" +
" a.total_cnt,\n" +
" b.amount,\n" +
" b.refund_amount,\n" +
" ifnull(p.presell_amount,0) presell_amount,\n" +
" b.amount - ifnull(a.total_price,0) - b.refund_amount - ifnull(p.presell_amount,0) then_surplus" +
" from prepay_customer t\n" +
" left join customer c on c.id= t.customer_id\n" +
" join (\n" + tempSql + " ) a on a.customer_id = t.customer_id\n" +
" left join (\n" + tempSql + " ) a on a.customer_id = t.customer_id\n" +
" left join(\n" +
" select a.customer_id, a.amount, ifnull(b.amount, 0) refund_amount\n" +
" from(\n" +
@ -125,7 +150,9 @@ public class CustomerStatService {
" and a.confirm_time <= ?\n" +
" group by t.customer_id\n" +
" ) b on b.customer_id= a.customer_id\n" +
" ) b on b.customer_id= t.customer_id\n";
" ) b on b.customer_id= t.customer_id\n" +
" left join (select customer_id, ifnull(sum(presell_amount), 0) presell_amount from presell_order where del = 0 group by customer_id) p\n" +
" on p.customer_id = t.customer_id";
if (customer_type_id != null) { // 客户对账不管临散订单
sql += " where c.customer_type_id = ? \n";
@ -147,10 +174,11 @@ public class CustomerStatService {
// 表头 start
Row row = sheet.createRow(0);
int a = 0;
int end_col = 8;
int end_col = 9;
row.createCell(a++).setCellValue("序号");
row.createCell(a++).setCellValue("客户");
row.createCell(a++).setCellValue("余额");
row.createCell(a++).setCellValue("预售金额");
row.createCell(a++).setCellValue("累计充值");
row.createCell(a++).setCellValue("累计退款");
row.createCell(a++).setCellValue("累计消费金额(元)");
@ -168,6 +196,7 @@ public class CustomerStatService {
row.createCell(a++).setCellValue(i + 1);
row.createCell(a++).setCellValue(record.getStr("name"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "then_surplus"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "presell_amount"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "amount"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "refund_amount"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "total_price"));

View File

@ -3,7 +3,6 @@ package com.cowr.ssjygl.stat.invoice;
import com.cowr.common.validator.DayValidator;
import com.cowr.common.view.ExcelRender;
import com.cowr.common.view.Result;
import com.cowr.ssjygl.stat.sale.OrderStatService;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import org.apache.poi.ss.usermodel.Workbook;
@ -23,10 +22,11 @@ public class InvoiceUseController extends Controller {
Integer order_state = getInt("order_state");
Integer product_id = getInt("product_id");
int export = getInt("export", 0);
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.success(InvoiceUseService.me.statuse(tm, supermarket_id, invoice_type, invoice_number, invoice_code, invoice_state, ticket_code, order_sn, truck_license, order_state, product_id)));
renderJson(Result.success(InvoiceUseService.me.statuse(tm, supermarket_id, invoice_type, invoice_number, invoice_code, invoice_state, ticket_code, order_sn, truck_license, order_state, product_id, sale_type)));
}else{
Workbook wb = InvoiceUseService.me.statuseExport(tm, supermarket_id, invoice_type, invoice_number, invoice_code, invoice_state, ticket_code, order_sn, truck_license, order_state, product_id);
Workbook wb = InvoiceUseService.me.statuseExport(tm, supermarket_id, invoice_type, invoice_number, invoice_code, invoice_state, ticket_code, order_sn, truck_license, order_state, product_id, sale_type);
render(new ExcelRender(tm + "_票据使用记录_" + System.currentTimeMillis() + ".xlsx", wb));
}
}

View File

@ -40,7 +40,8 @@ public class InvoiceUseService {
String order_sn,
String truck_license,
Integer order_state,
Integer product_id
Integer product_id,
Integer sale_type
) {
String logsql = "select \n" +
" t.id rowkey, t.invoice_number, t.`code` invoice_code, t.state invoice_state, t.settlement_user_name, t.settlement_time, t.create_time, t.invalid_time, t.invalid_memo, t.invoice_type, t.invalid_user_name\n" +
@ -75,6 +76,14 @@ public class InvoiceUseService {
paramord.add(tm);
paramord.add(tm);
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
logsql += " and o.sale_type = ? \n";
ordsql += " and t.sale_type = ? \n";
paramlog.add(sale_type);
paramord.add(sale_type);
}
if (supermarket_id != null) {
logsql += " and r.supermarket_id = ? \n"; // 这里用领用记录的 supermarket_id
ordsql += " and t.supermarket_id = ? \n";
@ -247,9 +256,10 @@ public class InvoiceUseService {
String order_sn,
String truck_license,
Integer order_state,
Integer product_id
Integer product_id,
Integer sale_type
) {
Record ret = statuse(tm, supermarket_id, invoice_type, invoice_number, invoice_code, invoice_state, ticket_code, order_sn, truck_license, order_state, product_id);
Record ret = statuse(tm, supermarket_id, invoice_type, invoice_number, invoice_code, invoice_state, ticket_code, order_sn, truck_license, order_state, product_id, sale_type);
List<Record> list = ret.get("list");

View File

@ -521,7 +521,14 @@ public class OrderStatService {
*
* @return
*/
public List<Record> salestat(String tm) {
public List<Record> salestat(String tm, Integer sale_type) {
String saleParams = "";
List<Object> params = new ArrayList<>();
params.add(tm + "%");
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
saleParams += " and t.sale_type = ? \n";
params.add(sale_type);
}
String sql = "select s.id, s.name, s.name2, p.id product_id, p.`name` product_name, ifnull(a.orderCount, 0) as orderCount, ifnull(a.totalPrice, 0) as totalPrice, ifnull(a.weight, 0) as weight\n" +
" from supermarket_product t\n" +
" left join (\n" +
@ -529,15 +536,16 @@ public class OrderStatService {
" from (\n" +
" select t.supermarket_id as id, t.paid, t.total_price, t.weight, t.product_id\n" +
" from order_temp t\n" +
" where t.state = ? \n" +
" where t.state = 5 \n" +
" and t.create_time like ? \n" +
saleParams +
" ) t\n" +
" group by t.id, t.product_id\n" +
" ) a on a.id = t.supermarket_id and a.product_id = t.product_id\n" +
" left join supermarket s on s.id = t.supermarket_id\n" +
" left join product p on p.id = t.product_id";
List<Record> dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), tm + "%");
List<Record> dblist = Db.find(sql, params.toArray());
Record total = new Record();
total.set("id", 0);
@ -565,11 +573,17 @@ public class OrderStatService {
* @param tm
* @return
*/
public List<Record> salestatCustomer(String tm, Integer invoice_type, Boolean stat_product, Integer customer_id, Integer customer_type_id) {
public List<Record> salestatCustomer(String tm, Integer invoice_type, Boolean stat_product, Integer customer_id, Integer customer_type_id, Integer sale_type) {
String saleParams = "";
List<Object> paraList = new ArrayList<>();
paraList.add(OrderStateEnum.RECEIVED.getStateid());
paraList.add(tm + "%");
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
saleParams += " and t.sale_type = ? \n";
paraList.add(sale_type);
}
String sql;
if (invoice_type != null) {
paraList.add(invoice_type);
@ -582,6 +596,7 @@ public class OrderStatService {
" left join customer c on c.id = t.customer_id \n" +
" where t.state = ? \n" +
" and t.create_time like ? \n" +
saleParams +
" and t.invoice_type = ? \n";
if (customer_id != null) {
sql += " and c.id = ? \n";
@ -606,6 +621,7 @@ public class OrderStatService {
" left join customer c on c.id = t.customer_id \n" +
" where t.state = ? \n" +
" and t.create_time like ? \n" +
saleParams +
" and t.invoice_type = ? \n";
if (customer_id != null) {
sql += " and c.id = ? \n";
@ -630,6 +646,7 @@ public class OrderStatService {
" from order_temp t\n" +
" left join customer c on c.id = t.customer_id \n" +
" where t.state = ? \n" +
saleParams +
" and t.create_time like ? \n";
if (customer_id != null) {
sql += " and c.id = ? \n";
@ -652,6 +669,7 @@ public class OrderStatService {
" from order_temp t\n" +
" left join customer c on c.id = t.customer_id \n" +
" where t.state = ? \n" +
saleParams +
" and t.create_time like ? \n";
if (customer_id != null) {
sql += " and c.id = ? \n";
@ -696,7 +714,7 @@ public class OrderStatService {
return dblist;
}
public Workbook daysalestatExport(String tm) {
public Workbook daysalestatExport(String tm, Integer sale_type) {
String title = "销售日统计";
@ -710,10 +728,10 @@ public class OrderStatService {
subtitle += title;
return salestatExport(tm, title, subtitle);
return salestatExport(tm, title, subtitle, sale_type);
}
public Workbook monthsalestatExport(String tm) {
public Workbook monthsalestatExport(String tm, Integer sale_type) {
String title = "销售月统计";
// 副标题 start
@ -726,10 +744,10 @@ public class OrderStatService {
subtitle += title;
return salestatExport(tm, title, subtitle);
return salestatExport(tm, title, subtitle, sale_type);
}
public Workbook yearsalestatExport(String tm) {
public Workbook yearsalestatExport(String tm, Integer sale_type) {
String title = "销售年统计";
// 副标题 start
@ -742,7 +760,7 @@ public class OrderStatService {
subtitle += title;
return salestatExport(tm, title, subtitle);
return salestatExport(tm, title, subtitle, sale_type);
}
@ -752,8 +770,8 @@ public class OrderStatService {
* @param tm
* @return
*/
public Workbook salestatExport(String tm, String title, String subtitle) {
List<Record> list = salestat(tm);
public Workbook salestatExport(String tm, String title, String subtitle, Integer sale_type) {
List<Record> list = salestat(tm, sale_type);
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(title);
@ -814,8 +832,8 @@ public class OrderStatService {
* @param tm
* @return
*/
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, customer_id, customer_type_id);
public Workbook salestatCustomerExport(String tm, String title, String subtitle, Integer invoice_type, Boolean stat_product, Integer customer_id, Integer customer_type_id, Integer sale_type) {
List<Record> list = salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id, sale_type);
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(title);
@ -871,7 +889,7 @@ public class OrderStatService {
}
public Workbook daysalestatCustomerExport(String tm, Integer invoice_type, Boolean stat_product, Integer customer_id, Integer customer_type_id) {
public Workbook daysalestatCustomerExport(String tm, Integer invoice_type, Boolean stat_product, Integer customer_id, Integer customer_type_id, Integer sale_type) {
String title = "销售日统计";
@ -885,10 +903,10 @@ public class OrderStatService {
subtitle += title;
return salestatCustomerExport(tm, title, subtitle, invoice_type, stat_product, customer_id, customer_type_id);
return salestatCustomerExport(tm, title, subtitle, invoice_type, stat_product, customer_id, customer_type_id, sale_type);
}
public Workbook monthsalestatCustomerExport(String tm, Integer invoice_type, Boolean stat_product, Integer customer_id, Integer customer_type_id) {
public Workbook monthsalestatCustomerExport(String tm, Integer invoice_type, Boolean stat_product, Integer customer_id, Integer customer_type_id, Integer sale_type) {
String title = "销售月统计";
// 副标题 start
@ -901,7 +919,7 @@ public class OrderStatService {
subtitle += title;
return salestatCustomerExport(tm, title, subtitle, invoice_type, stat_product, customer_id, customer_type_id);
return salestatCustomerExport(tm, title, subtitle, invoice_type, stat_product, customer_id, customer_type_id, sale_type);
}
/**
@ -912,10 +930,15 @@ public class OrderStatService {
* @param supermarket_id
* @return
*/
public List<Record> mdstat(String stm, String etm, Integer supermarket_id, Boolean stat_product, Integer product_id) {
public List<Record> mdstat(String stm, String etm, Integer supermarket_id, Boolean stat_product, Integer product_id, Integer sale_type) {
String sql;
String saleParam = "";
List<Object> paramsArray = new ArrayList<>();
paramsArray.add(OrderStateEnum.RECEIVED.getStateid());
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
saleParam += " and t.sale_type = ? \n";
paramsArray.add(sale_type);
}
paramsArray.add(stm);
paramsArray.add(etm);
String productParams = "";
@ -935,6 +958,7 @@ public class OrderStatService {
" select t.sn, t.create_time, t.weight, t.paid, t.total_price,t.product_id,t.product_name\n" +
" from order_temp t\n" +
" where t.state = ? \n" +
saleParam +
" and t.create_time >= ? \n" +
" and t.create_time <= ? \n" +
productParams +
@ -947,6 +971,7 @@ public class OrderStatService {
" select t.sn, t.create_time, t.weight, t.paid, t.total_price\n" +
" from order_temp t\n" +
" where t.state = ? \n" +
saleParam +
" and t.create_time >= ? \n" +
" and t.create_time <= ? \n" +
productParams +
@ -995,8 +1020,8 @@ public class OrderStatService {
* @param supermarket_id
* @return
*/
public Workbook mdstatExport(String stm, String etm, Integer supermarket_id, Boolean stat_product, Integer product_id) {
List<Record> list = mdstat(stm, etm, supermarket_id, stat_product, product_id);
public Workbook mdstatExport(String stm, String etm, Integer supermarket_id, Boolean stat_product, Integer product_id, Integer sale_type) {
List<Record> list = mdstat(stm, etm, supermarket_id, stat_product, product_id, sale_type);
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("销售月逐日统计");
@ -1280,7 +1305,7 @@ public class OrderStatService {
* @param isprepaid
* @return
*/
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) {
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, Integer sale_type) {
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> paraList = new ArrayList<>();
@ -1290,6 +1315,11 @@ public class OrderStatService {
paraList.add(OrderStateEnum.RECEIVED.getStateid());
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
temp_sql += " and t.sale_type = ? \n";
paraList.add(sale_type);
}
if (supermarket_id != null) {
temp_sql += " and t.supermarket_id = ? \n";
paraList.add(supermarket_id);
@ -1389,11 +1419,11 @@ public class OrderStatService {
return list;
}
public Workbook statCustomerExport(String name, String tm, String stm, String etm, Integer supermarket_id, Integer customer_id, String customer_ids, Integer customer_type_id, 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, Integer sale_type) {
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(name);
List<Record> list = statCustomer(tm, stm, etm, supermarket_id, customer_id, customer_ids, customer_type_id, 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, sale_type);
int datalen = list.size();
int end_col = stat_product ? 6 : 5; // 数据共有几列
@ -1583,10 +1613,15 @@ public class OrderStatService {
return wb;
}
public List<Record> yearStatBySup(String stm, String etm, Boolean stat_product, Integer product_id) {
public List<Record> yearStatBySup(String stm, String etm, Boolean stat_product, Integer product_id, Integer sale_type) {
List<Record> list;
String paramsSql = "";
String saleParam = "";
List<Object> paramsArray = new ArrayList<>();
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
saleParam += " and t.sale_type = ? \n";
paramsArray.add(sale_type);
}
paramsArray.add(stm);
paramsArray.add(etm);
if (stat_product) {
@ -1599,6 +1634,7 @@ public class OrderStatService {
" 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" +
saleParam +
" and t.create_time >= ? \n" +
" and t.create_time <= ? \n" +
paramsSql +
@ -1610,6 +1646,7 @@ public class OrderStatService {
" 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" +
saleParam +
" and t.create_time >= ? \n" +
" and t.create_time <= ? \n" +
" group by t.supermarket_id\n" +
@ -1640,8 +1677,8 @@ public class OrderStatService {
return list;
}
public Workbook yearStatBySupExport(String stm, String etm, Boolean stat_product, Integer product_id) {
List<Record> list = yearStatBySup(stm, etm, stat_product, product_id);
public Workbook yearStatBySupExport(String stm, String etm, Boolean stat_product, Integer product_id, Integer sale_type) {
List<Record> list = yearStatBySup(stm, etm, stat_product, product_id, sale_type);
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + etm.substring(0, 10) + "年销售汇总");
@ -1675,17 +1712,23 @@ public class OrderStatService {
return wb;
}
public List<Record> yearStatByCustomer(String year, Boolean stat_product, Integer customer_id, Integer customer_type_id) {
public List<Record> yearStatByCustomer(String year, Boolean stat_product, Integer customer_id, Integer customer_type_id, Integer sale_type) {
List<Record> list;
String saleParams = "";
List<Object> paraList = new ArrayList<>();
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
saleParams += " and t.sale_type = ? \n";
paraList.add(sale_type);
}
if (StrKit.notBlank(year)) {
if (stat_product) {
List<Object> paraList = new ArrayList<>();
paraList.add(year + "%");
String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus ,a.product_id,a.product_name from (\n" +
" select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight,t.product_id,t.product_name, c.name customer_name \n" +
" from order_temp t\n" +
" left join customer c on c.id = t.customer_id\n" +
" where t.state = 5\n" +
saleParams +
" and t.create_time like ? \n";
if (customer_id != null) {
@ -1705,13 +1748,13 @@ public class OrderStatService {
" left join prepay_customer p on p.customer_id = a.id";
list = Db.find(sql, paraList.toArray());
} else {
List<Object> paraList = new ArrayList<>();
paraList.add(year + "%");
String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus from (\n" +
" select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight, c.name customer_name \n" +
" from order_temp t\n" +
" left join customer c on c.id = t.customer_id\n" +
" where t.state = 5\n" +
saleParams +
" and t.create_time like ? \n";
if (customer_id != null) {
@ -1735,12 +1778,11 @@ public class OrderStatService {
} else {
if (stat_product) {
List<Object> paraList = new ArrayList<>();
String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus,a.product_id,a.product_name from (\n" +
" select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight,t.product_id,t.product_name, c.name customer_name \n" +
" from order_temp t\n" +
" left join customer c on c.id = t.customer_id\n" +
" where t.state = 5\n";
" where t.state = 5\n" + saleParams;
if (customer_id != null) {
sql += " and c.id = ? \n";
@ -1760,12 +1802,11 @@ public class OrderStatService {
list = Db.find(sql, paraList.toArray());
} else {
List<Object> paraList = new ArrayList<>();
String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus from (\n" +
" select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight, c.name customer_name \n" +
" from order_temp t\n" +
" left join customer c on c.id = t.customer_id\n" +
" where t.state = 5\n";
" where t.state = 5\n" + saleParams;
if (customer_id != null) {
sql += " and c.id = ? \n";
@ -1818,8 +1859,8 @@ public class OrderStatService {
}
public Workbook yearStatByCustomerExport(String year, Boolean stat_product, Integer customer_id, Integer customer_type_id) {
List<Record> list = yearStatByCustomer(year, stat_product, customer_id, customer_type_id);
public Workbook yearStatByCustomerExport(String year, Boolean stat_product, Integer customer_id, Integer customer_type_id, Integer sale_type) {
List<Record> list = yearStatByCustomer(year, stat_product, customer_id, customer_type_id, sale_type);
Workbook wb = new XSSFWorkbook();
Sheet sheet;
@ -1878,10 +1919,15 @@ public class OrderStatService {
}
public List<Record> yearStatByCustomer(String stm, String etm, Boolean stat_product, Integer product_id, Integer customer_id, Integer customer_type_id) {
public List<Record> yearStatByCustomer(String stm, String etm, Boolean stat_product, Integer product_id, Integer customer_id, Integer customer_type_id, Integer sale_type) {
List<Record> list;
String paramsSql = "";
String saleParam = "";
List<Object> paramsArray = new ArrayList<>();
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
saleParam += " and t.sale_type = ? \n";
paramsArray.add(sale_type);
}
paramsArray.add(stm);
paramsArray.add(etm);
if (stat_product) {
@ -1895,6 +1941,7 @@ public class OrderStatService {
" from order_temp t\n" +
" left join customer c on c.id = t.customer_id \n" +
" where t.state = 5\n" +
saleParam +
" and t.create_time >= ? \n" +
" and t.create_time <= ? \n" +
paramsSql;
@ -1922,6 +1969,7 @@ public class OrderStatService {
" from order_temp t\n" +
" left join customer c on c.id = t.customer_id \n" +
" where t.state = 5\n" +
saleParam +
" and t.create_time >= ? \n" +
" and t.create_time <= ? \n";
@ -1976,8 +2024,8 @@ public class OrderStatService {
}
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, customer_id, customer_type_id);
public Workbook yearStatByCustomerExport(String stm, String etm, Boolean stat_product, Integer product_id, Integer customer_id, Integer customer_type_id, Integer sale_type) {
List<Record> list = yearStatByCustomer(stm, etm, stat_product, product_id, customer_id, customer_type_id, sale_type);
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + stm.substring(0, 10) + "时段销售汇总");
@ -2028,8 +2076,8 @@ public class OrderStatService {
return wb;
}
public Workbook trafficStatisticsOfEachSandStationExport(String stm, String etm, String tm, Integer invoice_type) {
Record data = trafficStatisticsOfEachSandStation(stm, etm, tm, invoice_type);
public Workbook trafficStatisticsOfEachSandStationExport(String stm, String etm, String tm, Integer invoice_type, Integer sale_type) {
Record data = trafficStatisticsOfEachSandStation(stm, etm, tm, invoice_type, sale_type);
List<Record> list = data.get("data");
List<Record> sups = data.get("supermarket");
Workbook wb = new XSSFWorkbook();
@ -2158,7 +2206,7 @@ public class OrderStatService {
/**
*
*/
public Record trafficStatisticsOfEachSandStation(String stm, String etm, String tm, Integer invoice_type) {
public Record trafficStatisticsOfEachSandStation(String stm, String etm, String tm, Integer invoice_type, Integer sale_type) {
String year = DateTimeUtil.year.get().format(new Date());
if (StrKit.notBlank(tm) && tm.length() > 4) {
@ -2174,10 +2222,16 @@ public class OrderStatService {
}
String paramsSql = "";
String saleParam = "";
if (invoice_type != null) {
paramsSql = "and t.invoice_type = ? \n";
}
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
saleParam += " and t.sale_type = ? \n";
}
String union_4 = "union select\n" +
" ifnull(t.customer_id, 0) customer_id,\n" +
" t.supermarket_id,\n" +
@ -2185,6 +2239,7 @@ public class OrderStatService {
" ifnull(sum(t.total_price), 0) total_price\n" +
" from order_temp t\n" +
" where t.state = 5\n" +
saleParam +
" 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" +
@ -2201,6 +2256,7 @@ public class OrderStatService {
" ifnull(sum(t.total_price), 0) total_price\n" +
" from order_temp t\n" +
" where t.state = 5\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" +
@ -2237,6 +2293,7 @@ public class OrderStatService {
" ifnull(sum(t.total_price), 0) total_price\n" +
" from order_temp t\n" +
" where t.state = 5\n" +
saleParam +
" and t.supermarket_id != 4\n" +
" and t.create_time>= ? \n" +
" and t.create_time<= ?\n" +
@ -2249,9 +2306,17 @@ public class OrderStatService {
List<Record> customer_sale_list;
if (invoice_type != null) {
customer_sale_list = Db.find(sql, stm, etm, invoice_type, stm, etm, invoice_type, stm, etm, invoice_type);
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
customer_sale_list = Db.find(sql, sale_type, stm, etm, invoice_type, sale_type, stm, etm, invoice_type, sale_type, stm, etm, invoice_type);
} else {
customer_sale_list = Db.find(sql, stm, etm, invoice_type, stm, etm, invoice_type, stm, etm, invoice_type);
}
} else {
customer_sale_list = Db.find(sql, stm, etm, stm, etm, stm, etm);
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
customer_sale_list = Db.find(sql, sale_type, stm, etm, sale_type, stm, etm, sale_type, stm, etm);
} else {
customer_sale_list = Db.find(sql, stm, etm, stm, etm, stm, etm);
}
}
List<String> ids = new ArrayList<>();
@ -2945,14 +3010,12 @@ public class OrderStatService {
"OR id = 11");
List<Object> shParamsList = new ArrayList<>();
shParamsList.add(OrderStateEnum.RECEIVED.getStateid());
List<Object> yhParamsList = new ArrayList<>();
yhParamsList.add(OrderStateEnum.RECEIVED.getStateid());
String shParams = "";
String yhParams = "";
if (!StrKit.isBlank(tm)) {
shParams += " and t.create_time like ? \n";
yhParams += " and t.create_time like ? \n";
yhParams += " and p.presell_date like ? \n";
shParamsList.add(tm + "%");
yhParamsList.add(tm + "%");
}
@ -2966,25 +3029,29 @@ public class OrderStatService {
" select t.supermarket_id as id, t.paid, t.total_price, t.weight, t.product_id\n" +
" from order_temp t \n" +
" where t.sale_type = 0 \n" +
" and t.state = ? \n" +
" and t.state = 5 \n" +
shParams +
" ) t\n" +
" group by t.id, t.product_id\n" +
" ) a on a.id = t.supermarket_id and a.product_id = t.product_id\n" +
" left join supermarket s on s.id = t.supermarket_id\n" +
" left join product p on p.id = t.product_id", shParamsList.toArray());
" left join product p on p.id = t.product_id order BY s.id, p.id ASC", shParamsList.toArray());
// 预售
List<Record> yhList = Db.find(
"SELECT\n" +
" t.supermarket_id id,\n" +
" SUM(t.total_price) total_price\n" +
" count(*) as order_num,\n" +
" sum(t.weight) as weight,\n" +
" sum(t.total_price) total_price\n" +
"FROM\n" +
" `order_temp` t\n" +
" order_temp t\n" +
"LEFT JOIN ordercluster c ON c.id = t.ordercluster_id\n" +
"LEFT JOIN presell_order p ON p.id = c.presell_order_id\n" +
"WHERE\n" +
" t.sale_type = 1\n" +
" and t.state = ?\n" +
" t.sale_type = 1\n" +
" AND t.state = 5\n" +
yhParams +
" GROUP BY\n" +
"GROUP BY\n" +
" t.supermarket_id", yhParamsList.toArray());
List<Record> retChildren = new ArrayList<>();
@ -3004,6 +3071,8 @@ public class OrderStatService {
double hj_jzs_sh_weight = 0.0;
double hj_jzs_sh_total_price = 0.0;
int hj_yh_order_num = 0;
double hj_yh_weight = 0.0;
double hj_yh_total_price = 0.0;
// 实售合并
@ -3023,12 +3092,14 @@ public class OrderStatService {
for (Record s2 : shList2) {
int s1_id = s1.getInt("id");
int s2_id = s2.getInt("id");
BigDecimal weight = s1.getBigDecimal("weight").add(s2.getBigDecimal("weight"));
if (weight.compareTo(new BigDecimal(0)) == 0) {
weight = new BigDecimal(0);
}
if ((s1_id == 1 && s2_id == 7) || (s1_id == 5 && s2_id == 9) ||s1_id == 6 && s2_id == 8) {
Record s3 = new Record();
BigDecimal weight = s1.getBigDecimal("weight").add(s2.getBigDecimal("weight"));
if (weight.compareTo(new BigDecimal(0)) == 0) {
weight = new BigDecimal(0);
}
s3.set("id", s1_id);
s3.set("name", s1.getStr("name"));
s3.set("product_id", s1.getInt("product_id"));
@ -3058,17 +3129,30 @@ public class OrderStatService {
}
if (yhList2.size() > 1) {
for (Record s1 : yhList2) {
boolean flag = false;
for (Record s2 : yhList2) {
int s1_id = s1.getInt("id");
int s2_id = s2.getInt("id");
if ((s1_id == 1 && s2_id == 7) || (s1_id == 5 && s2_id == 9) ||s1_id == 6 && s2_id == 8) {
flag = true;
Record s3 = new Record();
BigDecimal weight = s1.getBigDecimal("weight").add(s2.getBigDecimal("weight"));
if (weight.compareTo(new BigDecimal(0)) == 0) {
weight = new BigDecimal(0);
}
s3.set("id", s1_id);
s3.set("order_num", Math.addExact(s1.getInt("order_num"), s2.getInt("order_num")));
s3.set("total_price", s1.getBigDecimal("total_price").add(s2.getBigDecimal("total_price")));
s3.set("weight", weight);
yhList1.add(s3);
break;
}
}
if (!flag) {
yhList1.add(s1);
}
}
} else if(yhList2.size() == 1) {
yhList1.addAll(yhList2);
@ -3165,7 +3249,11 @@ public class OrderStatService {
flag = false;
Record r = new Record();
int order_num = yl.getInt("order_num");
BigDecimal weight = yl.getBigDecimal("weight");
BigDecimal total_price = yl.getBigDecimal("total_price");
hj_yh_order_num += order_num;
hj_yh_weight += weight.doubleValue();
hj_yh_total_price += total_price.doubleValue();
r.set("key", yl_id + "_yh_1");
@ -3173,8 +3261,8 @@ public class OrderStatService {
r.set("name", name);
r.set("item_name", "预售");
r.set("product_name", "-");
r.set("order_num", "-");
r.set("weight", "-");
r.set("order_num", order_num);
r.set("weight", weight);
r.set("total_price", total_price);
retList.add(r);
yhChildren.add(new Record().setColumns(r).remove("name").remove("item_name"));
@ -3260,8 +3348,8 @@ public class OrderStatService {
hj_yh_1.set("name", "合计");
hj_yh_1.set("item_name", "预售");
hj_yh_1.set("product_name", "-");
hj_yh_1.set("order_num", "-");
hj_yh_1.set("weight", "-");
hj_yh_1.set("order_num", hj_yh_order_num);
hj_yh_1.set("weight", hj_yh_weight);
hj_yh_1.set("total_price", hj_yh_total_price);
retList.add(hj_yh_1);
hj_yh_children.add(hj_yh_1);
@ -3286,8 +3374,8 @@ public class OrderStatService {
// 总合计
Record total = new Record();
total.set("key", "total").set("name", "总合计").set("item_name", "-").set("product_name", "-")
.set("order_num", hj_hs_sh_order_num + hj_els_sh_order_num + hj_jzs_sh_order_num)
.set("weight", hj_hs_sh_weight + hj_els_sh_weight + hj_els_sh_weight)
.set("order_num", hj_hs_sh_order_num + hj_els_sh_order_num + hj_jzs_sh_order_num + hj_yh_order_num)
.set("weight", hj_hs_sh_weight + hj_els_sh_weight + hj_els_sh_weight + hj_yh_weight)
.set("total_price", hj_hs_sh_total_price + hj_els_sh_total_price + hj_jzs_sh_total_price + hj_yh_total_price);
retList.add(total);

View File

@ -89,12 +89,13 @@ public class OrderStatController extends BaseController {
*/
@Before(DayValidator.class)
public void daystat() {
String tm = get("tm");
int export = getInt("export", 0);
String tm = get("tm");
int export = getInt("export", 0);
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.salestat(tm)));
renderJson(Result.object(OrderStatService.me.salestat(tm, sale_type)));
} else {
Workbook wb = OrderStatService.me.daysalestatExport(tm);
Workbook wb = OrderStatService.me.daysalestatExport(tm, sale_type);
render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -104,13 +105,13 @@ public class OrderStatController extends BaseController {
*/
@Before(MonthValidator.class)
public void monthstat() {
String tm = get("tm");
int export = getInt("export", 0);
String tm = get("tm");
int export = getInt("export", 0);
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.salestat(tm)));
renderJson(Result.object(OrderStatService.me.salestat(tm, sale_type)));
} else {
Workbook wb = OrderStatService.me.monthsalestatExport(tm);
Workbook wb = OrderStatService.me.monthsalestatExport(tm, sale_type);
render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -126,10 +127,11 @@ public class OrderStatController extends BaseController {
Integer customer_type_id = getInt("customer_type_id");
int export = getInt("export", 0);
Boolean stat_product = getBoolean("stat_product", false);
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id)));
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id, sale_type)));
} else {
Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm, invoice_type, stat_product, customer_id, customer_type_id);
Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm, invoice_type, stat_product, customer_id, customer_type_id, sale_type);
render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -145,10 +147,11 @@ public class OrderStatController extends BaseController {
Integer customer_type_id = getInt("customer_type_id");
int export = getInt("export", 0);
Boolean stat_product = getBoolean("stat_product", false);
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id)));
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id, sale_type)));
} else {
Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm, invoice_type, stat_product, customer_id, customer_type_id);
Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm, invoice_type, stat_product, customer_id, customer_type_id, sale_type);
render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -164,11 +167,11 @@ public class OrderStatController extends BaseController {
int export = getInt("export", 0);
Boolean stat_product = getBoolean("stat_product", false);
Integer product_id = getInt("product_id");
Integer sale_type = getInt("sale_type");
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, sale_type)));
} 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, sale_type);
render(new ExcelRender(stm.substring(0, 10) + "至" + etm.substring(0, 10) + "_销售月逐日统计_" + System.currentTimeMillis() + ".xlsx", wb));
}
@ -247,11 +250,11 @@ public class OrderStatController extends BaseController {
Integer product_id = getInt("product_id");
boolean stat_product = getBoolean("stat_product", false);
Integer isprepaid = getInt("isprepaid");
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, 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, sale_type)));
} else {
Workbook wb = OrderStatService.me.statCustomerExport("砂站日销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, 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, sale_type);
render(new ExcelRender(tm + "_砂站日" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -270,11 +273,11 @@ public class OrderStatController extends BaseController {
Integer product_id = getInt("product_id");
boolean stat_product = getBoolean("stat_product", false);
Integer isprepaid = getInt("isprepaid");
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, 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, sale_type)));
} else {
Workbook wb = OrderStatService.me.statCustomerExport("砂站月销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, 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, sale_type);
render(new ExcelRender(tm + "_砂站月" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -291,11 +294,11 @@ public class OrderStatController extends BaseController {
Integer product_id = getInt("product_id");
boolean stat_product = getBoolean("stat_product", false);
Integer isprepaid = getInt("isprepaid");
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.statCustomer(null, stm, etm, supermarket_id, customer_id, customer_ids, customer_type_id, 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, sale_type)));
} else {
Workbook wb = OrderStatService.me.statCustomerExport("砂站时段销售汇总表", null, stm, etm, supermarket_id, customer_id, customer_ids, customer_type_id, 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,sale_type);
render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -306,10 +309,11 @@ public class OrderStatController extends BaseController {
Integer customer_type_id = getInt("customer_type_id");
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Boolean stat_product = getBoolean("stat_product", false);
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm, stat_product, customer_id, customer_type_id)));
renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm, stat_product, customer_id, customer_type_id, sale_type)));
} else {
Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm, stat_product, customer_id, customer_type_id);
Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm, stat_product, customer_id, customer_type_id, sale_type);
render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -318,11 +322,11 @@ public class OrderStatController extends BaseController {
String tm = get("tm");
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Boolean stat_product = getBoolean("stat_product", false);
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.salestat(tm)));
renderJson(Result.object(OrderStatService.me.salestat(tm, sale_type)));
} else {
Workbook wb = OrderStatService.me.yearsalestatExport(tm);
Workbook wb = OrderStatService.me.yearsalestatExport(tm, sale_type);
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -336,11 +340,11 @@ public class OrderStatController extends BaseController {
Integer product_id = getInt("product_id");
Integer customer_id = getInt("customer_id");
Integer customer_type_id = getInt("customer_type_id");
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm, stat_product, product_id, customer_id, customer_type_id)));
renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm, stat_product, product_id, customer_id, customer_type_id, sale_type)));
} else {
Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm, stat_product, product_id, customer_id, customer_type_id);
Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm, stat_product, product_id, customer_id, customer_type_id, sale_type);
render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -352,11 +356,11 @@ public class OrderStatController extends BaseController {
Boolean stat_product = getBoolean("stat_product", false);
Integer product_id = getInt("product_id");
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer sale_type = getInt("sale_type");
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, sale_type)));
} else {
Workbook wb = OrderStatService.me.yearStatBySupExport(stm, etm, stat_product, product_id);
Workbook wb = OrderStatService.me.yearStatBySupExport(stm, etm, stat_product, product_id, sale_type);
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}

View File

@ -117,12 +117,13 @@ public class OrderStatController extends BaseController {
*/
@Before(DayValidator.class)
public void daystat() {
String tm = get("tm");
int export = getInt("export", 0);
String tm = get("tm");
int export = getInt("export", 0);
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.salestat(tm)));
renderJson(Result.object(OrderStatService.me.salestat(tm, sale_type)));
} else {
Workbook wb = OrderStatService.me.daysalestatExport(tm);
Workbook wb = OrderStatService.me.daysalestatExport(tm, sale_type);
render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -132,13 +133,13 @@ public class OrderStatController extends BaseController {
*/
@Before(MonthValidator.class)
public void monthstat() {
String tm = get("tm");
int export = getInt("export", 0);
String tm = get("tm");
int export = getInt("export", 0);
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.salestat(tm)));
renderJson(Result.object(OrderStatService.me.salestat(tm, sale_type)));
} else {
Workbook wb = OrderStatService.me.monthsalestatExport(tm);
Workbook wb = OrderStatService.me.monthsalestatExport(tm, sale_type);
render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -154,11 +155,12 @@ public class OrderStatController extends BaseController {
Integer customer_type_id = getInt("customer_type_id");
int export = getInt("export", 0);
Boolean stat_product = getBoolean("stat_product", false);
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id)));
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id, sale_type)));
} else {
Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm, invoice_type, stat_product, customer_id, customer_type_id);
Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm, invoice_type, stat_product, customer_id, customer_type_id, sale_type);
render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -174,11 +176,12 @@ public class OrderStatController extends BaseController {
Integer customer_type_id = getInt("customer_type_id");
int export = getInt("export", 0);
Boolean stat_product = getBoolean("stat_product", false);
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id)));
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product, customer_id, customer_type_id, sale_type)));
} else {
Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm, invoice_type, stat_product, customer_id, customer_type_id);
Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm, invoice_type, stat_product, customer_id, customer_type_id, sale_type);
render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -194,11 +197,12 @@ public class OrderStatController extends BaseController {
Boolean stat_product = getBoolean("stat_product", false);
Integer product_id = getInt("product_id");
int export = getInt("export", 0);
Integer sale_type = getInt("sale_type");
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, sale_type)));
} 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, sale_type);
render(new ExcelRender(stm.substring(0, 10) + "至" + etm.substring(0, 10) + "_销售月逐日统计_" + System.currentTimeMillis() + ".xlsx", wb));
}
@ -290,11 +294,12 @@ public class OrderStatController extends BaseController {
Integer product_id = getInt("product_id");
boolean stat_product = getBoolean("stat_product", false);
Integer isprepaid = getInt("isprepaid");
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, 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, sale_type)));
} else {
Workbook wb = OrderStatService.me.statCustomerExport("砂站日销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, 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, sale_type);
render(new ExcelRender(tm + "_砂站日" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -325,11 +330,12 @@ public class OrderStatController extends BaseController {
Integer product_id = getInt("product_id");
boolean stat_product = getBoolean("stat_product", false);
Integer isprepaid = getInt("isprepaid");
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, 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, sale_type)));
} else {
Workbook wb = OrderStatService.me.statCustomerExport("砂站月销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, customer_type_id, 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, sale_type);
render(new ExcelRender(tm + "_砂站月" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -358,11 +364,12 @@ public class OrderStatController extends BaseController {
Integer product_id = getInt("product_id");
boolean stat_product = getBoolean("stat_product", false);
Integer isprepaid = getInt("isprepaid");
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.statCustomer(null, stm, etm, supermarket_id, customer_id, customer_ids, customer_type_id, 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, sale_type)));
} else {
Workbook wb = OrderStatService.me.statCustomerExport("砂站时段销售汇总表", null, stm, etm, supermarket_id, customer_id, customer_ids, customer_type_id, 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, sale_type);
render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -373,11 +380,12 @@ public class OrderStatController extends BaseController {
Integer customer_type_id = getInt("customer_type_id");
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Boolean stat_product = getBoolean("stat_product", false);
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm, stat_product, customer_id, customer_type_id)));
renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm, stat_product, customer_id, customer_type_id, sale_type)));
} else {
Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm, stat_product, customer_id, customer_type_id);
Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm, stat_product, customer_id, customer_type_id, sale_type);
render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -406,11 +414,12 @@ public class OrderStatController extends BaseController {
Integer customer_id = getInt("customer_id");
Integer customer_type_id = getInt("customer_type_id");
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm, stat_product, product_id, customer_id, customer_type_id)));
renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm, stat_product, product_id, customer_id, customer_type_id, sale_type)));
} else {
Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm, stat_product, product_id, customer_id, customer_type_id);
Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm, stat_product, product_id, customer_id, customer_type_id, sale_type);
render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -422,10 +431,11 @@ public class OrderStatController extends BaseController {
Boolean stat_product = getBoolean("stat_product", false);
Integer product_id = getInt("product_id");
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer sale_type = getInt("sale_type");
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, sale_type)));
} else {
Workbook wb = OrderStatService.me.yearStatBySupExport(stm, etm, stat_product, product_id);
Workbook wb = OrderStatService.me.yearStatBySupExport(stm, etm, stat_product, product_id, sale_type);
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@ -439,10 +449,11 @@ public class OrderStatController extends BaseController {
String tm = get("tm", DateTimeUtil.year_start.get().format(new Date())); // 客户账户统计起始时间
Integer invoice_type = getInt("invoice_type");
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer sale_type = getInt("sale_type");
if (export == 0) {
renderJson(Result.object(OrderStatService.me.trafficStatisticsOfEachSandStation(stm, etm, tm, invoice_type)));
renderJson(Result.object(OrderStatService.me.trafficStatisticsOfEachSandStation(stm, etm, tm, invoice_type, sale_type)));
} else {
Workbook wb = OrderStatService.me.trafficStatisticsOfEachSandStationExport(stm, etm, tm, invoice_type);
Workbook wb = OrderStatService.me.trafficStatisticsOfEachSandStationExport(stm, etm, tm, invoice_type, sale_type);
render(new ExcelRender("各砂站运输量统计表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}