service部分优化:删掉order_sale 相关的代码,简化统计查询相关的代码

dev
wuwenxiong 2021-08-31 15:58:32 +08:00
parent 6bbe80db09
commit 579819554d
17 changed files with 56 additions and 2684 deletions

View File

@ -1,14 +0,0 @@
package com.cowr.model;
import com.cowr.model.base.BaseOrderSale;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: order_sale
* Remarks: -
* PrimaryKey: sn
*/
@SuppressWarnings("serial")
public class OrderSale extends BaseOrderSale<OrderSale> {
public static final OrderSale dao = new OrderSale().dao();
}

View File

@ -79,7 +79,6 @@ public class _MappingKit {
arp.addMapping("ordercluster_truck", "id", OrderclusterTruck.class); arp.addMapping("ordercluster_truck", "id", OrderclusterTruck.class);
arp.addMapping("ordercluster", "id", Ordercluster.class); arp.addMapping("ordercluster", "id", Ordercluster.class);
arp.addMapping("order_transfer", "sn", OrderTransfer.class); arp.addMapping("order_transfer", "sn", OrderTransfer.class);
arp.addMapping("order_sale", "sn", OrderSale.class);
// Composite Primary Key order: supermarket_id,product_id // Composite Primary Key order: supermarket_id,product_id
arp.addMapping("stock", "supermarket_id,product_id", Stock.class); arp.addMapping("stock", "supermarket_id,product_id", Stock.class);
} }

View File

