dev
parent
644dd15ed0
commit
06ea0792b3
|
|
@ -69,7 +69,7 @@ public class OrderTempService extends BaseService {
|
|||
" left join ( \n" +
|
||||
" select t.order_sn, min(t.state) state from invoice_invalid_verify t\n" +
|
||||
" where t.order_sn = ? \n" +
|
||||
" and ( t.state = 1 or t.state = 2 ) \n" +
|
||||
" and t.state = 1 \n" + // 一个订单的发票可以作废多次,但是每个订单只能有一个是正在作废中的
|
||||
" group by t.order_sn" +
|
||||
" ) v on v.order_sn = t.sn \n" +
|
||||
" left join ( \n" +
|
||||
|
|
@ -80,22 +80,6 @@ public class OrderTempService extends BaseService {
|
|||
" ) ov on ov.order_sn = t.sn\n" +
|
||||
" where t.sn = ?", sn, sn, sn);
|
||||
|
||||
// if (record != null) {
|
||||
// InvoiceInvalidVerify verify1 = InvoiceInvalidVerify.dao.findFirst(
|
||||
// "select * from invoice_invalid_verify t where t.order_sn = ? and ( t.state = 1 or t.state = 2 ) limit 1", sn);
|
||||
//
|
||||
// if (verify1 != null) {
|
||||
// record.set("invoice_invalid_verify_state", 1);
|
||||
// }
|
||||
//
|
||||
// OrderInvalidVerify verify2 = OrderInvalidVerify.dao.findFirst(
|
||||
// "select * from invoice_invalid_verify t where t.order_sn = ? and ( t.state = 1 or t.state = 2 ) limit 1", sn);
|
||||
//
|
||||
// if (verify2 != null) {
|
||||
// record.set("order_invalid_verify_state", 1);
|
||||
// }
|
||||
// }
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
|
|
@ -119,19 +103,12 @@ public class OrderTempService extends BaseService {
|
|||
", p.in_time, p.out_time, p.in_which, p.out_which, p.in_mode, p.out_mode \n" +
|
||||
", p.first_weight, p.second_weight, p.first_weigh_mode, p.second_weight_mode \n" +
|
||||
", p.first_pic, p.first_weight_which, p.second_weight_which, p.second_pic \n" +
|
||||
", p.arrive_time, p.type, p.memo transport_memo, s.name supermarket_name \n" +
|
||||
", case when v.state is not null then 1 end invoice_invalid_verify_state " + // 只需要标记是 1,不需要反映 state = 2
|
||||
", case when ov.state is not null then 1 end order_invalid_verify_state \n"; // 只需要标记是 1,不需要反映 state = 2
|
||||
", p.arrive_time, p.type, p.memo transport_memo, s.name supermarket_name \n";
|
||||
String fromsql = "from order_temp t \n" +
|
||||
" left join transport p on p.order_sn = t.sn \n" +
|
||||
" left join supermarket s on s.id = t.supermarket_id \n" +
|
||||
" left join ( select t.order_sn, min(t.state) state from invoice_invalid_verify t\n" +
|
||||
" where ( t.state = 1 or t.state = 2 )\n" +
|
||||
" group by t.order_sn ) v on v.order_sn = t.sn and ( v.state = 1 or v.state = 2 ) \n" +
|
||||
" left join ( select t.order_sn, min(t.state) state from order_invalid_verify t\n" +
|
||||
" where ( t.state = 1 or t.state = 2 )\n" +
|
||||
" group by t.order_sn ) ov on ov.order_sn = t.sn and ( ov.state = 1 or ov.state = 2 ) \n" +
|
||||
" where 1=1 ";
|
||||
|
||||
List<Object> paraList = new ArrayList<>();
|
||||
|
||||
if (StrKit.notBlank(sn)) {
|
||||
|
|
@ -214,7 +191,46 @@ public class OrderTempService extends BaseService {
|
|||
findSql += " order by t.create_time desc";
|
||||
}
|
||||
|
||||
return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
|
||||
Page<Record> page = Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
|
||||
List<Record> list = page.getList();
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
List<String> sqlparams = new ArrayList<>();
|
||||
List<String> params = new ArrayList<>();
|
||||
|
||||
for (Record record : list) {
|
||||
sqlparams.add("?");
|
||||
params.add(record.getStr("sn"));
|
||||
}
|
||||
|
||||
if (!sqlparams.isEmpty()) {
|
||||
// 一个订单的发票可以作废多次,但是每个订单只能有一个是正在作废中的
|
||||
List<InvoiceInvalidVerify> verifies1 = InvoiceInvalidVerify.dao.find(
|
||||
"select * from invoice_invalid_verify t where t.order_sn in(" +StrKit.join(sqlparams, ",") + ") and t.state = 1 ", params.toArray());
|
||||
|
||||
List<OrderInvalidVerify> verifies2 = OrderInvalidVerify.dao.find(
|
||||
"select * from order_invalid_verify t where t.order_sn in(" +StrKit.join(sqlparams, ",") + ") and ( t.state = 1 or t.state = 2 )", params.toArray());
|
||||
|
||||
|
||||
for (Record record : list) {
|
||||
String rdsn = record.getStr("sn");
|
||||
|
||||
for(InvoiceInvalidVerify v : verifies1){
|
||||
if(rdsn.equals(v.getOrderSn())){
|
||||
record.set("invoice_invalid_verify_state", 1);
|
||||
}
|
||||
}
|
||||
|
||||
for(OrderInvalidVerify v : verifies2){
|
||||
if(rdsn.equals(v.getOrderSn())){
|
||||
record.set("order_invalid_verify_state", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class InvoiceInvalidVerifySyncService {
|
|||
}
|
||||
|
||||
InvoiceInvalidVerify old = InvoiceInvalidVerify.dao.findFirst(
|
||||
"select * from invoice_invalid_verify t where t.order_sn = ? and ( t.state = 1 or t.state = 2 ) limit 1", order_sn);
|
||||
"select * from invoice_invalid_verify t where t.order_sn = ? and t.state = 1 limit 1", order_sn);
|
||||
|
||||
if (old != null) {
|
||||
return Result.failedstr("订单 %s 已提交申请", order_sn);
|
||||
|
|
@ -90,7 +90,7 @@ public class InvoiceInvalidVerifySyncService {
|
|||
"select * from invoice_invalid_verify t \n" +
|
||||
" wheret.invoice_number = ? \n" +
|
||||
" and t.invoice_code = ? \n" +
|
||||
" and ( t.state = 1 or t.state = 2 )" +
|
||||
" and t.state = 1 " +
|
||||
" limit 1", model.getInvoiceNumber(), model.getInvoiceCode());
|
||||
|
||||
if (old != null) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue