各统计接口修改,将巴河两个站的数据统计在一起
parent
8a9aa6af7d
commit
5d4c1cec7d
|
|
@ -536,24 +536,16 @@ public class OrderStatService {
|
|||
|
||||
addTm(tm, params);
|
||||
|
||||
// params.add(tm + "%");
|
||||
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
saleParams += " and t.sale_type = ? \n";
|
||||
params.add(sale_type);
|
||||
}else {
|
||||
// saleParams += " and t.sale_type = 0 \n";
|
||||
}
|
||||
|
||||
// if (type != null){
|
||||
// saleParams += " and s.type = ? \n";
|
||||
// params.add(type);
|
||||
// }
|
||||
|
||||
params.addAll(params);
|
||||
//2025-03-06更改,解决砂站商品删除后月统计数据查询不到问题
|
||||
String selectSql = "select s.id, s.name, s.name2, p.id product_id, p.`name` product_name, ifnull(a.orderCount, 0) as orderCount, ifnull(a.totalPrice, 0) as totalPrice, ifnull(a.weight, 0) as weight\n" +
|
||||
" from supermarket_product t\n";
|
||||
String commonSql = "select t.id, t.product_id, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" +
|
||||
" from (select case when supermarket_id in (4,5) then 4 else supermarket_id end as supermarket_id,product_id,unit_price from supermarket_product ) t\n";
|
||||
String commonSql = "select case when t.id in (4,5) then 4 else t.id end as id, t.product_id, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" +
|
||||
" from (\n" +
|
||||
" select t.supermarket_id as id, t.paid, t.total_price, t.weight, t.product_id\n" +
|
||||
" from order_temp t\n" +
|
||||
|
|
@ -561,7 +553,7 @@ public class OrderStatService {
|
|||
" and t.create_time between ? and ? \n" +
|
||||
saleParams +
|
||||
" ) t\n" +
|
||||
" group by t.id, t.product_id\n";
|
||||
" group by case when t.id in (4,5) then 4 else t.id end, t.product_id\n";
|
||||
|
||||
String sql = "select m.* from (" + selectSql + "left join (\n" + commonSql + " ) a on a.id = t.supermarket_id and a.product_id = t.product_id\n" +
|
||||
" left join supermarket s on s.id = t.supermarket_id\n" +
|
||||
|
|
@ -625,7 +617,7 @@ public class OrderStatService {
|
|||
public Record salestat1(String stm,String etm) {
|
||||
|
||||
List<Record> sups = Db.find("select t.* from supermarket t \n" +
|
||||
" where t.type = 0");
|
||||
" where t.type = 0 and t.id != 5");
|
||||
|
||||
if(sups == null || sups.isEmpty()){
|
||||
return null;
|
||||
|
|
@ -1248,11 +1240,10 @@ public class OrderStatService {
|
|||
String productParams = "";
|
||||
|
||||
if (supermarket_id != null && supermarket_id > 0) {
|
||||
if (6 == supermarket_id){
|
||||
productParams += " and (t.supermarket_id = ? OR t.supermarket_id = ? OR t.supermarket_id = ?)\n";
|
||||
paramsArray.add(6);
|
||||
paramsArray.add(8);
|
||||
paramsArray.add(10);
|
||||
if (4 == supermarket_id){
|
||||
productParams += " and (t.supermarket_id = ? OR t.supermarket_id = ? )\n";
|
||||
paramsArray.add(4);
|
||||
paramsArray.add(5);
|
||||
}else{
|
||||
productParams += " and t.supermarket_id = ?\n";
|
||||
paramsArray.add(supermarket_id);
|
||||
|
|
@ -1641,10 +1632,15 @@ public class OrderStatService {
|
|||
}
|
||||
|
||||
if (supermarket_id != null) {
|
||||
if(supermarket_id == 4){
|
||||
temp_sql += " and t.supermarket_id in (4,5) \n";
|
||||
}else{
|
||||
temp_sql += " and t.supermarket_id = ? \n";
|
||||
paraList.add(supermarket_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (customer_id != null) {
|
||||
temp_sql += " and t.customer_id = ? \n";
|
||||
paraList.add(customer_id);
|
||||
|
|
@ -1956,25 +1952,25 @@ public class OrderStatService {
|
|||
}
|
||||
list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight ,a.product_id,a.product_name from supermarket s\n" +
|
||||
"left join (\n" +
|
||||
" select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name \n" +
|
||||
" select case when t.supermarket_id in (4,5) then 4 else t.supermarket_id end as id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name \n" +
|
||||
" from order_temp t\n" +
|
||||
" where t.state = 5\n" +
|
||||
saleParam +
|
||||
" and t.create_time >= ? \n" +
|
||||
" and t.create_time <= ? \n" +
|
||||
paramsSql +
|
||||
" group by t.supermarket_id,t.product_id,t.product_name\n" +
|
||||
" group by case when t.supermarket_id in (4,5) then 4 else t.supermarket_id end,t.product_id,t.product_name\n" +
|
||||
") a on s.id = a.id where s.type = 0 order by s.id", paramsArray.toArray());
|
||||
} else {
|
||||
list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight from supermarket s\n" +
|
||||
"left join (\n" +
|
||||
" select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight \n" +
|
||||
" select case when t.supermarket_id in (4,5) then 4 else t.supermarket_id end as id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight \n" +
|
||||
" from order_temp t\n" +
|
||||
" where t.state = 5\n" +
|
||||
saleParam +
|
||||
" and t.create_time >= ? \n" +
|
||||
" and t.create_time <= ? \n" +
|
||||
" group by t.supermarket_id\n" +
|
||||
" group by case when t.supermarket_id in (4,5) then 4 else t.supermarket_id end\n" +
|
||||
") a on s.id = a.id where s.type = 0 order by s.id", paramsArray.toArray());
|
||||
}
|
||||
|
||||
|
|
@ -2966,7 +2962,7 @@ public class OrderStatService {
|
|||
|
||||
List<Record> sups = Db.find("select t.*, s.yield from supermarket t \n" +
|
||||
" left join supermarket_yield s on s.supermarket_id = t.id and s.year = ? \n" +
|
||||
" where t.type = 0", year);
|
||||
" where t.type = 0 and t.id != 5", year);
|
||||
|
||||
String paramsSql = "";
|
||||
String saleParam = "";
|
||||
|
|
@ -2985,6 +2981,8 @@ public class OrderStatService {
|
|||
" ifnull( sum( g.total_price ), 0 ) total_price,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 1 THEN g.weight END ), 0 ) xsl_1,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 1 THEN g.total_price END ), 0 ) xse_1\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id in (4,5) THEN g.weight END ), 0 ) xsl_4,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id in (4,5) THEN g.total_price END ), 0 ) xse_4\n" +
|
||||
"FROM\n" +
|
||||
" (\n" +
|
||||
" SELECT\n" +
|
||||
|
|
@ -3170,6 +3168,8 @@ public class OrderStatService {
|
|||
double all_total_price = 0.0;
|
||||
double all_xsl_1 = 0.0;
|
||||
double all_xse_1 = 0.0;
|
||||
double all_xsl_4 = 0.0;
|
||||
double all_xse_4 = 0.0;
|
||||
|
||||
for (Record record : typelist) {
|
||||
Integer customer_type_id = record.getInt("customer_type_id");
|
||||
|
|
@ -3185,6 +3185,8 @@ public class OrderStatService {
|
|||
double total_price = 0.0;
|
||||
double xsl_1 = 0.0;
|
||||
double xse_1 = 0.0;
|
||||
double xsl_4 = 0.0;
|
||||
double xse_4 = 0.0;
|
||||
|
||||
for (Record r : list) {
|
||||
prepay_total_amount += DataUtil.getDefaultByRecord(r, "prepay_total_amount");
|
||||
|
|
@ -3202,6 +3204,8 @@ public class OrderStatService {
|
|||
all_total_price += DataUtil.getDefaultByRecord(r, "total_price");
|
||||
all_xsl_1 += DataUtil.getDefaultByRecord(r, "xsl_1");
|
||||
all_xse_1 += DataUtil.getDefaultByRecord(r, "xse_1");
|
||||
all_xsl_4 += DataUtil.getDefaultByRecord(r, "xsl_4");
|
||||
all_xse_4 += DataUtil.getDefaultByRecord(r, "xse_4");
|
||||
}
|
||||
|
||||
record.set("prepay_total_amount", prepay_total_amount);
|
||||
|
|
@ -3211,6 +3215,8 @@ public class OrderStatService {
|
|||
record.set("total_price", total_price);
|
||||
record.set("xsl_1", xsl_1);
|
||||
record.set("xse_1", xse_1);
|
||||
record.set("xsl_4", xsl_4);
|
||||
record.set("xse_4", xse_4);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3229,6 +3235,8 @@ public class OrderStatService {
|
|||
record.set("total_price", all_total_price);
|
||||
record.set("xsl_1", all_xsl_1);
|
||||
record.set("xse_1", all_xse_1);
|
||||
record.set("xsl_4", all_xsl_4);
|
||||
record.set("xse_4", all_xse_4);
|
||||
|
||||
typelist.add(record);
|
||||
|
||||
|
|
@ -4483,15 +4491,6 @@ public class OrderStatService {
|
|||
* @return
|
||||
*/
|
||||
public List<Record> statYearBySup1(String tm) {
|
||||
// 砂站
|
||||
List<Record> sups = Db.find("SELECT\n" +
|
||||
" t.id,\n" +
|
||||
" t.`name`\n" +
|
||||
"FROM\n" +
|
||||
" supermarket t\n"
|
||||
+ "WHERE\n" +
|
||||
"t.type = 0 "
|
||||
);
|
||||
|
||||
List<Object> shParamsList = new ArrayList<>();
|
||||
List<Object> yhParamsList = new ArrayList<>();
|
||||
|
|
@ -4575,9 +4574,7 @@ public class OrderStatService {
|
|||
private String getSaleSql(String params,Integer saleType){
|
||||
return "select s.id, s.name, p.id product_id, p.`name` product_name, ifnull(a.orderCount, 0) as order_num, ifnull(a.totalPrice, 0) as total_price, ifnull(a.weight, 0) as weight\n" +
|
||||
" from " +
|
||||
// "supermarket_product t\n" +
|
||||
// " left join \n" +
|
||||
" (select t.id, t.product_id" +
|
||||
" (select case when t.id in (4,5) then 4 else t.id end as id, t.product_id" +
|
||||
", sum(t.count) as orderCount" +
|
||||
", sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" +
|
||||
" from (\n" +
|
||||
|
|
@ -4587,9 +4584,8 @@ public class OrderStatService {
|
|||
" where t.sale_type = " + saleType + " \n" +
|
||||
params +
|
||||
" ) t\n" +
|
||||
" group by t.id, t.product_id\n" +
|
||||
" group by case when t.id in (4,5) then 4 else t.id end, t.product_id\n" +
|
||||
" ) a " +
|
||||
// "on a.id = t.supermarket_id and a.product_id = t.product_id\n" +
|
||||
" left join supermarket s on s.id = a.id\n" +
|
||||
" left join product p on p.id = a.product_id order BY s.id, p.id ASC";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,4 +150,8 @@ public class SupermarketService extends BaseService {
|
|||
|
||||
return Result.success(out);
|
||||
}
|
||||
|
||||
public List<Record> newlist() {
|
||||
return Db.find("select * from supermarket t where t.del = 0 and id != 5");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,10 @@ public class SupermarketController extends BaseController {
|
|||
renderJson(Result.object(SupermarketService.me.list()));
|
||||
}
|
||||
|
||||
public void newlist() {
|
||||
renderJson(Result.object(SupermarketService.me.newlist()));
|
||||
}
|
||||
|
||||
@Before(SupAddProductValidator.class)
|
||||
public void addProduct() {
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue