|
|
@@ -17,6 +17,7 @@ import common.data.Row;
|
|
|
import common.data.Rows;
|
|
|
import common.data.RowsMap;
|
|
|
import common.data.SQLFactory;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import restcontroller.R;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
@@ -24,6 +25,8 @@ import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
public class rebateaccounthead extends Controller {
|
|
|
/**
|
|
|
@@ -260,6 +263,15 @@ public class rebateaccounthead extends Controller {
|
|
|
Rows agentrebatecategorys = dbConnect.runSqlQuery("select * from sa_agentrebatecategory where siteid='"+siteid+"'");
|
|
|
RowsMap agentdecorationtrebatesRowsMap =agentdecorationtrebates.toRowsMap("sys_enterpriseid");
|
|
|
RowsMap agentrebatecategorysRowsMap =agentrebatecategorys.toRowsMap("sys_enterpriseid");
|
|
|
+ String itemids =rebateunproducts.toJsonArray("itemid").toString();
|
|
|
+ itemids=itemids.replace("[", "(").replace("]", ")");
|
|
|
+
|
|
|
+ ArrayList<Long> itemclsids = rebatecategorys.toArrayList("itemclassid", new ArrayList<Long>());
|
|
|
+
|
|
|
+ RowsMap amountRowsMap = CalculateAmount(itemclsids,rebateaccounts.toArrayList("sys_enterpriseid",new ArrayList<Long>()), itemids);
|
|
|
+ RowsMap ordersRowsMap = QuerySaorderNum(itemclsids,rebateaccounts.toArrayList("sys_enterpriseid",new ArrayList<Long>()), itemids);
|
|
|
+ RowsMap orderDetailIdRowsMap = QuerySaorderDetailId(itemclsids,rebateaccounts.toArrayList("sys_enterpriseid",new ArrayList<Long>()), itemids);
|
|
|
+
|
|
|
for (Row row:rebateaccounts) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String begindate ="";
|
|
|
@@ -267,54 +279,67 @@ public class rebateaccounthead extends Controller {
|
|
|
BigDecimal amount =BigDecimal.ZERO;
|
|
|
BigDecimal balance = BigDecimal.ZERO;
|
|
|
BigDecimal brate = BigDecimal.ZERO;
|
|
|
- String itemids =rebateunproducts.toJsonArray("itemid").toString();
|
|
|
- itemids=itemids.replace("[", "(").replace("]", ")");
|
|
|
- System.out.println(itemids);
|
|
|
- ArrayList<Long> itemclsids = rebatecategorys.toArrayList("itemclassid", new ArrayList<Long>());
|
|
|
- String agentitemclsnums = null;
|
|
|
+
|
|
|
+
|
|
|
+// String agentitemclsnums = null;
|
|
|
if(agentdecorationtrebatesRowsMap.containsKey(row.getString("sys_enterpriseid"))){
|
|
|
if(!agentdecorationtrebatesRowsMap.get(row.getString("sys_enterpriseid")).isEmpty()){
|
|
|
begindate=sdf.format(agentdecorationtrebatesRowsMap.get(row.getString("sys_enterpriseid")).get(0).getDate("begindate"));
|
|
|
+ if(begindate.compareTo("2023-08-26")<0){
|
|
|
+ begindate="2023-08-26";
|
|
|
+ }
|
|
|
enddate=sdf.format(agentdecorationtrebatesRowsMap.get(row.getString("sys_enterpriseid")).get(0).getDate("enddate"));
|
|
|
amount=agentdecorationtrebatesRowsMap.get(row.getString("sys_enterpriseid")).get(0).getBigDecimal("amount");
|
|
|
balance=agentdecorationtrebatesRowsMap.get(row.getString("sys_enterpriseid")).get(0).getBigDecimal("balance");
|
|
|
brate=agentdecorationtrebatesRowsMap.get(row.getString("sys_enterpriseid")).get(0).getBigDecimal("brate");
|
|
|
}
|
|
|
}
|
|
|
- String billdate = sdf.format(rows.get(0).getDate("billdate"));
|
|
|
- StringBuffer str = new StringBuffer();
|
|
|
- if (!agentrebatecategorysRowsMap.isEmpty()) {
|
|
|
- if(agentrebatecategorysRowsMap.containsKey(row.getString("sys_enterpriseid"))){
|
|
|
- if(!agentrebatecategorysRowsMap.get(row.getString("sys_enterpriseid")).isEmpty()){
|
|
|
- for (Row agentrebatecategorysRow :agentrebatecategorysRowsMap.get(row.getString("sys_enterpriseid"))){
|
|
|
- if (str.toString().equals("")) {
|
|
|
- str.append("'" + agentrebatecategorysRow.getString("marketingcategory") + "'");
|
|
|
- } else {
|
|
|
- str.append(",'" + agentrebatecategorysRow.getString("marketingcategory") + "'");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (!str.toString().equals("")) {
|
|
|
- agentitemclsnums = "(" + str.toString() + ")";
|
|
|
- } else {
|
|
|
- agentitemclsnums = "('')";
|
|
|
+ final String begindate1=begindate;
|
|
|
+ final String enddate1=enddate;
|
|
|
+// String billdate = sdf.format(rows.get(0).getDate("billdate"));
|
|
|
+// StringBuffer str = new StringBuffer();
|
|
|
+// if (!agentrebatecategorysRowsMap.isEmpty()) {
|
|
|
+// if(agentrebatecategorysRowsMap.containsKey(row.getString("sys_enterpriseid"))){
|
|
|
+// if(!agentrebatecategorysRowsMap.get(row.getString("sys_enterpriseid")).isEmpty()){
|
|
|
+// for (Row agentrebatecategorysRow :agentrebatecategorysRowsMap.get(row.getString("sys_enterpriseid"))){
|
|
|
+// if (str.toString().equals("")) {
|
|
|
+// str.append("'" + agentrebatecategorysRow.getString("marketingcategory") + "'");
|
|
|
+// } else {
|
|
|
+// str.append(",'" + agentrebatecategorysRow.getString("marketingcategory") + "'");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (!str.toString().equals("")) {
|
|
|
+// agentitemclsnums = "(" + str.toString() + ")";
|
|
|
+// } else {
|
|
|
+// agentitemclsnums = "('')";
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else {
|
|
|
+// agentitemclsnums = "('')";
|
|
|
+// }
|
|
|
+ System.out.println(begindate1);
|
|
|
+ System.out.println(enddate1);
|
|
|
+ List<Row> selectamountList = amountRowsMap.get(row.getString("sys_enterpriseid")).stream().filter(row1 ->sdf.format(row1.getDate("closedate")).compareTo(enddate1)<=0 && sdf.format(row1.getDate("closedate")).compareTo(begindate1)>=0).collect(Collectors.toList());
|
|
|
+ List<Row> selectorderDetailIdList = orderDetailIdRowsMap.get(row.getString("sys_enterpriseid")).stream().filter(row1 ->sdf.format(row1.getDate("closedate")).compareTo(enddate1)<=0 && sdf.format(row1.getDate("closedate")).compareTo(begindate1)>=0).collect(Collectors.toList());
|
|
|
+ List<Row> selectordersList = ordersRowsMap.get(row.getString("sys_enterpriseid")).stream().filter(row1 ->sdf.format(row1.getDate("closedate")).compareTo(enddate1)<=0 && sdf.format(row1.getDate("closedate")).compareTo(begindate1)>=0).collect(Collectors.toList());
|
|
|
+
|
|
|
+ BigDecimal saorderamount = new BigDecimal("0");
|
|
|
+ for (Row row2 : selectamountList) {
|
|
|
+ if (row2.containsKey("amount")) {
|
|
|
+ saorderamount = saorderamount.add(row2.getBigDecimal("amount"));
|
|
|
}
|
|
|
-
|
|
|
- }else {
|
|
|
- agentitemclsnums = "('')";
|
|
|
}
|
|
|
-
|
|
|
- BigDecimal saorderamount=CalculateAmount(begindate, enddate, row.getLong("sys_enterpriseid"), itemclsids,agentitemclsnums, itemids);
|
|
|
+ System.out.println(saorderamount);
|
|
|
if(balance.compareTo(saorderamount.multiply(brate))>=0) {
|
|
|
sqlList.add("update sa_rebateaccount set approvedamount="+saorderamount.multiply(brate)+",rebateamount="+saorderamount.multiply(brate)+",accumulatedamount="+saorderamount+" where sa_rebateaccountid="+row.getLong("sa_rebateaccountid"));
|
|
|
}else if(balance.compareTo(BigDecimal.ZERO)>0) {
|
|
|
sqlList.add("update sa_rebateaccount set approvedamount="+balance+",rebateamount="+balance+",accumulatedamount="+saorderamount+" where sa_rebateaccountid="+row.getLong("sa_rebateaccountid"));
|
|
|
}
|
|
|
- sqlList.add("update sa_orderitems set decorationrebateflag=1,rebatesourceid="+rows.get(0).getLong("sa_rebateaccountheadid")+",rebatesourceobject='sa_rebateaccounthead' where sa_orderitemsid in"+QuerySaorderDetailId(begindate, enddate, row.getLong("sys_enterpriseid"), itemclsids,agentitemclsnums, itemids));
|
|
|
+ sqlList.add("update sa_orderitems set decorationrebateflag=1,rebatesourceid="+rows.get(0).getLong("sa_rebateaccountheadid")+",rebatesourceobject='sa_rebateaccounthead' where sa_orderitemsid in"+ toJsonArray("sa_orderitemsid",selectorderDetailIdList).toJSONString().replace("[", "(").replace("]", ")"));
|
|
|
|
|
|
- Rows orders = QuerySaorderNum(begindate, enddate,row.getLong("sys_enterpriseid"), itemclsids,agentitemclsnums, itemids);
|
|
|
- for (Row order:orders) {
|
|
|
+ for (Row order:selectordersList) {
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "返利结算单孙体明细新增");
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
sqlFactory.addParameter("sa_rebateaccountdetailid", createTableID("sa_rebateaccountdetail"));
|
|
|
@@ -537,80 +562,82 @@ public class rebateaccounthead extends Controller {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public BigDecimal CalculateAmount(String begindate, String enddate, long sys_enterpriseid, ArrayList<Long> itemclsids,String agentitemclsnums,
|
|
|
+ public RowsMap CalculateAmount( ArrayList<Long> itemclsids,ArrayList<Long> sys_enterpriseids,
|
|
|
String itemids) throws YosException {
|
|
|
Rows rows = null;
|
|
|
itemclsids.addAll(ItemClass.getSubItemClassIds(this,itemclsids));
|
|
|
itemclsids.add(0l);
|
|
|
if (itemids .equals("()")) {
|
|
|
- rows = dbConnect.runSqlQuery("select SUM(if(t1.isclose,t1.amount,t1.price*(t1.qty-t1.undeliqty))) amount from sa_orderitems t1 \n" +
|
|
|
+ rows = dbConnect.runSqlQuery("select t2.closedate,t2.sys_enterpriseid,sum(if(t1.isclose,t1.amount,t1.price*(t1.qty-t1.undeliqty))) amount from sa_orderitems t1 \n" +
|
|
|
"inner join sa_order t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid\n" +
|
|
|
- "inner join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where '"+begindate+"'<=DATE_FORMAT(t2.closedate, '%Y-%m-%d') and '"+enddate+"'>=DATE_FORMAT(t2.closedate, '%Y-%m-%d') " +
|
|
|
- "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"' and t2.status in('关闭') and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"'");
|
|
|
+ "inner join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where t2.type !='促销订单' and ifnull( t2.closedate,'')!='' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid in"+sys_enterpriseids.toString().replace("[", "(").replace("]", ")")+" and t2.status in('关闭') and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"' group by t2.sys_enterpriseid,t2.closedate");
|
|
|
|
|
|
} else {
|
|
|
- rows = dbConnect.runSqlQuery("select SUM(if(t1.isclose,t1.amount,t1.price*(t1.qty-t1.undeliqty))) amount from sa_orderitems t1 \n" +
|
|
|
+ rows = dbConnect.runSqlQuery("select t2.closedate,t2.sys_enterpriseid,sum(if(t1.isclose,t1.amount,t1.price*(t1.qty-t1.undeliqty))) amount from sa_orderitems t1 \n" +
|
|
|
"inner join sa_order t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid\n" +
|
|
|
- "inner join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where '"+begindate+"'<=DATE_FORMAT(t2.closedate, '%Y-%m-%d') and '"+enddate+"'>=DATE_FORMAT(t2.closedate, '%Y-%m-%d') " +
|
|
|
- "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"' and t2.status in('关闭') and t1.itemid not in" + itemids + " and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"'");
|
|
|
+ "inner join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where t2.type !='促销订单' and ifnull( t2.closedate,'')!='' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid in"+sys_enterpriseids.toString().replace("[", "(").replace("]", ")")+" and t2.status in('关闭') and t1.itemid not in" + itemids + " and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"' group by t2.sys_enterpriseid,t2.closedate");
|
|
|
|
|
|
}
|
|
|
- if (rows.isEmpty()) {
|
|
|
- return BigDecimal.ZERO;
|
|
|
- } else {
|
|
|
- return rows.get(0).getBigDecimal("amount");
|
|
|
- }
|
|
|
+ return rows.toRowsMap("sys_enterpriseid");
|
|
|
+
|
|
|
|
|
|
}
|
|
|
- public Rows QuerySaorderNum(String begindate, String enddate, long sys_enterpriseid, ArrayList<Long> itemclsids,String agentitemclsnums,
|
|
|
+ public RowsMap QuerySaorderNum(ArrayList<Long> itemclsids,ArrayList<Long> sys_enterpriseids,
|
|
|
String itemids) throws YosException {
|
|
|
Rows rows = null;
|
|
|
itemclsids.addAll(ItemClass.getSubItemClassIds(this,itemclsids));
|
|
|
itemclsids.add(0l);
|
|
|
if (itemids .equals("()")) {
|
|
|
- rows = dbConnect.runSqlQuery("select t2.sa_orderid,SUM(if(t1.isclose,t1.amount,t1.price*(t1.qty-t1.undeliqty))) amount from sa_orderitems t1 \n" +
|
|
|
+ rows = dbConnect.runSqlQuery("select t2.closedate,t2.sys_enterpriseid,t2.sa_orderid,SUM(if(t1.isclose,t1.amount,t1.price*(t1.qty-t1.undeliqty))) amount from sa_orderitems t1 \n" +
|
|
|
"inner join sa_order t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid\n" +
|
|
|
- "inner join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where '"+begindate+"'<=DATE_FORMAT(t2.closedate, '%Y-%m-%d') and '"+enddate+"'>=DATE_FORMAT(t2.closedate, '%Y-%m-%d') " +
|
|
|
- "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"' and t2.status in('关闭') and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"' group by t2.sa_orderid ");
|
|
|
+ "inner join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where t2.type !='促销订单' and ifnull( t2.closedate,'')!='' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid in"+sys_enterpriseids.toString().replace("[", "(").replace("]", ")")+" and t2.status in('关闭') and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"' group by t2.sa_orderid,t2.sys_enterpriseid,t2.closedate");
|
|
|
|
|
|
} else {
|
|
|
- rows = dbConnect.runSqlQuery("select t2.sa_orderid,SUM(if(t1.isclose,t1.amount,t1.price*(t1.qty-t1.undeliqty))) amount from sa_orderitems t1 \n" +
|
|
|
+ rows = dbConnect.runSqlQuery("select t2.closedate,t2.sys_enterpriseid,t2.sa_orderid,SUM(if(t1.isclose,t1.amount,t1.price*(t1.qty-t1.undeliqty))) amount from sa_orderitems t1 \n" +
|
|
|
"inner join sa_order t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid\n" +
|
|
|
- "inner join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where '"+begindate+"'<=DATE_FORMAT(t2.closedate, '%Y-%m-%d') and '"+enddate+"'>=DATE_FORMAT(t2.closedate, '%Y-%m-%d') " +
|
|
|
- "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"' and t2.status in('关闭') and t1.itemid not in" + itemids + " and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"' group by t2.sa_orderid");
|
|
|
+ "inner join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where t2.type !='促销订单' and ifnull( t2.closedate,'')!='' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid in"+sys_enterpriseids.toString().replace("[", "(").replace("]", ")")+" and t2.status in('关闭') and t1.itemid not in" + itemids + " and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"' group by t2.sa_orderid,t2.sys_enterpriseid,t2.closedate");
|
|
|
|
|
|
|
|
|
}
|
|
|
- return rows;
|
|
|
+ return rows.toRowsMap("sys_enterpriseid");
|
|
|
|
|
|
}
|
|
|
- public String QuerySaorderDetailId(String begindate, String enddate, long sys_enterpriseid, ArrayList<Long> itemclsids,String agentitemclsnums,
|
|
|
+ public RowsMap QuerySaorderDetailId(ArrayList<Long> itemclsids,ArrayList<Long> sys_enterpriseids,
|
|
|
String itemids) throws YosException {
|
|
|
Rows rows = null;
|
|
|
itemclsids.addAll(ItemClass.getSubItemClassIds(this,itemclsids));
|
|
|
itemclsids.add(0l);
|
|
|
if (itemids .equals("()")) {
|
|
|
- rows = dbConnect.runSqlQuery("select t1.sa_orderitemsid from sa_orderitems t1 \n" +
|
|
|
+ rows = dbConnect.runSqlQuery("select t2.closedate,t2.sys_enterpriseid,t1.sa_orderitemsid from sa_orderitems t1 \n" +
|
|
|
"inner join sa_order t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid\n" +
|
|
|
- "inner join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where '"+begindate+"'<=DATE_FORMAT(t2.closedate, '%Y-%m-%d') and '"+enddate+"'>=DATE_FORMAT(t2.closedate, '%Y-%m-%d') " +
|
|
|
- "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"' and t2.status in('关闭') and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"'");
|
|
|
+ "inner join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where t2.type !='促销订单' and ifnull( t2.closedate,'')!='' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid in"+sys_enterpriseids.toString().replace("[", "(").replace("]", ")")+" and t2.status in('关闭') and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" + itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"' group by t2.sys_enterpriseid,t2.closedate,t1.sa_orderitemsid");
|
|
|
|
|
|
} else {
|
|
|
- rows = dbConnect.runSqlQuery("select t1.sa_orderitemsid from sa_orderitems t1 \n" +
|
|
|
+ rows = dbConnect.runSqlQuery("select t2.closedate,t2.sys_enterpriseid,t1.sa_orderitemsid from sa_orderitems t1 \n" +
|
|
|
"inner join sa_order t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid\n" +
|
|
|
- "inner join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where '"+begindate+"'<=DATE_FORMAT(t2.closedate, '%Y-%m-%d') and '"+enddate+"'>=DATE_FORMAT(t2.closedate, '%Y-%m-%d') " +
|
|
|
- "and t2.type !='促销订单' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid ='"+sys_enterpriseid+"' and t2.status in('关闭') and t1.itemid not in" + itemids + " and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" +itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"'");
|
|
|
+ "inner join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where t2.type !='促销订单' and ifnull( t2.closedate,'')!='' and t2.sa_accountclassid!=0 and t2.sys_enterpriseid in"+sys_enterpriseids.toString().replace("[", "(").replace("]", ")")+" and t2.status in('关闭') and t1.itemid not in" + itemids + " and t1.itemid in(select itemid from sa_itemsaleclass where itemclassid in" +itemclsids.toString().replace("[", "(").replace("]", ")")+" ) and t1.DECORATIONREBATEFLAG=0 and t1.siteid='"+siteid+"' group by t2.sys_enterpriseid,t2.closedate,t1.sa_orderitemsid");
|
|
|
|
|
|
|
|
|
}
|
|
|
+ return rows.toRowsMap("sys_enterpriseid");
|
|
|
+// if(rows.toJsonArray("sa_orderitemsid").isEmpty()){
|
|
|
+// return "(0)";
|
|
|
+// }else{
|
|
|
+// return rows.toJsonArray("sa_orderitemsid").toJSONString().replace("[", "(").replace("]", ")");
|
|
|
+// }
|
|
|
|
|
|
- if(rows.toJsonArray("sa_orderitemsid").isEmpty()){
|
|
|
- return "(0)";
|
|
|
- }else{
|
|
|
- return rows.toJsonArray("sa_orderitemsid").toJSONString().replace("[", "(").replace("]", ")");
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
+ public JSONArray toJsonArray(String column,List<Row> list) {
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ array.add("0");
|
|
|
+ for (Row row : list) {
|
|
|
+ Object value = row.get(column);
|
|
|
+ array.add(value);
|
|
|
+ }
|
|
|
+ return array;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|