From d90a4dd80fbb250cc49f00ace17a483d4bccabc8 Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Fri, 20 Nov 2020 20:34:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=A5=A8=E6=8D=AE=E6=98=8E?= =?UTF-8?q?=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stat/invoice/InvoiceUseService.java | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java index a66e030..ce7d966 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java @@ -42,7 +42,7 @@ public class InvoiceUseService { Integer order_state ) { 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.settlement_time create_time, t.invalid_time, t.invalid_memo, t.invoice_type, t.invalid_user_name\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" + " , r.receive_user_name, r.create_time receive_time, r.supermarket_id\n" + " , o.sn order_sn, o.weight, o.total_price, o.unit_price, o.truck_license, o.customer_id, o.customer_texpayer_name, o.customer_texpayer_num, o.isprepaid, o.state order_state\n" + " , s.name supermarket_name " + @@ -50,7 +50,7 @@ public class InvoiceUseService { " left join invoice_receive r on t.invoice_receive_id = r.id\n" + " left join order_temp o on o.sn = t.order_sn \n" + " left join supermarket s on s.id = r.supermarket_id \n" + - " where 1 = 1 \n"; + " where t.state = 9 \n"; String ordsql = "select\n" + " t.uuid rowkey, t.invoice_number, t.invoice_code, null invoice_state, t.settlement_user_name, null settlement_time, t.create_time, null invalid_time, null invalid_memo, t.invoice_type, null invalid_user_name\n" + @@ -58,15 +58,14 @@ public class InvoiceUseService { " , t.sn order_sn, t.weight, t.total_price, t.unit_price, t.truck_license, t.customer_id, t.customer_texpayer_name, t.customer_texpayer_num, t.isprepaid, t.state order_state \n" + " , s.name supermarket_name " + " from order_temp t \n" + - " left join invoice_log l on l.order_sn = t.sn \n" + + " left join invoice_log l on l.invoice_number = t.invoice_number and l.code = t.invoice_code and l.order_sn = t.sn \n" + " left join supermarket s on s.id = t.supermarket_id \n" + - " where t.invoice_type = 2 \n" + - " and l.id is null\n"; + " where 1=1 \n"; List paramlog = new ArrayList<>(); List paramord = new ArrayList<>(); - logsql += " and t.settlement_time >= ? and t.settlement_time < date_add(?, interval 1 day)\n"; + logsql += " and t.create_time >= ? and t.create_time < date_add(?, interval 1 day)\n"; ordsql += " and t.create_time >= ? and t.create_time < date_add(?, interval 1 day)\n"; paramlog.add(tm); @@ -115,8 +114,10 @@ public class InvoiceUseService { } if (invoice_state != null) { - logsql += " and t.state = ? \n"; - paramlog.add(invoice_state); + if (invoice_state == 9) { + logsql += " and t.state = ? \n"; + paramlog.add(invoice_state); + } } if (order_state != null) { @@ -127,26 +128,26 @@ public class InvoiceUseService { paramord.add(order_state); } + if (invoice_type != null) { + logsql += " and t.invoice_type = ? \n"; + ordsql += " and t.invoice_type = ? \n"; + + paramlog.add(invoice_type); + paramord.add(invoice_type); + } + List list = new ArrayList<>(); if (invoice_state != null) { - list = Db.find(logsql + " order by t.create_time", paramlog.toArray()); - } else { - if (invoice_type != null && invoice_type == 1) { + if(invoice_state == 9){ list = Db.find(logsql + " order by t.create_time", paramlog.toArray()); - } else { - if (invoice_type != null && invoice_type == 2) { - logsql += " and t.invoice_type = ? \n"; - ordsql += " and t.invoice_type = ? \n"; - - paramlog.add(invoice_type); - paramord.add(invoice_type); - } - - paramlog.addAll(paramord); - - list = Db.find("select * from (" + logsql + "\n union \n " + ordsql + ") a order by a.create_time ", paramlog.toArray()); + }else if(invoice_state == 5){ + list = Db.find(ordsql + " order by t.create_time", paramord.toArray()); } + } else { + paramlog.addAll(paramord); + + list = Db.find("select * from (" + logsql + "\n union \n " + ordsql + ") a order by a.create_time ", paramlog.toArray()); } Record out = new Record();