@ -45,15 +45,14 @@ public class InvoiceLogService extends BaseService {
public Page<Record> find(PageParam pp, String invoice_number, Integer supermarket_id, Integer state, String order_sn, String stm, String etm, String code, Integer invoice_type) { public Page<Record> find(PageParam pp, String invoice_number, Integer supermarket_id, Integer state, String order_sn, String stm, String etm, String code, Integer invoice_type) {
String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" + String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" +
" case when t.type = 1 then o.weight when t.type = 3 then p.weight end weight, \n" + " case when t.type = 3 then p.weight end weight, \n" +
" case when t.type = 1 then o.total_price when t.type = 3 then p.total_price end total_price, \n" + " case when t.type = 3 then p.total_price end total_price, \n" +
" case when t.type = 1 then o.create_time when t.type = 3 then p.create_time end create_time, \n" + " case when t.type = 3 then p.create_time end create_time, \n" +
" case when t.type = 1 then o.settlement_user_name when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" + " case when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" +
" case when t.type = 1 then o.customer_name when t.type = 3 then p.customer_name end customer_name "; " case when t.type = 3 then p.customer_name end customer_name \n";
String fromsql = "from invoice_log t \n" + String fromsql = "from invoice_log t \n" +
" left join invoice_receive r on r.id = t.invoice_receive_id \n" + " left join invoice_receive r on r.id = t.invoice_receive_id \n" +
" left join supermarket s on s.id = r.supermarket_id \n" + " left join supermarket s on s.id = r.supermarket_id \n" +
" left join order_sale o on o.sn = t.order_sn \n" +
" left join order_temp p on p.sn = t.order_sn \n" + " left join order_temp p on p.sn = t.order_sn \n" +
" where 1=1 \n"; " where 1=1 \n";
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
@ -120,18 +119,17 @@ public class InvoiceLogService extends BaseService {
public Workbook export(String invoice_number, Integer supermarket_id, Integer state, String order_sn, String stm, String etm, String code, Integer invoice_type) { public Workbook export(String invoice_number, Integer supermarket_id, Integer state, String order_sn, String stm, String etm, String code, Integer invoice_type) {
String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" + String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" +
" tr.first_weight, tr.second_weight, \n" + " tr.first_weight, tr.second_weight, \n" +
" case when t.type = 1 then o.weight when t.type = 3 then p.weight end weight, \n" + " case when t.type = 3 then p.weight end weight, \n" +
" case when t.type = 1 then o.total_price when t.type = 3 then p.total_price end total_price, \n" + " case when t.type = 3 then p.total_price end total_price, \n" +
" case when t.type = 1 then o.create_time when t.type = 3 then p.create_time end order_create_time, \n" + " case when t.type = 3 then p.create_time end order_create_time, \n" +
" case when t.type = 1 then o.settlement_user_name when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" + " case when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" +
" case when t.type = 1 then o.truck_license when t.type = 3 then p.truck_license end truck_license, \n" + " case when t.type = 3 then p.truck_license end truck_license, \n" +
" case when t.type = 1 then o.customer_texpayer_name when t.type = 3 then p.customer_texpayer_name end customer_texpayer_name, \n" + " case when t.type = 3 then p.customer_texpayer_name end customer_texpayer_name, \n" +
" case when t.type = 1 then o.customer_texpayer_num when t.type = 3 then p.customer_texpayer_num end customer_texpayer_num, \n" + " case when t.type = 3 then p.customer_texpayer_num end customer_texpayer_num, \n" +
" case when t.type = 1 then o.customer_name when t.type = 3 then p.customer_name end customer_name "; " case when t.type = 3 then p.customer_name end customer_name \n";
String fromsql = "from invoice_log t \n" + String fromsql = "from invoice_log t \n" +
" left join invoice_receive r on r.id = t.invoice_receive_id \n" + " left join invoice_receive r on r.id = t.invoice_receive_id \n" +
" left join supermarket s on s.id = r.supermarket_id \n" + " left join supermarket s on s.id = r.supermarket_id \n" +
" left join order_sale o on o.sn = t.order_sn \n" +
" left join order_temp p on p.sn = t.order_sn \n" + " left join order_temp p on p.sn = t.order_sn \n" +
" left join transport tr on tr.order_sn = t.order_sn \n" + " left join transport tr on tr.order_sn = t.order_sn \n" +
" where 1=1 \n"; " where 1=1 \n";

View File

@ -437,17 +437,12 @@ public class OrderclusterService extends BaseService {
map.put(record.getInt("id"), record); map.put(record.getInt("id"), record);
} }
String sql = "select t.ordercluster_id, sum(t.weight) weight from order_sale t \n" + String sql = " select t.ordercluster_id, sum(t.weight) weight from order_temp t \n" +
" where t.state = ? \n" +
" and t.ordercluster_id in(" + ids.toString() + ") \n" +
" group by t.ordercluster_id \n" +
" union \n" +
" select t.ordercluster_id, sum(t.weight) weight from order_temp t \n" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.ordercluster_id in(" + ids.toString() + ") \n" + " and t.ordercluster_id in(" + ids.toString() + ") \n" +
" group by t.ordercluster_id "; " group by t.ordercluster_id ";
List<Record> orderlist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), OrderStateEnum.RECEIVED.getStateid()); List<Record> orderlist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid());
for (Record cli : orderlist) { for (Record cli : orderlist) {
int ordercluster_id = cli.getInt("ordercluster_id"); int ordercluster_id = cli.getInt("ordercluster_id");
@ -491,21 +486,6 @@ public class OrderclusterService extends BaseService {
String invoice_code, String invoice_code,
Integer product_id Integer product_id
) { ) {
String salesql = "select \n" +
" t.sn, t.uuid, t.transport_id, t.supermarket_id\n" +
" , t.customer_id, t.customer_name, t.customer_texpayer_name, t.customer_texpayer_num, t.customer_address\n" +
" , t.customer_phone, t.customer_bank_name, t.customer_bank_account\n" +
" , t.customer_receiver_name, t.customer_receiver_phone, t.customer_receiver_address, t.customer_receiver_lgtd, t.customer_receiver_lttd\n" +
" , t.trans_co_id, t.trans_co_name, t.trans_co_texpayer_name, t.trans_co_texpayer_num, t.trans_co_address, t.trans_co_phone, t.trans_co_bank_name, t.trans_co_bank_account\n" +
" , t.truck_license, t.driver_name, t.driver_phone\n" +
" , t.unit_price, t.total_price, t.weight, t.paid, t.pick_time, t.trans_distance\n" +
" , t.trans_price, t.trans_unit_price\n" +
" , t.pay_type, t.create_time, t.create_user_id, t.create_user_name\n" +
" , t.settlement_user_id, t.settlement_user_name, t.state, t.req_receipt, t.ordercluster_id\n" +
" , t.change_time, t.isprepaid, t.memo, t.product_id, t.product_name, t.prepay_customer_id, 1 type\n" +
" from order_sale t\n" +
" where t.ordercluster_id = ? \n";
String tempsql = "select \n" + String tempsql = "select \n" +
" t.sn, t.uuid, t.transport_id, t.supermarket_id\n" + " t.sn, t.uuid, t.transport_id, t.supermarket_id\n" +
" , t.customer_id, t.customer_name, t.customer_texpayer_name, t.customer_texpayer_num, t.customer_address\n" + " , t.customer_id, t.customer_name, t.customer_texpayer_name, t.customer_texpayer_num, t.customer_address\n" +
@ -521,82 +501,52 @@ public class OrderclusterService extends BaseService {
" from order_temp t\n" + " from order_temp t\n" +
" where t.ordercluster_id = ? \n"; " where t.ordercluster_id = ? \n";
List<Object> salePara = new ArrayList<>();
List<Object> tempPara = new ArrayList<>(); List<Object> tempPara = new ArrayList<>();
salePara.add(ordercluster_id);
tempPara.add(ordercluster_id); tempPara.add(ordercluster_id);
if (StrKit.notBlank(sn)) { if (StrKit.notBlank(sn)) {
salesql += " and t.sn like ? \n";
tempsql += " and t.sn like ? \n"; tempsql += " and t.sn like ? \n";
salePara.add("%" + sn.trim() + "%");
tempPara.add("%" + sn.trim() + "%"); tempPara.add("%" + sn.trim() + "%");
} }
if (StrKit.notBlank(truck_license)) { if (StrKit.notBlank(truck_license)) {
salesql += " and t.truck_license like ? \n";
tempsql += " and t.truck_license like ? \n"; tempsql += " and t.truck_license like ? \n";
salePara.add("%" + truck_license.trim() + "%");
tempPara.add("%" + truck_license.trim() + "%"); tempPara.add("%" + truck_license.trim() + "%");
} }
if (StrKit.notBlank(invoice_code)) { if (StrKit.notBlank(invoice_code)) {
salesql += " and t.invoice_code like ? \n";
tempsql += " and t.invoice_code like ? \n"; tempsql += " and t.invoice_code like ? \n";
salePara.add("%" + invoice_code.trim() + "%");
tempPara.add("%" + invoice_code.trim() + "%"); tempPara.add("%" + invoice_code.trim() + "%");
} }
if (StrKit.notBlank(stm)) { if (StrKit.notBlank(stm)) {
salesql += " and t.create_time >= ? \n";
tempsql += " and t.create_time >= ? \n"; tempsql += " and t.create_time >= ? \n";
salePara.add(stm);
tempPara.add(stm); tempPara.add(stm);
} }
if (StrKit.notBlank(etm)) { if (StrKit.notBlank(etm)) {
salesql += " and t.create_time <= ? \n";
tempsql += " and t.create_time <= ? \n"; tempsql += " and t.create_time <= ? \n";
salePara.add(etm);
tempPara.add(etm); tempPara.add(etm);
} }
if (isprepaid != null) { if (isprepaid != null) {
salesql += " and t.isprepaid = ? \n";
tempsql += " and t.isprepaid = ? \n"; tempsql += " and t.isprepaid = ? \n";
salePara.add(isprepaid);
tempPara.add(isprepaid); tempPara.add(isprepaid);
} }
if (product_id != null) { if (product_id != null) {
salesql += " and t.product_id = ? \n";
tempsql += " and t.product_id = ? \n"; tempsql += " and t.product_id = ? \n";
salePara.add(product_id);
tempPara.add(product_id); tempPara.add(product_id);
} }
if (state != null) { if (state != null) {
salesql += " and t.state = ? \n";
tempsql += " and t.state = ? \n"; tempsql += " and t.state = ? \n";
salePara.add(state);
tempPara.add(state); tempPara.add(state);
} }
String fromsql = " from ( " + salesql + " \n union \n" + tempsql + "\n ) a order by a.create_time desc"; String fromsql = " from ( " + tempsql + " ) a order by a.create_time desc";
salePara.addAll(tempPara); return Db.paginate(pp.getPage(), pp.getSize(), "select * ", fromsql, tempPara.toArray());
return Db.paginate(pp.getPage(), pp.getSize(), "select * ", fromsql, salePara.toArray());
} }
public BigDecimal getTotalPriceByLicense(int supermarket_id, String truck_license, double weight) { public BigDecimal getTotalPriceByLicense(int supermarket_id, String truck_license, double weight) {
@ -658,11 +608,6 @@ public class OrderclusterService extends BaseService {
*/ */
public BigDecimal getOverWeight(int ordercluster_id) { public BigDecimal getOverWeight(int ordercluster_id) {
String sql = "select sum(a.weight) weight from ( \n " + String sql = "select sum(a.weight) weight from ( \n " +
" select t.ordercluster_id, sum(t.weight) weight from order_sale t \n" +
" where t.state = ? \n" +
" and t.ordercluster_id = ? \n" +
" group by t.ordercluster_id \n" +
" union \n" +
" select t.ordercluster_id, sum(t.weight) weight from order_temp t \n" + " select t.ordercluster_id, sum(t.weight) weight from order_temp t \n" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.ordercluster_id = ? \n" + " and t.ordercluster_id = ? \n" +
@ -670,7 +615,7 @@ public class OrderclusterService extends BaseService {
" ) a \n" + " ) a \n" +
" group by a.ordercluster_id "; " group by a.ordercluster_id ";
BigDecimal out = Db.queryBigDecimal(sql, OrderStateEnum.RECEIVED.getStateid(), ordercluster_id, OrderStateEnum.RECEIVED.getStateid(), ordercluster_id); BigDecimal out = Db.queryBigDecimal(sql, OrderStateEnum.RECEIVED.getStateid(), ordercluster_id);
return out == null ? new BigDecimal(0) : out; return out == null ? new BigDecimal(0) : out;
} }
@ -683,14 +628,6 @@ public class OrderclusterService extends BaseService {
*/ */
public BigDecimal getOverWeightByCustomer(int customer_id) { public BigDecimal getOverWeightByCustomer(int customer_id) {
String sql = "select sum(a.weight) weight from ( \n" + String sql = "select sum(a.weight) weight from ( \n" +
" select t.ordercluster_id, sum(t.weight) weight from order_sale t \n" +
" left join ordercluster o on o.id = t.ordercluster_id\n" +
" where t.state = ? \n" +
" and o.state < ? \n" +
" and o.customer_id = ? \n" +
" group by t.ordercluster_id \n" +
" \n" +
" union \n" +
" select t.ordercluster_id, sum(t.weight) weight from order_temp t \n" + " select t.ordercluster_id, sum(t.weight) weight from order_temp t \n" +
" left join ordercluster o on o.id = t.ordercluster_id\n" + " left join ordercluster o on o.id = t.ordercluster_id\n" +
" where t.state = ? \n" + " where t.state = ? \n" +
@ -702,7 +639,6 @@ public class OrderclusterService extends BaseService {
BigDecimal out = Db.queryBigDecimal( BigDecimal out = Db.queryBigDecimal(
sql, sql,
OrderStateEnum.RECEIVED.getStateid(), OrderStateEnum.RECEIVED.getStateid(), customer_id,
OrderStateEnum.RECEIVED.getStateid(), OrderStateEnum.RECEIVED.getStateid(), customer_id OrderStateEnum.RECEIVED.getStateid(), OrderStateEnum.RECEIVED.getStateid(), customer_id
); );
@ -718,14 +654,6 @@ public class OrderclusterService extends BaseService {
*/ */
public BigDecimal getOverTotalPriceByCustomer(int customer_id) { public BigDecimal getOverTotalPriceByCustomer(int customer_id) {
String sql = "select sum(a.total_price) total_price from ( \n" + String sql = "select sum(a.total_price) total_price from ( \n" +
" select t.ordercluster_id, sum(t.weight) weight, sum(t.total_price) total_price from order_sale t \n" +
" left join ordercluster o on o.id = t.ordercluster_id\n" +
" where t.state = ? \n" +
" and o.state < ? \n" +
" and o.customer_id = ? \n" +
" group by t.ordercluster_id \n" +
" \n" +
" union \n" +
" select t.ordercluster_id, sum(t.weight) weight, sum(t.total_price) total_price from order_temp t \n" + " select t.ordercluster_id, sum(t.weight) weight, sum(t.total_price) total_price from order_temp t \n" +
" left join ordercluster o on o.id = t.ordercluster_id\n" + " left join ordercluster o on o.id = t.ordercluster_id\n" +
" where t.state = ? \n" + " where t.state = ? \n" +
@ -737,7 +665,6 @@ public class OrderclusterService extends BaseService {
BigDecimal out = Db.queryBigDecimal( BigDecimal out = Db.queryBigDecimal(
sql, sql,
OrderStateEnum.RECEIVED.getStateid(), OrderStateEnum.RECEIVED.getStateid(), customer_id,
OrderStateEnum.RECEIVED.getStateid(), OrderStateEnum.RECEIVED.getStateid(), customer_id OrderStateEnum.RECEIVED.getStateid(), OrderStateEnum.RECEIVED.getStateid(), customer_id
); );

View File

@ -1,25 +0,0 @@
package com.cowr.ssjygl.order.ordersale;
import com.cowr.common.validator.CrudParamValidator;
import com.cowr.common.view.Result;
import com.cowr.model.OrderSale;
import com.jfinal.core.Controller;
/**
* Generated by COWR Fri Apr 17 16:59:39 CST 2020
* TableName: order_sale
* Remarks: -
* PrimaryKey: sn
*/
public class OrderSalePKValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
validateRequired("sn", "sn", "sn 必填");
validateString("sn", 1, 16, "sn", "sn 长度 1~16");
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -1,156 +0,0 @@
package com.cowr.ssjygl.order.ordersale;
import com.cowr.common.Const;
import com.cowr.common.base.BaseService;
import com.cowr.common.view.PageParam;
import com.cowr.common.view.Result;
import com.cowr.model.OrderSale;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import java.util.ArrayList;
import java.util.List;
/**
* Generated by COWR Fri Apr 17 16:59:39 CST 2020
* TableName: order_sale
* Remarks: -
* PrimaryKey: sn
*/
public class OrderSaleService extends BaseService {
public static final OrderSaleService me = new OrderSaleService();
/**
* sn
*
* @param sn
* @return
*/
public Record get(String sn) {
return Db.findFirst("select t.*" +
", p.order_sn " +
", 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 \n" +
", s.name supermarket_name \n" +
" from order_sale t \n" +
" left join transport p on p.order_sn = t.sn \n" +
" left join supermarket s on s.id = t.supermarket_id \n" +
" where t.sn = ?", sn);
}
/**
* @param pp
* @param sn
* @param truck_license
* @param supermarket_id
* @param trans_co_id
* @param customer_id
* @param customer_name
* @param stm
* @param etm
* @param isprepaid
* @return
*/
public Page<Record> find(PageParam pp,
String sn,
String truck_license,
Integer supermarket_id,
Integer trans_co_id,
Integer customer_id,
String customer_name,
String stm,
String etm,
Integer isprepaid,
Integer state,
Integer product_id
) {
String selectsql = "select t.*" +
", p.order_sn " +
", 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";
String fromsql = "from order_sale t \n" +
" left join transport p on p.order_sn = t.sn \n" +
" left join supermarket s on s.id = t.supermarket_id \n" +
" where 1=1 ";
List<Object> paraList = new ArrayList<>();
if (StrKit.notBlank(sn)) {
fromsql += " and t.sn like ? \n";
paraList.add("%" + sn.trim() + "%");
}
if (supermarket_id != null) {
fromsql += " and t.supermarket_id = ? \n";
paraList.add(supermarket_id);
}
if (trans_co_id != null) {
fromsql += " and t.trans_co_id = ? ";
paraList.add(trans_co_id);
}
if (StrKit.notBlank(truck_license)) {
fromsql += " and t.truck_license like ? \n";
paraList.add("%" + truck_license.trim() + "%");
}
if (StrKit.notBlank(customer_name)) {
fromsql += " and t.customer_name like ? \n";
paraList.add("%" + customer_name.trim() + "%");
}
if (customer_id != null) {
fromsql += " and t.customer_id = ? \n";
paraList.add(customer_id);
}
if (StrKit.notBlank(stm)) {
fromsql += " and t.create_time >= ? \n";
paraList.add(stm);
}
if (StrKit.notBlank(etm)) {
fromsql += " and t.create_time <= ? \n";
paraList.add(etm);
}
if (isprepaid != null) {
fromsql += " and t.isprepaid = ? \n";
paraList.add(isprepaid);
}
if (product_id != null) {
fromsql += " and t.product_id = ? \n";
paraList.add(product_id);
}
if (state != null) {
fromsql += " and t.state = ? \n";
paraList.add(state);
}
String totalRowSql = "select count(*) " + fromsql;
String findSql = selectsql + fromsql;
// 前端传了排序字段,并且排序字段存在相关表中
if (StrKit.notBlank(pp.getSort_field()) && OrderSale.dao.hasColunm(pp.getSort_field())) {
findSql += " order by t." + pp.getSort_field() + " is null, t." + pp.getSort_field();
if (Const.ORDER_BY_ASC.equals(pp.getSort_order())) {
findSql += " " + Const.ORDER_BY_ASC;
} else {
findSql += " " + Const.ORDER_BY_DESC;
}
} else {
findSql += " order by t.create_time desc";
}
return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
}
}

View File

@ -166,14 +166,6 @@ public class PrepayService {
* @return * @return
*/ */
public List<Record> consumption(Integer customer_id, Integer supermarket_id, String stm, String etm, String truck_license,Integer invoice_type) { public List<Record> consumption(Integer customer_id, Integer supermarket_id, String stm, String etm, String truck_license,Integer invoice_type) {
String sale_sql = " select t.sn, t.supermarket_id, t.truck_license, t.weight, t.total_price, t.paid, t.customer_id, t.customer_name, t.create_time \n" +
" from order_sale t \n" +
" left join customer c on c.id = t.customer_id \n" +
" where t.state = ? \n" +
" and t.isprepaid = 1 \n" +
" and t.prepay_customer_id is not null \n" +
" and t.create_time >= ? \n" +
" and t.create_time <= ? \n";
String temp_sql = " select t.sn, t.supermarket_id, t.truck_license, t.weight, t.total_price, t.paid, t.customer_id, t.customer_name, t.create_time \n" + String temp_sql = " select t.sn, t.supermarket_id, t.truck_license, t.weight, t.total_price, t.paid, t.customer_id, t.customer_name, t.create_time \n" +
" from order_temp t \n" + " from order_temp t \n" +
" where t.state = ? \n" + " where t.state = ? \n" +
@ -182,45 +174,29 @@ public class PrepayService {
" and t.create_time >= ? \n" + " and t.create_time >= ? \n" +
" and t.create_time <= ? \n"; " and t.create_time <= ? \n";
List<Object> saleList = new ArrayList<>();
List<Object> tempList = new ArrayList<>(); List<Object> tempList = new ArrayList<>();
saleList.add(OrderStateEnum.RECEIVED.getStateid());
saleList.add(stm);
saleList.add(etm);
tempList.add(OrderStateEnum.RECEIVED.getStateid()); tempList.add(OrderStateEnum.RECEIVED.getStateid());
tempList.add(stm); tempList.add(stm);
tempList.add(etm); tempList.add(etm);
if (supermarket_id != null && supermarket_id > 0) { if (supermarket_id != null && supermarket_id > 0) {
sale_sql += " and t.supermarket_id = ?"; temp_sql += " and t.supermarket_id = ? \n";
saleList.add(supermarket_id);
temp_sql += " and t.supermarket_id = ?";
tempList.add(supermarket_id); tempList.add(supermarket_id);
} }
if (invoice_type != null) { if (invoice_type != null) {
sale_sql += " and t.invoice_type = ?"; temp_sql += " and t.invoice_type = ? \n";
saleList.add(invoice_type);
temp_sql += " and t.invoice_type = ?";
tempList.add(invoice_type); tempList.add(invoice_type);
} }
if (customer_id != null && customer_id > 0) { if (customer_id != null && customer_id > 0) {
sale_sql += " and t.customer_id = ?"; temp_sql += " and t.customer_id = ? \n";
saleList.add(customer_id);
temp_sql += " and t.customer_id = ?";
tempList.add(customer_id); tempList.add(customer_id);
} }
if (StrKit.notBlank(truck_license)) { if (StrKit.notBlank(truck_license)) {
sale_sql += " and t.truck_license like ?"; temp_sql += " and t.truck_license like ? \n";
saleList.add("%" + truck_license.trim() + "%");
temp_sql += " and t.truck_license like ?";
tempList.add("%" + truck_license.trim() + "%"); tempList.add("%" + truck_license.trim() + "%");
} }
@ -237,15 +213,13 @@ public class PrepayService {
" ,a.customer_id \n" + " ,a.customer_id \n" +
" ,a.customer_name \n" + " ,a.customer_name \n" +
" ,a.create_time \n" + " ,a.create_time \n" +
" from ( \n" + sale_sql + " from ( \n" + temp_sql +
" union \n" + temp_sql +
" ) a \n" + " ) a \n" +
" left join supermarket s on s.id = a.supermarket_id \n" + " left join supermarket s on s.id = a.supermarket_id \n" +
" left join transport p on p.order_sn = a.sn " + " left join transport p on p.order_sn = a.sn \n" +
" where 1 = 1 \n"; " where 1 = 1 \n";
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
paraList.addAll(saleList);
paraList.addAll(tempList); paraList.addAll(tempList);
return Db.find(sql, paraList.toArray()); return Db.find(sql, paraList.toArray());
@ -447,14 +421,6 @@ public class PrepayService {
" case when a.paid > 0 then concat('补差额', a.paid) else '' end memo, a.customer_id, a.customer_name \n" + " case when a.paid > 0 then concat('补差额', a.paid) else '' end memo, a.customer_id, a.customer_name \n" +
" from ( \n" + " from ( \n" +
" select t.sn, t.total_price, t.paid, t.customer_id, t.customer_name, t.create_time \n" + " select t.sn, t.total_price, t.paid, t.customer_id, t.customer_name, t.create_time \n" +
" from order_sale t \n" +
" where t.isprepaid = 1 \n" +
" and t.state = ? \n" +
" and t.prepay_customer_id is not null\n" +
" and t.create_time >= ? \n" +
" and t.create_time <= ? \n" +
" union \n" +
" select t.sn, t.total_price, t.paid, t.customer_id, t.customer_name, t.create_time \n" +
" from order_temp t \n" + " from order_temp t \n" +
" where t.isprepaid = 1 \n" + " where t.isprepaid = 1 \n" +
" and t.state = ? \n" + " and t.state = ? \n" +
@ -487,10 +453,6 @@ public class PrepayService {
paraList.add(stm); paraList.add(stm);
paraList.add(etm); paraList.add(etm);
paraList.add(OrderStateEnum.RECEIVED.getStateid());
paraList.add(stm);
paraList.add(etm);
paraList.add(stm); paraList.add(stm);
paraList.add(etm); paraList.add(etm);

View File

@ -47,30 +47,6 @@ public class OrderStatService {
Integer product_id, Integer product_id,
String sn String sn
) { ) {
String sale_sql = " select\n" +
" t.sn\n" +
" , t.weight\n" +
" , t.unit_price\n" +
" , t.paid\n" +
" , t.total_price\n" +
" , t.customer_id\n" +
" , t.customer_name\n" +
" , t.truck_license\n" +
" , t.trans_price\n" +
" , t.trans_distance\n" +
" , t.supermarket_id\n" +
" , 1 type \n" + // OrderTypeEnum.SALE.getTypeid()
" , t.trans_co_id\n" +
" , t.trans_co_name\n" +
" , t.isprepaid\n" +
" , t.create_time \n" +
" , t.product_id \n" +
" , t.product_name \n" +
" , p.in_time, p.out_time, p.first_weight, p.second_weight \n" +
" from order_sale t \n" +
" left join transport p on p.order_sn = t.sn \n" +
" where t.state = ? \n" +
" and t.create_time like ? \n";
String temp_sql = " select\n" + String temp_sql = " select\n" +
" t.sn\n" + " t.sn\n" +
" , t.weight\n" + " , t.weight\n" +
@ -96,67 +72,47 @@ public class OrderStatService {
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.create_time like ? \n"; " and t.create_time like ? \n";
List<Object> paraSaleList = new ArrayList<>();
List<Object> paraTempList = new ArrayList<>(); List<Object> paraTempList = new ArrayList<>();
paraSaleList.add(OrderStateEnum.RECEIVED.getStateid());
paraSaleList.add(tm + "%");
paraTempList.add(OrderStateEnum.RECEIVED.getStateid()); paraTempList.add(OrderStateEnum.RECEIVED.getStateid());
paraTempList.add(tm + "%"); paraTempList.add(tm + "%");
if (supermarket_id != null && supermarket_id > 0) { if (supermarket_id != null && supermarket_id > 0) {
sale_sql += " and t.supermarket_id = ? \n";
temp_sql += " and t.supermarket_id = ? \n"; temp_sql += " and t.supermarket_id = ? \n";
paraSaleList.add(supermarket_id);
paraTempList.add(supermarket_id); paraTempList.add(supermarket_id);
} }
if (trans_co_id != null && trans_co_id > 0) { if (trans_co_id != null && trans_co_id > 0) {
sale_sql += " and t.trans_co_id = ? \n";
temp_sql += " and t.trans_co_id = ? \n"; temp_sql += " and t.trans_co_id = ? \n";
paraSaleList.add(trans_co_id);
paraTempList.add(trans_co_id); paraTempList.add(trans_co_id);
} }
if (isprepaid != null && isprepaid != -1) { if (isprepaid != null && isprepaid != -1) {
sale_sql += " and t.isprepaid = ? \n";
temp_sql += " and t.isprepaid = ? \n"; temp_sql += " and t.isprepaid = ? \n";
paraSaleList.add(isprepaid);
paraTempList.add(isprepaid); paraTempList.add(isprepaid);
} }
if (customer_id != null && customer_id > 0) { if (customer_id != null && customer_id > 0) {
sale_sql += " and t.customer_id = ? \n";
temp_sql += " and t.customer_id = ? \n"; temp_sql += " and t.customer_id = ? \n";
paraSaleList.add(customer_id);
paraTempList.add(customer_id); paraTempList.add(customer_id);
} }
if (product_id != null && product_id > 0) { if (product_id != null && product_id > 0) {
sale_sql += " and t.product_id = ? \n";
temp_sql += " and t.product_id = ? \n"; temp_sql += " and t.product_id = ? \n";
paraSaleList.add(product_id);
paraTempList.add(product_id); paraTempList.add(product_id);
} }
if (StrKit.notBlank(customer_name)) { if (StrKit.notBlank(customer_name)) {
sale_sql += " and t.customer_name like ? \n";
temp_sql += " and t.customer_name like ? \n"; temp_sql += " and t.customer_name like ? \n";
paraSaleList.add("%" + customer_name.trim() + "%");
paraTempList.add("%" + customer_name.trim() + "%"); paraTempList.add("%" + customer_name.trim() + "%");
} }
if (StrKit.notBlank(truck_license)) { if (StrKit.notBlank(truck_license)) {
sale_sql += " and t.truck_license like ? \n";
temp_sql += " and t.truck_license like ? \n"; temp_sql += " and t.truck_license like ? \n";
paraSaleList.add("%" + truck_license.trim() + "%");
paraTempList.add("%" + truck_license.trim() + "%"); paraTempList.add("%" + truck_license.trim() + "%");
} }
if (StrKit.notBlank(sn)) { if (StrKit.notBlank(sn)) {
sale_sql += " and t.sn like ? \n";
temp_sql += " and t.sn like ? \n"; temp_sql += " and t.sn like ? \n";
paraSaleList.add("%" + sn.trim() + "%");
paraTempList.add("%" + sn.trim() + "%"); paraTempList.add("%" + sn.trim() + "%");
} }
@ -184,13 +140,9 @@ public class OrderStatService {
" from( \n"; " from( \n";
if (null == type) { if (null == type) {
sql += sale_sql + " \n union \n " + temp_sql; sql += temp_sql;
paraSaleList.addAll(paraTempList);
} else if (OrderTypeEnum.SALE.getTypeid() == type) {
sql += sale_sql;
} else if (OrderTypeEnum.TEMP.getTypeid() == type) { } else if (OrderTypeEnum.TEMP.getTypeid() == type) {
sql += temp_sql; sql += temp_sql;
paraSaleList = paraTempList;
} else { } else {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -198,8 +150,7 @@ public class OrderStatService {
sql += " ) a\n" + sql += " ) a\n" +
" left join supermarket s on s.id = a.supermarket_id\n"; " left join supermarket s on s.id = a.supermarket_id\n";
return Db.find(sql, paraTempList.toArray());
return Db.find(sql, paraSaleList.toArray());
} }
public Workbook daydetailExport( public Workbook daydetailExport(
@ -380,11 +331,6 @@ public class OrderStatService {
// 使用实际支付金额统计 // 使用实际支付金额统计
String 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 \n" + String 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 \n" +
" from (\n" + " from (\n" +
" select t.customer_id, t.customer_name, t.supermarket_id, t.paid, t.total_price, 1 type \n" +
" from order_sale t\n" +
" where t.state = ? \n" +
" and t.create_time like ?\n" +
" union all\n" +
" select t.customer_id, t.customer_name, t.supermarket_id, t.paid, t.total_price, 3 type \n" + " select t.customer_id, t.customer_name, t.supermarket_id, t.paid, t.total_price, 3 type \n" +
" from order_temp t\n" + " from order_temp t\n" +
" where t.state = ? \n" + " where t.state = ? \n" +
@ -394,9 +340,6 @@ public class OrderStatService {
" where 1 = 1 \n"; " where 1 = 1 \n";
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
paraList.add(OrderStateEnum.RECEIVED.getStateid());
paraList.add(tm + "%");
paraList.add(OrderStateEnum.RECEIVED.getStateid()); paraList.add(OrderStateEnum.RECEIVED.getStateid());
paraList.add(tm + "%"); paraList.add(tm + "%");
@ -551,11 +494,6 @@ public class OrderStatService {
" 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" +
" from (\n" + " from (\n" +
" select t.supermarket_id as id, t.paid, t.total_price, t.weight, t.product_id\n" + " select t.supermarket_id as id, t.paid, t.total_price, t.weight, t.product_id\n" +
" from order_sale t\n" +
" where t.state = ? \n" +
" and t.create_time like ? \n" +
" union all\n" +
" select t.supermarket_id as id, t.paid, t.total_price, t.weight, t.product_id\n" +
" from order_temp t\n" + " from order_temp t\n" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.create_time like ? \n" + " and t.create_time like ? \n" +
@ -565,7 +503,7 @@ public class OrderStatService {
" left join supermarket s on s.id = t.supermarket_id\n" + " left join supermarket s on s.id = t.supermarket_id\n" +
" left join product p on p.id = t.product_id"; " left join product p on p.id = t.product_id";
List<Record> dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), tm + "%", OrderStateEnum.RECEIVED.getStateid(), tm + "%"); List<Record> dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), tm + "%");
Record total = new Record(); Record total = new Record();
total.set("id", 0); total.set("id", 0);
@ -600,12 +538,6 @@ public class OrderStatService {
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" + 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_sale t\n" +
" where t.state = ? \n" +
" and t.invoice_type = ? \n" +
" and t.create_time like ? \n" +
" union all\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" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.invoice_type = ? \n" + " and t.invoice_type = ? \n" +
@ -614,28 +546,18 @@ public class OrderStatService {
" group by t.customer_name", " group by t.customer_name",
OrderStateEnum.RECEIVED.getStateid(), OrderStateEnum.RECEIVED.getStateid(),
invoice_type, invoice_type,
tm + "%",
OrderStateEnum.RECEIVED.getStateid(),
invoice_type,
tm + "%" tm + "%"
); );
} else { } 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" + 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_sale t\n" +
" where t.state = ? \n" +
" and t.create_time like ? \n" +
" union all\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" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.create_time like ? \n" + " and t.create_time like ? \n" +
" ) t\n" + " ) t\n" +
" group by t.customer_name", " group by t.customer_name",
OrderStateEnum.RECEIVED.getStateid(), OrderStateEnum.RECEIVED.getStateid(),
tm + "%",
OrderStateEnum.RECEIVED.getStateid(),
tm + "%" tm + "%"
); );
} }
@ -868,13 +790,6 @@ public class OrderStatService {
String sql = "select date_format(t.create_time, '%Y-%m-%d') as date, sum(t.weight) as weight, sum(t.total_price) as totalPrice\n" + String sql = "select date_format(t.create_time, '%Y-%m-%d') as date, sum(t.weight) as weight, sum(t.total_price) as totalPrice\n" +
"from (\n" + "from (\n" +
" select t.create_time, t.weight, t.paid, t.total_price\n" + " select t.create_time, t.weight, t.paid, t.total_price\n" +
" from order_sale t\n" +
" where t.state = ? \n" +
paramsSql +
" and t.create_time >= ? \n" +
" and t.create_time <= ? \n" +
" union all\n" +
" select t.create_time, t.weight, t.paid, t.total_price\n" +
" from order_temp t\n" + " from order_temp t\n" +
" where t.state = ? \n" + " where t.state = ? \n" +
paramsSql + paramsSql +
@ -886,9 +801,9 @@ public class OrderStatService {
List<Record> dblist; List<Record> dblist;
if (supermarket_id != null) { if (supermarket_id != null) {
dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), supermarket_id, stm, etm, OrderStateEnum.RECEIVED.getStateid(), supermarket_id, stm, etm); dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), supermarket_id, stm, etm);
} else { } else {
dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), stm, etm, OrderStateEnum.RECEIVED.getStateid(), stm, etm); dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), stm, etm);
} }
Record total = new Record(); Record total = new Record();
@ -1007,33 +922,18 @@ public class OrderStatService {
* @return * @return
*/ */
public List<Record> statTrans(String tm, String stm, String etm, Integer supermarket_id, boolean stat_product, Integer product_id, Integer isprepaid) { public List<Record> statTrans(String tm, String stm, String etm, Integer supermarket_id, boolean stat_product, Integer product_id, Integer isprepaid) {
String sale_sql;
String temp_sql; String temp_sql;
List<Object> paraSale = new ArrayList<>();
List<Object> paraTemp = new ArrayList<>(); List<Object> paraTemp = new ArrayList<>();
if (stat_product) { if (stat_product) {
sale_sql = "select " +
" t.trans_co_id, t.product_id, t.product_name, sum(t.weight) weight, sum(t.total_price) total_price, " +
" count(t.sn) orderCount, sum(t.trans_distance) trans_distance, sum(t.trans_price) trans_price " +
" from order_sale t \n" +
" left join transport p on p.order_sn = t.sn \n" +
" where t.state = ? \n";
temp_sql = "select -1 trans_co_id, t.product_id, t.product_name, ifnull(sum(t.weight), 0) weight, ifnull(sum(t.total_price), 0) total_price," + temp_sql = "select -1 trans_co_id, t.product_id, t.product_name, ifnull(sum(t.weight), 0) weight, ifnull(sum(t.total_price), 0) total_price," +
" count(t.sn) orderCount, 0 trans_distance, 0 trans_price " + " count(t.sn) orderCount, 0 trans_distance, 0 trans_price " +
" from order_temp t\n" + " from order_temp t\n" +
" left join transport p on p.order_sn = t.sn \n" + " left join transport p on p.order_sn = t.sn \n" +
" where t.state = ? \n"; " where t.state = ? \n";
paraSale.add(OrderStateEnum.RECEIVED.getStateid());
paraTemp.add(OrderStateEnum.RECEIVED.getStateid()); paraTemp.add(OrderStateEnum.RECEIVED.getStateid());
if (supermarket_id != null) { if (supermarket_id != null) {
sale_sql += " and t.supermarket_id = ? \n";
paraSale.add(supermarket_id);
temp_sql += " and t.supermarket_id = ? \n"; temp_sql += " and t.supermarket_id = ? \n";
paraTemp.add(supermarket_id); paraTemp.add(supermarket_id);
} }
@ -1043,59 +943,34 @@ public class OrderStatService {
log.error("参数错误"); log.error("参数错误");
return new ArrayList<>(); return new ArrayList<>();
} }
sale_sql += " and t.create_time between ? and ? \n";
paraSale.add(stm);
paraSale.add(etm);
temp_sql += " and t.create_time between ? and ? \n"; temp_sql += " and t.create_time between ? and ? \n";
paraTemp.add(stm); paraTemp.add(stm);
paraTemp.add(etm); paraTemp.add(etm);
} else { } else {
sale_sql += " and t.create_time like ? \n";
paraSale.add(tm + "%");
temp_sql += " and t.create_time like ? \n"; temp_sql += " and t.create_time like ? \n";
paraTemp.add(tm + "%"); paraTemp.add(tm + "%");
} }
if (product_id != null) { if (product_id != null) {
sale_sql += " and t.product_id = ? \n";
paraSale.add(product_id);
temp_sql += " and t.product_id = ? \n"; temp_sql += " and t.product_id = ? \n";
paraTemp.add(product_id); paraTemp.add(product_id);
} }
if (isprepaid != null) { if (isprepaid != null) {
sale_sql += " and t.isprepaid = ? \n";
paraSale.add(isprepaid);
temp_sql += " and t.isprepaid = ? \n"; temp_sql += " and t.isprepaid = ? \n";
paraTemp.add(isprepaid); paraTemp.add(isprepaid);
} }
sale_sql += " group by t.trans_co_id, t.product_id \n";
temp_sql += " group by t.product_id "; temp_sql += " group by t.product_id ";
} else { } else {
sale_sql = "select t.trans_co_id, sum(t.weight) weight, sum(t.total_price) total_price, count(t.sn) orderCount" +
" , sum(t.trans_distance) trans_distance, sum(t.trans_price) trans_price " +
" from order_sale t \n" +
" left join transport p on p.order_sn = t.sn \n" +
" where t.state = ? \n";
temp_sql = "select -1 trans_co_id, ifnull(sum(t.weight), 0) weight, ifnull(sum(t.total_price), 0) total_price, count(t.sn) orderCount, 0 trans_distance, 0 trans_price " + temp_sql = "select -1 trans_co_id, ifnull(sum(t.weight), 0) weight, ifnull(sum(t.total_price), 0) total_price, count(t.sn) orderCount, 0 trans_distance, 0 trans_price " +
" from order_temp t\n" + " from order_temp t\n" +
" left join transport p on p.order_sn = t.sn \n" + " left join transport p on p.order_sn = t.sn \n" +
" where t.state = ? \n"; " where t.state = ? \n";
paraSale.add(OrderStateEnum.RECEIVED.getStateid());
paraTemp.add(OrderStateEnum.RECEIVED.getStateid()); paraTemp.add(OrderStateEnum.RECEIVED.getStateid());
if (supermarket_id != null) { if (supermarket_id != null) {
sale_sql += " and t.supermarket_id = ? \n";
paraSale.add(supermarket_id);
temp_sql += " and t.supermarket_id = ? \n"; temp_sql += " and t.supermarket_id = ? \n";
paraTemp.add(supermarket_id); paraTemp.add(supermarket_id);
} }
@ -1106,43 +981,27 @@ public class OrderStatService {
return new ArrayList<>(); return new ArrayList<>();
} }
sale_sql += " and t.create_time between ? and ? \n";
paraSale.add(stm);
paraSale.add(etm);
temp_sql += " and t.create_time between ? and ? \n"; temp_sql += " and t.create_time between ? and ? \n";
paraTemp.add(stm); paraTemp.add(stm);
paraTemp.add(etm); paraTemp.add(etm);
} else { } else {
sale_sql += " and t.create_time like ? \n";
paraSale.add(tm + "%");
temp_sql += " and t.create_time like ? \n"; temp_sql += " and t.create_time like ? \n";
paraTemp.add(tm + "%"); paraTemp.add(tm + "%");
} }
if (isprepaid != null) { if (isprepaid != null) {
sale_sql += " and t.isprepaid = ? \n";
paraSale.add(isprepaid);
temp_sql += " and t.isprepaid = ? \n"; temp_sql += " and t.isprepaid = ? \n";
paraTemp.add(isprepaid); paraTemp.add(isprepaid);
} }
sale_sql += " group by t.trans_co_id \n";
} }
String sql = "select ifnull(co.name, '外销') trans_co_name, a.* from ( \n" + String sql = "select ifnull(co.name, '外销') trans_co_name, a.* from ( \n" +
sale_sql +
" union \n " +
temp_sql + temp_sql +
" ) a\n" + " ) a\n" +
" left join transport_company co on co.id = a.trans_co_id \n" + " left join transport_company co on co.id = a.trans_co_id \n" +
" order by a.trans_co_id desc"; " order by a.trans_co_id desc";
paraSale.addAll(paraTemp); List<Record> list = Db.find(sql, paraTemp.toArray());
List<Record> list = Db.find(sql, paraSale.toArray());
// 只有一个统计总数为 0 的记录时,删除该记录后返回 // 只有一个统计总数为 0 的记录时,删除该记录后返回
if (list != null && list.size() == 1) { if (list != null && list.size() == 1) {
@ -1270,33 +1129,21 @@ public class OrderStatService {
* @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, boolean stat_product, Integer product_id, Integer isprepaid) {
String sale_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 "; 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> paraSale = new ArrayList<>();
List<Object> paraTemp = new ArrayList<>(); List<Object> paraTemp = new ArrayList<>();
sale_sql += " from order_sale t \n" +
" where t.state = ? \n";
temp_sql += " from order_temp t\n" + temp_sql += " from order_temp t\n" +
" where t.state = ? \n"; " where t.state = ? \n";
paraSale.add(OrderStateEnum.RECEIVED.getStateid());
paraTemp.add(OrderStateEnum.RECEIVED.getStateid()); paraTemp.add(OrderStateEnum.RECEIVED.getStateid());
if (supermarket_id != null) { if (supermarket_id != null) {
sale_sql += " and t.supermarket_id = ? \n";
paraSale.add(supermarket_id);
temp_sql += " and t.supermarket_id = ? \n"; temp_sql += " and t.supermarket_id = ? \n";
paraTemp.add(supermarket_id); paraTemp.add(supermarket_id);
} }
if (customer_id != null) { if (customer_id != null) {
sale_sql += " and t.customer_id = ? \n";
paraSale.add(customer_id);
temp_sql += " and t.customer_id = ? \n"; temp_sql += " and t.customer_id = ? \n";
paraTemp.add(customer_id); paraTemp.add(customer_id);
} }
@ -1305,26 +1152,20 @@ public class OrderStatService {
String[] cids = customer_ids.split(","); String[] cids = customer_ids.split(",");
if (cids.length > 0) { if (cids.length > 0) {
sale_sql += " and t.customer_id in( \n";
temp_sql += " and t.customer_id in( \n"; temp_sql += " and t.customer_id in( \n";
for (int i = 0; i < cids.length; i++) { for (int i = 0; i < cids.length; i++) {
String cid = cids[i]; String cid = cids[i];
if (i > 0) { if (i > 0) {
sale_sql += ", ";
temp_sql += ", "; temp_sql += ", ";
} }
sale_sql += "?";
temp_sql += "?"; temp_sql += "?";
paraSale.add(cid);
paraTemp.add(cid); paraTemp.add(cid);
} }
sale_sql += " ) \n";
temp_sql += " ) \n"; temp_sql += " ) \n";
} }
} }
@ -1334,26 +1175,15 @@ public class OrderStatService {
log.error("参数错误"); log.error("参数错误");
return new ArrayList<>(); return new ArrayList<>();
} }
sale_sql += " and t.create_time between ? and ? \n";
paraSale.add(stm);
paraSale.add(etm);
temp_sql += " and t.create_time between ? and ? \n"; temp_sql += " and t.create_time between ? and ? \n";
paraTemp.add(stm); paraTemp.add(stm);
paraTemp.add(etm); paraTemp.add(etm);
} else { } else {
sale_sql += " and t.create_time like ? \n";
paraSale.add(tm + "%");
temp_sql += " and t.create_time like ? \n"; temp_sql += " and t.create_time like ? \n";
paraTemp.add(tm + "%"); paraTemp.add(tm + "%");
} }
if (isprepaid != null) { if (isprepaid != null) {
sale_sql += " and t.isprepaid = ? \n";
paraSale.add(isprepaid);
temp_sql += " and t.isprepaid = ? \n"; temp_sql += " and t.isprepaid = ? \n";
paraTemp.add(isprepaid); paraTemp.add(isprepaid);
} }
@ -1362,17 +1192,12 @@ public class OrderStatService {
if (stat_product) { if (stat_product) {
if (product_id != null) { if (product_id != null) {
sale_sql += " and t.product_id = ? \n";
paraSale.add(product_id);
temp_sql += " and t.product_id = ? \n"; temp_sql += " and t.product_id = ? \n";
paraTemp.add(product_id); paraTemp.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" +
sale_sql +
" union \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" +
@ -1380,17 +1205,13 @@ public class OrderStatService {
} 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" +
sale_sql +
" union \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 "; " group by a.customer_name ";
} }
paraSale.addAll(paraTemp); List<Record> list = Db.find(sql, paraTemp.toArray());
List<Record> list = Db.find(sql, paraSale.toArray());
// 只有一个统计总数为 0 的记录时,删除该记录后返回 // 只有一个统计总数为 0 的记录时,删除该记录后返回
if (list != null && list.size() == 1) { if (list != null && list.size() == 1) {
@ -2186,19 +2007,6 @@ public class OrderStatService {
"\tifnull(sum(case g.supermarket_id when 9 then g.total_price end), 0) sl_xse,\n" + "\tifnull(sum(case g.supermarket_id when 9 then g.total_price end), 0) sl_xse,\n" +
"\tifnull(sum(case g.supermarket_id when 10 then g.total_price end), 0) hdw_xse\n" + "\tifnull(sum(case g.supermarket_id when 10 then g.total_price end), 0) hdw_xse\n" +
"from (\n" + "from (\n" +
"\n" +
"\tselect\n" +
"\t\tifnull(t.customer_id, 0) customer_id,\n" +
"\t\tt.supermarket_id,\n" +
"\t\tifnull(sum(t.weight), 0) weight,\n" +
"\t\tifnull(sum(t.total_price), 0) total_price\n" +
"\tfrom order_sale t\n" +
"\twhere t.state = 5\n" +
"\tand t.create_time>= ?\n" +
"\tand t.create_time<= ?\n" +
paramsSql +
"\tgroup by t.customer_id, t.supermarket_id\n" +
"\tunion all\n" +
"\tselect\n" + "\tselect\n" +
"\t\tifnull(t.customer_id, 0) customer_id,\n" + "\t\tifnull(t.customer_id, 0) customer_id,\n" +
"\t\tt.supermarket_id,\n" + "\t\tt.supermarket_id,\n" +
@ -2215,9 +2023,9 @@ public class OrderStatService {
"group by g.customer_id"; "group by g.customer_id";
List<Record> recordList; List<Record> recordList;
if (invoice_type != null) { if (invoice_type != null) {
recordList = Db.find(sql, stm, etm, invoice_type, stm, etm, invoice_type); recordList = Db.find(sql, stm, etm, invoice_type);
} else { } else {
recordList = Db.find(sql, stm, etm, stm, etm); recordList = Db.find(sql, stm, etm);
} }
return recordList; return recordList;
} }

View File

@ -43,15 +43,14 @@ public class TicketLogService extends BaseService {
public Page<Record> find(PageParam pp, Integer supermarket_id, Integer state, String order_sn, String stm, String etm, String ticket_code) { public Page<Record> find(PageParam pp, Integer supermarket_id, Integer state, String order_sn, String stm, String etm, String ticket_code) {
String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" + String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" +
" case when t.type = 1 then o.weight when t.type = 3 then p.weight end weight, \n" + " case when t.type = 3 then p.weight end weight, \n" +
" case when t.type = 1 then o.total_price when t.type = 3 then p.total_price end total_price, \n" + " case when t.type = 3 then p.total_price end total_price, \n" +
" case when t.type = 1 then o.create_time when t.type = 3 then p.create_time end create_time, \n" + " case when t.type = 3 then p.create_time end create_time, \n" +
" case when t.type = 1 then o.settlement_user_name when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" + " case when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" +
" case when t.type = 1 then o.customer_name when t.type = 3 then p.customer_name end customer_name "; " case when t.type = 3 then p.customer_name end customer_name \n";
String fromsql = "from ticket_log t \n" + String fromsql = "from ticket_log t \n" +
" left join ticket_receive r on r.id = t.ticket_receive_id \n" + " left join ticket_receive r on r.id = t.ticket_receive_id \n" +
" left join supermarket s on s.id = r.supermarket_id \n" + " left join supermarket s on s.id = r.supermarket_id \n" +
" left join order_sale o on o.sn = t.order_sn \n" +
" left join order_temp p on p.sn = t.order_sn \n" + " left join order_temp p on p.sn = t.order_sn \n" +
" where 1=1 "; " where 1=1 ";
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
@ -108,18 +107,17 @@ public class TicketLogService extends BaseService {
public Workbook export(Integer supermarket_id, Integer state, String order_sn, String stm, String etm, String ticket_code) { public Workbook export(Integer supermarket_id, Integer state, String order_sn, String stm, String etm, String ticket_code) {
String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" + String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" +
" tr.first_weight, tr.second_weight, \n" + " tr.first_weight, tr.second_weight, \n" +
" case when t.type = 1 then o.weight when t.type = 3 then p.weight end weight, \n" + " case when t.type = 3 then p.weight end weight, \n" +
" case when t.type = 1 then o.total_price when t.type = 3 then p.total_price end total_price, \n" + " case when t.type = 3 then p.total_price end total_price, \n" +
" case when t.type = 1 then o.create_time when t.type = 3 then p.create_time end order_create_time, \n" + " case when t.type = 3 then p.create_time end order_create_time, \n" +
" case when t.type = 1 then o.settlement_user_name when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" + " case when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" +
" case when t.type = 1 then o.truck_license when t.type = 3 then p.truck_license end truck_license, \n" + " case when t.type = 3 then p.truck_license end truck_license, \n" +
" case when t.type = 1 then o.customer_texpayer_name when t.type = 3 then p.customer_texpayer_name end customer_texpayer_name, \n" + " case when t.type = 3 then p.customer_texpayer_name end customer_texpayer_name, \n" +
" case when t.type = 1 then o.customer_texpayer_num when t.type = 3 then p.customer_texpayer_num end customer_texpayer_num, \n" + " case when t.type = 3 then p.customer_texpayer_num end customer_texpayer_num, \n" +
" case when t.type = 1 then o.customer_name when t.type = 3 then p.customer_name end customer_name "; " case when t.type = 3 then p.customer_name end customer_name ";
String fromsql = "from ticket_log t \n" + String fromsql = "from ticket_log t \n" +
" left join ticket_receive r on r.id = t.ticket_receive_id \n" + " left join ticket_receive r on r.id = t.ticket_receive_id \n" +
" left join supermarket s on s.id = r.supermarket_id \n" + " left join supermarket s on s.id = r.supermarket_id \n" +
" left join order_sale o on o.sn = t.order_sn \n" +
" left join order_temp p on p.sn = t.order_sn \n" + " left join order_temp p on p.sn = t.order_sn \n" +
" left join transport tr on tr.order_sn = t.order_sn \n" + " left join transport tr on tr.order_sn = t.order_sn \n" +
" where 1=1 \n"; " where 1=1 \n";

View File

@ -31,7 +31,6 @@ import com.cowr.local.ssjygl.order.invalidverify.OrderInvalidVerifyController;
import com.cowr.local.ssjygl.order.ordercluster.OrderclusterController; import com.cowr.local.ssjygl.order.ordercluster.OrderclusterController;
import com.cowr.local.ssjygl.order.ordercluster.truck.OrderclusterTruckController; import com.cowr.local.ssjygl.order.ordercluster.truck.OrderclusterTruckController;
import com.cowr.local.ssjygl.order.orderpurchase.OrderPurchaseController; import com.cowr.local.ssjygl.order.orderpurchase.OrderPurchaseController;
import com.cowr.local.ssjygl.order.ordersale.OrderSaleController;
import com.cowr.local.ssjygl.order.ordertemp.OrderTempController; import com.cowr.local.ssjygl.order.ordertemp.OrderTempController;
import com.cowr.local.ssjygl.order.ordertransfer.OrderTransferController; import com.cowr.local.ssjygl.order.ordertransfer.OrderTransferController;
import com.cowr.local.ssjygl.order.ordertrash.OrderTrashController; import com.cowr.local.ssjygl.order.ordertrash.OrderTrashController;
@ -218,7 +217,6 @@ public class Config extends JFinalConfig {
// -- 订单相关 // -- 订单相关
me.add("/order/ordercluster", OrderclusterController.class); me.add("/order/ordercluster", OrderclusterController.class);
me.add("/order/sale", OrderSaleController.class);
me.add("/order/temp", OrderTempController.class); me.add("/order/temp", OrderTempController.class);
me.add("/order/transfer", OrderTransferController.class); me.add("/order/transfer", OrderTransferController.class);
me.add("/order/trash", OrderTrashController.class); me.add("/order/trash", OrderTrashController.class);

View File

@ -1,125 +0,0 @@
package com.cowr.local.ssjygl.order.ordersale;
import com.cowr.common.base.BaseController;
import com.cowr.common.enums.Enums;
import com.cowr.common.enums.OrderTypeEnum;
import com.cowr.common.view.PageParam;
import com.cowr.common.view.Result;
import com.cowr.local.ssjygl.order.LocalOrderService;
import com.cowr.local.ssjygl.system.sysuser.SysuserSyncService;
import com.cowr.model.Sysuser;
import com.cowr.ssjygl.order.OrderCancelValidator;
import com.cowr.ssjygl.order.SnValidator;
import com.cowr.ssjygl.order.ordersale.OrderSalePKValidator;
import com.cowr.ssjygl.order.ordersale.OrderSaleService;
import com.jfinal.aop.Before;
public class OrderSaleController extends BaseController {
@Before(OrderSalePKValidator.class)
public void get() {
renderJson(Result.object(OrderSaleService.me.get(get("sn"))));
}
/**
* order_sale
*/
public void find() {
PageParam pp = getBean(PageParam.class, "", true);
String stm = get("stm");
String etm = get("etm");
String truck_license = getUpperCaseVal("truck_license");
String customer_name = get("customer_name");
String sn = get("sn");
Integer state = getInt("state");
Integer product_id = getInt("product_id");
Integer supermarket_id = getInt("supermarket_id");
Integer trans_co_id = getInt("trans_co_id");
Integer isprepaid = getInt("isprepaid");
Integer customer_id = getInt("customer_id");
renderJson(Result.object(OrderSaleService.me.find(pp, sn, truck_license, supermarket_id, trans_co_id, customer_id, customer_name, stm, etm, isprepaid, state, product_id)));
}
/**
*
*/
@Before(OrderSalePayValidator.class)
public void pay() {
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
if (tokenuser == null) {
renderJson(Result.noauth());
return;
}
String uuid = get("uuid");
String transport_id = get("transport_id");
Integer ordercluster_id = getInt("ordercluster_id");
String driver_name = get("driver_name");
String driver_phone = get("driver_phone");
String memo = get("memo");
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
renderJson(OrderSaleSyncService.me.pay(uuid, transport_id, ordercluster_id, driver_name, driver_phone, memo, printer, tokenuser));
}
/**
*
*/
@Before(OrderSalePayValidator.class)
public void prepay() {
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
if (tokenuser == null) {
renderJson(Result.noauth());
return;
}
String uuid = get("uuid");
String transport_id = get("transport_id");
Integer ordercluster_id = getInt("ordercluster_id");
String driver_name = get("driver_name");
String driver_phone = get("driver_phone");
String memo = get("memo");
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
renderJson(OrderSaleSyncService.me.prepay(uuid, transport_id, ordercluster_id, driver_name, driver_phone, memo, printer, tokenuser));
}
/**
*
*/
@Before(OrderCancelValidator.class)
public void cancel() {
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
if (tokenuser == null) {
renderJson(Result.noauth());
return;
}
String sn = get("sn");
String password = get("password");
renderJson(OrderSaleSyncService.me.cancel(sn, tokenuser, password));
}
@Before(SnValidator.class)
public void print() {
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
if (tokenuser == null) {
renderJson(Result.noauth());
return;
}
String sn = get("sn");
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
if (Integer.parseInt(sn.substring(10, 12)) != OrderTypeEnum.SALE.getTypeid()) {
renderJson(Result.failed("sn 不能为 null"));
} else {
renderJson(LocalOrderService.me.print(sn, printer, tokenuser));
}
}
}

View File

@ -1,22 +0,0 @@
package com.cowr.local.ssjygl.order.ordersale;
import com.cowr.common.validator.CrudParamValidator;
import com.cowr.common.view.Result;
import com.jfinal.core.Controller;
public class OrderSalePayValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
validateString("uuid", 32, 32, "uuid", "uuid 长度 32必填");
validateString("transport_id", 32, 32, "transport_id", "transport_id 长度 32必填");
validateInteger("ordercluster_id", 1, 2147483647, "ordercluster_id", "ordercluster_id 范围 1~2147483647");
validateString("driver_name", 0, 8, "driver_name", "driver_name 长度 0~8");
validateString("driver_phone", 0, 11, "driver_phone", "driver_phone 长度 0~11");
validateString("memo", 0, 11, "memo", "memo 长度 0~255");
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -1,641 +0,0 @@
package com.cowr.local.ssjygl.order.ordersale;
import com.cowr.common.enums.Enums;
import com.cowr.common.enums.OrderStateEnum;
import com.cowr.common.enums.OrderTypeEnum;
import com.cowr.common.utils.DateTimeUtil;
import com.cowr.common.view.Result;
import com.cowr.local.ssjygl.order.LocalOrderService;
import com.cowr.local.ssjygl.order.orderseq.OrderSeqService;
import com.cowr.ssjygl.customer.supermarketproduct.CustomerSupermarketProductService;
import com.cowr.local.ssjygl.synctask.SyncTaskService;
import com.cowr.local.ssjygl.system.sysuser.SysuserSyncService;
import com.cowr.model.*;
import com.cowr.local.ssjygl.modifylog.ModifyLogSyncService;
import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService;
import com.cowr.ssjygl.transprice.TransPriceService;
import com.jfinal.kit.StrKit;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.IAtom;
import com.jfinal.plugin.activerecord.Record;
import java.math.BigDecimal;
import java.util.Date;
public class OrderSaleSyncService {
public static OrderSaleSyncService me = new OrderSaleSyncService();
private static Log log = Log.getLog(OrderSaleSyncService.class);
/**
*
* 1.1.
*
* @param uuid
* @param transport_id
* @return Result
*/
public Result pay(
String uuid,
String transport_id,
Integer ordercluster_id,
String driver_name,
String driver_phone,
String memo,
String printerId,
Sysuser sysuser
) {
Transport transport = Transport.dao.findById(transport_id);
if (transport == null) {
return Result.failed("进出场记录不能为空");
}
if (transport.getState() >= OrderStateEnum.RECEIVED.getStateid()) {
return Result.failed("进出场记录以完成,或者已经被取消,不能使用");
}
if (Truck.dao.findById(transport.getTruckLicense()) == null) {
return Result.failedstr("【%s】不是物流公司车辆", transport.getTruckLicense());
}
Ordercluster ordercluster = Ordercluster.dao.findById(ordercluster_id);
if (ordercluster == null) {
return Result.failedstr("集团订单【%s】信息不存在", ordercluster_id);
}
Customer customer = Customer.dao.findById(ordercluster.getCustomerId());
if (customer == null) {
return Result.failedstr("集团订单关联客户信息【%s】信息不存在", ordercluster.getCustomerId());
}
if (ordercluster.getState() == OrderStateEnum.INVALID.getStateid()) {
return Result.failedstr("集团订单【%s】已完结请重新下单", ordercluster_id);
}
if (ordercluster.getTransCoId() == null) {
return Result.failedstr("集团订单【%s】没有配置有效的物流公司", ordercluster_id);
}
BigDecimal up = CustomerSupermarketProductService.me.getUnitPrice(customer.getId(), transport.getSupermarketId(), ordercluster.getProductId());
if (up == null) {
return Result.failedstr("未查到有效的单价信息");
}
OrderSale order = new OrderSale();
order.setUuid(uuid);
if (order.checkDuplicate("uuid")) {
return Result.failed("【%s】已经存在", uuid);
}
BigDecimal min = new BigDecimal("0.001");
Date now = new Date();
SyncTask synctask = new SyncTask();
// 验证重量
if (transport.getFirstWeight() == null
|| transport.getSecondWeight() == null
|| transport.getFirstWeight().compareTo(min) < 0
|| transport.getSecondWeight().compareTo(min) < 0
|| transport.getSecondWeight().subtract(transport.getFirstWeight()).doubleValue() <= 0 // 销售订单 第一重量要比第二次重量小, 即 毛重 > 皮重
) {
return Result.failedstr("重量数据有误,第一次称重:%.4f,第二次称重:%.4f", transport.getFirstWeight(), transport.getSecondWeight());
}
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次
order.setTransportId(transport.getId());
order.setSupermarketId(transport.getSupermarketId());
order.setTruckLicense(transport.getTruckLicense());
// 运输信息
order.setProductId(ordercluster.getProductId());
order.setProductName(ordercluster.getProductName());
order.setTransDistance(ordercluster.getTransDistance());
order.setTransUnitPrice(BigDecimal.valueOf(TransPriceService.me.getOrderStartTransPrice(ordercluster.getTransCoId(), order.getTransDistance().doubleValue())));
// 支付时,用净重计算运费
order.setTransPrice(BigDecimal.valueOf(TransPriceService.me.caleOrderTransPrice(ordercluster.getTransCoId(), net_weight.doubleValue(), order.getTransDistance().doubleValue())));
order.setDriverName(driver_name);
order.setDriverPhone(driver_phone);
order.setPickTime(ordercluster.getCutoffTime()); // 集团订单的截止时间
// 支付信息
order.setUnitPrice(up);
order.setWeight(net_weight); // 使用净重更新重量
order.setTotalPrice(TransPriceService.me.caleTotalPrice(up, net_weight)); // 获取根据净重和单价计算的总价,作为应付金额
order.setPaid(order.getTotalPrice()); // 如果有预付费,该字段根据预付费情况设置。实付金额
order.setPayType(ordercluster.getPayType());
order.setReqReceipt(ordercluster.getReqReceipt());
order.setOrderclusterId(ordercluster_id);
// 客户信息
order.setCustomerId(customer.getId());
order.setCustomerAddress(customer.getAddress());
order.setCustomerBankAccount(customer.getBankAccount());
order.setCustomerBankName(customer.getBankName());
order.setCustomerName(customer.getName());
order.setCustomerPhone(customer.getPhone());
order.setCustomerTexpayerName(customer.getTexpayerName());
order.setCustomerTexpayerNum(customer.getTexpayerNum());
// 客户收货信息
order.setCustomerReceiverName(ordercluster.getCustomerReceiverName());
order.setCustomerReceiverPhone(ordercluster.getCustomerReceiverPhone());
order.setCustomerReceiverAddress(ordercluster.getCustomerReceiverAddress());
order.setCustomerReceiverLgtd(ordercluster.getCustomerReceiverLgtd());
order.setCustomerReceiverLttd(ordercluster.getCustomerReceiverLttd());
// 物流公司信息
order.setTransCoId(ordercluster.getTransCoId());
order.setTransCoAddress(ordercluster.getTransCoAddress());
order.setTransCoBankAccount(ordercluster.getTransCoBankAccount());
order.setTransCoBankName(ordercluster.getTransCoBankName());
order.setTransCoName(ordercluster.getTransCoName());
order.setTransCoPhone(ordercluster.getTransCoPhone());
order.setTransCoTexpayerName(ordercluster.getTransCoTexpayerName());
order.setTransCoTexpayerNum(ordercluster.getTransCoTexpayerNum());
order.setCreateUserId(ordercluster.getCreateUserId());
order.setCreateUserName(ordercluster.getCreateUserName());
order.setSettlementUserId(sysuser.getId());
order.setSettlementUserName(sysuser.getName());
order.setState(OrderStateEnum.RECEIVED.getStateid()); // 直接完成,没有前面的过程
order.setCreateTime(now);
order.setMemo(memo); // 备注
// 更新 transport 出入场信息
transport.setTransCoId(ordercluster.getTransCoId());
transport.setTransCoAddress(ordercluster.getTransCoAddress());
transport.setTransCoBankAccount(ordercluster.getTransCoBankAccount());
transport.setTransCoBankName(ordercluster.getTransCoBankName());
transport.setTransCoName(ordercluster.getTransCoName());
transport.setTransCoPhone(ordercluster.getTransCoPhone());
transport.setTransCoTexpayerName(ordercluster.getTransCoTexpayerName());
transport.setTransCoTexpayerNum(ordercluster.getTransCoTexpayerNum());
transport.setState(OrderStateEnum.RECEIVED.getStateid()); // 标记 transport state 为 5 ,表示出入场记录完成
transport.setArriveTime(now);
transport.setType(OrderTypeEnum.SALE.getTypeid());
boolean ret = Db.tx(new IAtom() {
@Override
public boolean run() {
try {
boolean ret = false;
order.setSn(OrderSeqService.me.getNextSn(transport.getSupermarketId(), OrderTypeEnum.SALE.getTypeid()));
transport.setOrderSn(order.getSn());
ret = order.save() && transport.update();
if (!ret) {
return false;
}
Stock stock = Stock.dao.findByIds(transport.getSupermarketId(), order.getProductId());
if (stock == null) {
log.error("未找到库存信息 %s, %s", order.getSupermarketId(), order.getProductId());
return false;
}
stock.setStockWeight(stock.getStockWeight().subtract(net_weight)); // 销售减库存
ret = stock.update();
if (!ret) {
return false;
}
// 在这里更新sn字段之后存入
synctask.addSaveData(order);
synctask.addUpdateData(transport);
synctask.addUpdateData(stock);
return SyncTaskService.me.save(synctask);
} catch (Exception e) {
log.error(e.getMessage(), e);
return false;
}
}
});
if (ret) {
SyncTaskService.me.send(synctask);
}
return LocalOrderService.me.orderPayComplete(ret, order.toRecord(), transport, printerId);
}
public Result prepay(
String uuid,
String transport_id,
Integer ordercluster_id,
String driver_name,
String driver_phone,
String memo,
String printerId,
Sysuser sysuser
) {
BigDecimal min = new BigDecimal(0);
Transport transport = Transport.dao.findById(transport_id);
if (transport == null) {
return Result.failed("进出场记录不能为空");
}
if (transport.getState() >= OrderStateEnum.RECEIVED.getStateid()) {
return Result.failed("进出场记录以完成,或者已经被取消,不能使用");
}
if (Truck.dao.findById(transport.getTruckLicense()) == null) {
return Result.failedstr("【%s】不是物流公司车辆", transport.getTruckLicense());
}
Ordercluster ordercluster = Ordercluster.dao.findById(ordercluster_id);
if (ordercluster == null) {
return Result.failedstr("集团订单【%s】信息不存在", ordercluster_id);
}
Customer customer = Customer.dao.findById(ordercluster.getCustomerId());
if (customer == null) {
return Result.failedstr("集团订单关联客户信息【%s】信息不存在", ordercluster.getCustomerId());
}
if (customer.getType() != 1) {
return Result.failed("不是预付费客户");
}
if (ordercluster.getState() == OrderStateEnum.INVALID.getStateid()) {
return Result.failedstr("集团订单【%s】已完结请重新下单", ordercluster_id);
}
if (ordercluster.getTransCoId() == null) {
return Result.failedstr("集团订单【%s】没有配置有效的物流公司", ordercluster_id);
}
PrepayCustomer prepayCustomer = PrepayCustomerService.me.getPrepayCustomer(customer.getId());
if (prepayCustomer == null) {
return Result.failed("没有找到客户预付费信息");
}
if (prepayCustomer.getSurplus() == null || prepayCustomer.getSurplus().compareTo(min) == 0) {
return Result.failed("客户余额不足");
}
PrepayTruck pt = PrepayTruck.dao.findFirst("select * from prepay_truck t \n" +
" where t.supermarket_id = ? \n" +
" and t.truck_license = ? \n" +
" and t.valid_date = ? ",
transport.getSupermarketId(),
transport.getTruckLicense(),
DateTimeUtil.sdf.get().format(transport.getInTime())
);
if (pt == null) {
return Result.failedstr("【%s】不是今日预付费车辆", transport.getTruckLicense());
}
if (pt.getType() != OrderTypeEnum.SALE.getTypeid()) {
return Result.failedstr("【%s】不是配送预付费车辆", transport.getTruckLicense());
}
BigDecimal up = CustomerSupermarketProductService.me.getUnitPrice(customer.getId(), transport.getSupermarketId(), ordercluster.getProductId());
if (up == null) {
return Result.failedstr("未查到有效的单价信息");
}
OrderSale order = new OrderSale();
order.setUuid(uuid);
if (order.checkDuplicate("uuid")) {
return Result.failed("【%s】已经存在", uuid);
}
Date now = new Date();
SyncTask synctask = new SyncTask();
// 验证重量
if (transport.getFirstWeight() == null
|| transport.getSecondWeight() == null
|| transport.getFirstWeight().compareTo(min) < 0
|| transport.getSecondWeight().compareTo(min) < 0
|| transport.getSecondWeight().subtract(transport.getFirstWeight()).doubleValue() <= 0 // 销售订单 第一重量要比第二次重量小, 即 毛重 > 皮重
) {
return Result.failedstr("重量数据有误,第一次称重:%.4f,第二次称重:%.4f", transport.getFirstWeight(), transport.getSecondWeight());
}
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次
order.setTransportId(transport.getId());
order.setSupermarketId(transport.getSupermarketId());
order.setTruckLicense(transport.getTruckLicense());
// 运输信息
order.setProductId(ordercluster.getProductId());
order.setProductName(ordercluster.getProductName());
order.setTransDistance(ordercluster.getTransDistance());
order.setTransUnitPrice(BigDecimal.valueOf(TransPriceService.me.getOrderStartTransPrice(ordercluster.getTransCoId(), order.getTransDistance().doubleValue())));
// 支付时,用净重计算运费
order.setTransPrice(BigDecimal.valueOf(TransPriceService.me.caleOrderTransPrice(ordercluster.getTransCoId(), net_weight.doubleValue(), order.getTransDistance().doubleValue())));
order.setDriverName(driver_name);
order.setDriverPhone(driver_phone);
order.setPickTime(ordercluster.getCutoffTime()); // 集团订单的截止时间
// 支付信息
order.setUnitPrice(up);
order.setWeight(net_weight); // 使用净重更新重量
order.setTotalPrice(TransPriceService.me.caleTotalPrice(up, net_weight)); // 获取根据净重和单价计算的总价,作为应付金额
order.setPaid(order.getTotalPrice()); // 如果有预付费,该字段根据预付费情况设置。实付金额
order.setPayType(ordercluster.getPayType());
order.setReqReceipt(ordercluster.getReqReceipt());
order.setOrderclusterId(ordercluster_id);
// 客户信息
order.setCustomerId(customer.getId());
order.setCustomerAddress(customer.getAddress());
order.setCustomerBankAccount(customer.getBankAccount());
order.setCustomerBankName(customer.getBankName());
order.setCustomerName(customer.getName());
order.setCustomerPhone(customer.getPhone());
order.setCustomerTexpayerName(customer.getTexpayerName());
order.setCustomerTexpayerNum(customer.getTexpayerNum());
// 客户收货信息
order.setCustomerReceiverName(ordercluster.getCustomerReceiverName());
order.setCustomerReceiverPhone(ordercluster.getCustomerReceiverPhone());
order.setCustomerReceiverAddress(ordercluster.getCustomerReceiverAddress());
order.setCustomerReceiverLgtd(ordercluster.getCustomerReceiverLgtd());
order.setCustomerReceiverLttd(ordercluster.getCustomerReceiverLttd());
// 物流公司信息
order.setTransCoId(ordercluster.getTransCoId());
order.setTransCoAddress(ordercluster.getTransCoAddress());
order.setTransCoBankAccount(ordercluster.getTransCoBankAccount());
order.setTransCoBankName(ordercluster.getTransCoBankName());
order.setTransCoName(ordercluster.getTransCoName());
order.setTransCoPhone(ordercluster.getTransCoPhone());
order.setTransCoTexpayerName(ordercluster.getTransCoTexpayerName());
order.setTransCoTexpayerNum(ordercluster.getTransCoTexpayerNum());
order.setCreateUserId(ordercluster.getCreateUserId());
order.setCreateUserName(ordercluster.getCreateUserName());
order.setSettlementUserId(sysuser.getId());
order.setSettlementUserName(sysuser.getName());
order.setState(OrderStateEnum.RECEIVED.getStateid()); // 直接完成,没有前面的过程
order.setCreateTime(now);
order.setMemo(memo); // 备注
// 更新 transport 出入场信息
transport.setTransCoId(ordercluster.getTransCoId());
transport.setTransCoAddress(ordercluster.getTransCoAddress());
transport.setTransCoBankAccount(ordercluster.getTransCoBankAccount());
transport.setTransCoBankName(ordercluster.getTransCoBankName());
transport.setTransCoName(ordercluster.getTransCoName());
transport.setTransCoPhone(ordercluster.getTransCoPhone());
transport.setTransCoTexpayerName(ordercluster.getTransCoTexpayerName());
transport.setTransCoTexpayerNum(ordercluster.getTransCoTexpayerNum());
transport.setState(OrderStateEnum.RECEIVED.getStateid()); // 标记 transport state 为 5 ,表示出入场记录完成
transport.setArriveTime(now);
transport.setType(OrderTypeEnum.SALE.getTypeid());
boolean ret = Db.tx(new IAtom() {
@Override
public boolean run() {
try {
boolean ret = false;
order.setSn(OrderSeqService.me.getNextSn(transport.getSupermarketId(), OrderTypeEnum.SALE.getTypeid()));
transport.setOrderSn(order.getSn());
// 是预付费用户,并且还有余额
order.setIsprepaid(1);
order.setPaid(new BigDecimal(0)); // 预付费的实际支付为 0
order.setPrepayCustomerId(prepayCustomer.getId());
prepayCustomer.setSpendTime(now);
if (prepayCustomer.getSurplus().compareTo(order.getTotalPrice()) > -1) {
prepayCustomer.setSurplus(prepayCustomer.getSurplus().subtract(order.getTotalPrice()));
} else {
// 对于支付的差额,算作一次即充即用的预付费充值
prepayCustomer.setSurplus(new BigDecimal(0));
String paidmemo = "现场补足预付金额:" + order.getPaid().intValue() + "元";
if (StrKit.isBlank(order.getMemo())) {
order.setMemo(paidmemo);
} else {
order.setMemo(order.getMemo() + "。" + paidmemo);
}
PrepayDetail pd = new PrepayDetail();
pd.setId(StrKit.getRandomUUID());
pd.setCustomerId(order.getCustomerId());
pd.setSupermarketId(order.getSupermarketId());
pd.setAmount(order.getTotalPrice().subtract(prepayCustomer.getSurplus())); // 订单总价减去余额,就是本次补的差价
pd.setType(2);
pd.setContactName("");
pd.setContactPhone("");
pd.setBankName("");
pd.setSerialnum("");
pd.setState(2);
pd.setChangeTime(now);
pd.setCreateTime(now);
pd.setVerifyTime(now);
ret = pd.save();
if (!ret) {
return false;
}
synctask.addSaveData(pd);
PrepayDetailStateHistory his = new PrepayDetailStateHistory();
his.setId(StrKit.getRandomUUID());
his.setPrepayDetailId(pd.getId());
his.setChangeUserId(sysuser.getId());
his.setChangeUserName(sysuser.getName());
his.setState(1);
his.setChangeTime(now);
his.setMemo(paidmemo);
ret = his.save();
if (!ret) {
return false;
}
synctask.addSaveData(his);
his = new PrepayDetailStateHistory();
his.setId(StrKit.getRandomUUID());
his.setPrepayDetailId(pd.getId());
his.setChangeUserId(sysuser.getId());
his.setChangeUserName(sysuser.getName());
his.setState(2);
his.setChangeTime(now);
his.setMemo(paidmemo);
ret = his.save();
if (!ret) {
return false;
}
synctask.addSaveData(his);
}
synctask.addUpdateData(prepayCustomer);
ret = prepayCustomer.update();
if (!ret) {
return false;
}
ret = order.save() && transport.update();
if (!ret) {
return false;
}
Stock stock = Stock.dao.findByIds(transport.getSupermarketId(), order.getProductId());
if (stock == null) {
log.error("未找到库存信息 %s, %s", order.getSupermarketId(), order.getProductId());
return false;
}
stock.setStockWeight(stock.getStockWeight().subtract(net_weight)); // 销售减库存
ret = stock.update();
if (!ret) {
return false;
}
// 在这里更新sn字段之后存入
synctask.addSaveData(order);
synctask.addUpdateData(transport);
synctask.addUpdateData(stock);
return SyncTaskService.me.save(synctask);
} catch (Exception e) {
log.error(e.getMessage(), e);
return false;
}
}
});
if (ret) {
SyncTaskService.me.send(synctask);
}
return LocalOrderService.me.orderPayComplete(ret, order.toRecord(), transport, printerId);
}
public Result cancel(String sn, Sysuser sysuser, String password) {
// TODO: 判断权限
OrderSale order = OrderSale.dao.findById(sn);
if (order == null) {
return Result.failedstr("按订单号【%s】未找到记录", sn);
}
int orderstate = order.getState();
// 订单已经完成
if (orderstate == OrderStateEnum.RECEIVED.getStateid()) {
// 已完成订单,再删除时需要重新验证密码
Sysuser chkuser = SysuserSyncService.me.getUserByWhere(null, sysuser.getPhone(), password);
if (chkuser == null) {
log.debug("用户输入密码错误");
return Result.permissionDenied();
}
}
if (orderstate == OrderStateEnum.INVALID.getStateid()) {
return Result.failed("订单已经取消");
}
order.setState(OrderStateEnum.INVALID.getStateid()); // 将订单状态置为 9
SyncTask synctask = new SyncTask();
Record logrecord = new Record();
logrecord.set("sn", sn);
logrecord.set("state", OrderStateEnum.INVALID.getStateid());
boolean ret = Db.tx(new IAtom() {
@Override
public boolean run() {
try {
synctask.addUpdateData(order);
boolean ret = order.update()
&& ModifyLogSyncService.me.save(order.tablename, "sn", logrecord.toJson(), Enums.DataOpType.UPDATE.getId(), sysuser);
if (!ret) {
return false;
}
// 是集团客户订单
if (order.getOrderclusterId() != null) {
Ordercluster ordercluster = Ordercluster.dao.findById(order.getOrderclusterId());
if (ordercluster == null) {
log.error("关联集团订单信息未找到ordercluster_id:【%s】", order.getOrderclusterId());
return false;
}
}
// 是预付费订单
if (order.getIsprepaid() == 1) {
Customer customer = Customer.dao.findById(order.getCustomerId());
if (customer == null) {
log.error("关联预付费客户信息未找到customer_id:【%s】", order.getCustomerId());
return false;
}
PrepayCustomer prepayCustomer = PrepayCustomerService.me.getPrepayCustomer(customer.getId());
if (prepayCustomer != null) {
if (prepayCustomer.getSurplus() == null) {
prepayCustomer.setSurplus(order.getTotalPrice());
} else {
prepayCustomer.setSurplus(prepayCustomer.getSurplus().add(order.getTotalPrice()));
}
synctask.addUpdateData(prepayCustomer);
ret = prepayCustomer.update();
}
}
if (!ret) {
return false;
}
Stock stock = Stock.dao.findByIds(order.getSupermarketId(), order.getProductId());
if (stock == null) {
log.error("未找到库存信息 %s, %s", order.getSupermarketId(), order.getProductId());
return false;
}
stock.setStockWeight(stock.getStockWeight().add(order.getWeight())); // 取消销售订单,增加库存
ret = stock.update();
synctask.addUpdateData(stock);
return ret && SyncTaskService.me.save(synctask);
} catch (Exception e) {
log.error(e.getMessage(), e);
return false;
}
}
});
if (ret) {
SyncTaskService.me.send(synctask);
}
return ret ? Result.success(order) : Result.failed("取消失败");
}
}

View File

@ -13,7 +13,6 @@ import com.cowr.ssjygl.invoice.receive.InvoiceReceiveService;
import com.cowr.ssjygl.order.OrderService; import com.cowr.ssjygl.order.OrderService;
import com.cowr.ssjygl.order.ordercluster.OrderclusterService; import com.cowr.ssjygl.order.ordercluster.OrderclusterService;
import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService; import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService;
import com.cowr.ssjygl.order.ordersale.OrderSaleService;
import com.cowr.ssjygl.order.ordertemp.OrderTempService; import com.cowr.ssjygl.order.ordertemp.OrderTempService;
import com.cowr.ssjygl.prepay.PrepayService; import com.cowr.ssjygl.prepay.PrepayService;
import com.cowr.ssjygl.supermarket.product.SupermarketProductService; import com.cowr.ssjygl.supermarket.product.SupermarketProductService;
@ -272,11 +271,6 @@ public class TransportQueryService {
" p.trans_co_phone, p.trans_co_bank_name, p.trans_co_bank_account, " + " p.trans_co_phone, p.trans_co_bank_name, p.trans_co_bank_account, " +
" s.name supermarket_name from (\n" + " s.name supermarket_name from (\n" +
" select t.sn, truck_license, t.weight, t.total_price, t.unit_price, t.product_id, t.product_name, t.create_time, t.state \n" + " select t.sn, truck_license, t.weight, t.total_price, t.unit_price, t.product_id, t.product_name, t.create_time, t.state \n" +
" from order_sale t \n" +
" where t.state = ? \n" +
" and t.supermarket_id = ? \n" +
" union\n" +
" select t.sn, truck_license, t.weight, t.total_price, t.unit_price, t.product_id, t.product_name, t.create_time, t.state \n" +
" from order_temp t \n" + " from order_temp t \n" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.supermarket_id = ? \n" + " and t.supermarket_id = ? \n" +
@ -288,8 +282,6 @@ public class TransportQueryService {
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
paraList.add(OrderStateEnum.LEAVE.getStateid()); // 这里用这个状态标记等等结算 paraList.add(OrderStateEnum.LEAVE.getStateid()); // 这里用这个状态标记等等结算
paraList.add(supermarket_id); paraList.add(supermarket_id);
paraList.add(OrderStateEnum.LEAVE.getStateid()); // 这里用这个状态标记等等结算
paraList.add(supermarket_id);
paraList.add(which); paraList.add(which);
if (StrKit.notBlank(truck_license)) { if (StrKit.notBlank(truck_license)) {
@ -335,11 +327,6 @@ public class TransportQueryService {
" p.trans_co_phone, p.trans_co_bank_name, p.trans_co_bank_account, " + " p.trans_co_phone, p.trans_co_bank_name, p.trans_co_bank_account, " +
" s.name supermarket_name from (\n" + " s.name supermarket_name from (\n" +
" select t.sn, truck_license, t.weight, t.total_price, t.unit_price, t.product_id, t.product_name, t.create_time, t.state \n" + " select t.sn, truck_license, t.weight, t.total_price, t.unit_price, t.product_id, t.product_name, t.create_time, t.state \n" +
" from order_sale t \n" +
" where t.state = ? \n" +
" and t.supermarket_id = ? \n" +
" union\n" +
" select t.sn, truck_license, t.weight, t.total_price, t.unit_price, t.product_id, t.product_name, t.create_time, t.state \n" +
" from order_temp t \n" + " from order_temp t \n" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.supermarket_id = ? \n" + " and t.supermarket_id = ? \n" +
@ -351,8 +338,6 @@ public class TransportQueryService {
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
paraList.add(OrderStateEnum.LEAVE.getStateid()); // 这里用这个状态标记等等结算 paraList.add(OrderStateEnum.LEAVE.getStateid()); // 这里用这个状态标记等等结算
paraList.add(supermarket_id); paraList.add(supermarket_id);
paraList.add(OrderStateEnum.LEAVE.getStateid()); // 这里用这个状态标记等等结算
paraList.add(supermarket_id);
paraList.add(which); paraList.add(which);
sql += " order by a.create_time desc "; // 按最后更新时间排序 sql += " order by a.create_time desc "; // 按最后更新时间排序
@ -424,9 +409,7 @@ public class TransportQueryService {
Record snorder = null; Record snorder = null;
int sntype = Integer.parseInt(order_sn.substring(10, 12)); int sntype = Integer.parseInt(order_sn.substring(10, 12));
if (sntype == OrderTypeEnum.SALE.getTypeid()) { if (sntype == OrderTypeEnum.TEMP.getTypeid()) {
snorder = OrderSaleService.me.get(order_sn);
} else if (sntype == OrderTypeEnum.TEMP.getTypeid()) {
snorder = OrderTempService.me.get(order_sn); snorder = OrderTempService.me.get(order_sn);
} }

View File

@ -27,7 +27,6 @@ import com.cowr.service.ssjygl.order.invalidverify.OrderInvalidVerifyController;
import com.cowr.service.ssjygl.order.ordercluster.OrderclusterController; import com.cowr.service.ssjygl.order.ordercluster.OrderclusterController;
import com.cowr.service.ssjygl.order.ordercluster.truck.OrderclusterTruckController; import com.cowr.service.ssjygl.order.ordercluster.truck.OrderclusterTruckController;
import com.cowr.service.ssjygl.order.orderpurchase.OrderPurchaseController; import com.cowr.service.ssjygl.order.orderpurchase.OrderPurchaseController;
import com.cowr.service.ssjygl.order.ordersale.OrderSaleController;
import com.cowr.service.ssjygl.order.ordertemp.OrderTempController; import com.cowr.service.ssjygl.order.ordertemp.OrderTempController;
import com.cowr.service.ssjygl.order.ordertransfer.OrderTransferController; import com.cowr.service.ssjygl.order.ordertransfer.OrderTransferController;
import com.cowr.service.ssjygl.order.ordertrash.OrderTrashController; import com.cowr.service.ssjygl.order.ordertrash.OrderTrashController;
@ -198,7 +197,6 @@ public class Config extends JFinalConfig {
// -- 订单相关 // -- 订单相关
me.add("/order/ordercluster", OrderclusterController.class); me.add("/order/ordercluster", OrderclusterController.class);
me.add("/order/sale", OrderSaleController.class);
me.add("/order/temp", OrderTempController.class); me.add("/order/temp", OrderTempController.class);
me.add("/order/transfer", OrderTransferController.class); me.add("/order/transfer", OrderTransferController.class);
me.add("/order/trash", OrderTrashController.class); me.add("/order/trash", OrderTrashController.class);

View File

@ -1,48 +0,0 @@
package com.cowr.service.ssjygl.order.ordersale;
import com.cowr.common.base.BaseController;
import com.cowr.common.enums.UserTypeEnum;
import com.cowr.common.view.PageParam;
import com.cowr.common.view.Result;
import com.cowr.model.Sysuser;
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
import com.cowr.ssjygl.order.ordersale.OrderSalePKValidator;
import com.cowr.ssjygl.order.ordersale.OrderSaleService;
import com.jfinal.aop.Before;
public class OrderSaleController extends BaseController {
@Before(OrderSalePKValidator.class)
public void get() {
renderJson(Result.object(OrderSaleService.me.get(get("sn"))));
}
/**
* order_sale
*/
public void find() {
PageParam pp = getBean(PageParam.class, "", true);
String stm = get("stm");
String etm = get("etm");
String truck_license = getUpperCaseVal("truck_license");
String customer_name = get("customer_name");
String sn = get("sn");
Integer state = getInt("state");
Integer product_id = getInt("product_id");
Integer supermarket_id = getInt("supermarket_id");
Integer trans_co_id = getInt("trans_co_id");
Integer isprepaid = getInt("isprepaid");
Integer customer_id = getInt("customer_id");
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
// 是客户账户
if (tokenuser == null) {
renderJson(Result.noauth());
return;
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
customer_id = tokenuser.getEntityId();
}
renderJson(Result.object(OrderSaleService.me.find(pp, sn, truck_license, supermarket_id, trans_co_id, customer_id, customer_name, stm, etm, isprepaid, state, product_id)));
}
}