|
|
@@ -107,10 +107,10 @@ public class Order extends Controller {
|
|
|
//营销账户类型ID
|
|
|
if ((type.equals("标准订单") || type.equals("特殊订单")) && content.getString("tradefield").equals("整装工程")) {
|
|
|
sqlFactory.addParameter("sa_accountclassid", "69");
|
|
|
- sqlList.addAll(updateAccountclassinfos(sa_orderid,69));
|
|
|
+ sqlList.addAll(updateAccountclassinfos(sa_orderid,69,sys_enterpriseid));
|
|
|
} else {
|
|
|
sqlFactory.addParameter("sa_accountclassid", beans.order.Order.getDefaultAccount(siteid, type));
|
|
|
- sqlList.addAll(updateAccountclassinfos(sa_orderid,beans.order.Order.getDefaultAccount(siteid, type)));
|
|
|
+ sqlList.addAll(updateAccountclassinfos(sa_orderid,beans.order.Order.getDefaultAccount(siteid, type),sys_enterpriseid));
|
|
|
}
|
|
|
//品牌ID
|
|
|
sqlFactory.addParameter("sa_brandid", sa_brandid);
|
|
|
@@ -168,7 +168,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
if(content.containsKey("sa_accountclassid")){
|
|
|
sqlFactory.addParameter("sa_accountclassid", content.getLongValue("sa_accountclassid"));
|
|
|
- sqlList.addAll(updateAccountclassinfos(sa_orderid,content.getLongValue("sa_accountclassid")));
|
|
|
+ sqlList.addAll(updateAccountclassinfos(sa_orderid,content.getLongValue("sa_accountclassid"),sys_enterpriseid));
|
|
|
}
|
|
|
} else {
|
|
|
//订单更新时
|
|
|
@@ -186,7 +186,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
}
|
|
|
sqlFactory.addParameter("sa_accountclassid", content.getLongValue("sa_accountclassid"));
|
|
|
- sqlList.addAll(updateAccountclassinfos(sa_orderid, content.getLongValue("sa_accountclassid")));
|
|
|
+ sqlList.addAll(updateAccountclassinfos(sa_orderid, content.getLongValue("sa_accountclassid"),sys_enterpriseid));
|
|
|
}
|
|
|
if (billdate.equals("")) {
|
|
|
sqlFactory.addParameter_SQL("billdate", "createdate");
|
|
|
@@ -273,10 +273,10 @@ public class Order extends Controller {
|
|
|
//营销账户类型ID
|
|
|
if ((type.equals("标准订单") || type.equals("特殊订单")) && content.getString("tradefield").equals("整装工程")) {
|
|
|
sqlFactory.addParameter("sa_accountclassid", "69");
|
|
|
- sqlList1.addAll(updateAccountclassinfos(sa_orderid,69));
|
|
|
+ sqlList1.addAll(updateAccountclassinfos(sa_orderid,69,sys_enterpriseid));
|
|
|
} else {
|
|
|
sqlFactory.addParameter("sa_accountclassid", beans.order.Order.getDefaultAccount(siteid, type));
|
|
|
- sqlList1.addAll(updateAccountclassinfos(sa_orderid,beans.order.Order.getDefaultAccount(siteid, type)));
|
|
|
+ sqlList1.addAll(updateAccountclassinfos(sa_orderid,beans.order.Order.getDefaultAccount(siteid, type),sys_enterpriseid));
|
|
|
}
|
|
|
|
|
|
//品牌ID
|
|
|
@@ -2784,14 +2784,15 @@ public class Order extends Controller {
|
|
|
/**
|
|
|
* 更新订单扣款信息
|
|
|
*/
|
|
|
- public ArrayList<String> updateAccountclassinfos(Long sa_orderid,long sa_accountclassid) throws YosException {
|
|
|
+ public ArrayList<String> updateAccountclassinfos(Long sa_orderid,long sa_accountclassid,long sys_enterpriseid) throws YosException {
|
|
|
|
|
|
Rows orderRows = getOrderRows(this, sa_orderid);
|
|
|
ArrayList<String> sqlList =new ArrayList<>();
|
|
|
|
|
|
- if (orderRows.isEmpty()) {
|
|
|
- return sqlList;
|
|
|
- }
|
|
|
+// if (orderRows.isEmpty()) {
|
|
|
+// System.out.println(111111);
|
|
|
+// return sqlList;
|
|
|
+// }
|
|
|
JSONArray jsonArray =new JSONArray();
|
|
|
BigDecimal orderSumamount = BigDecimal.ZERO;
|
|
|
Rows classamountrows =dbConnect.runSqlQuery("select t3.topitemclassid,t1.siteid,sum(ifnull(t1.amount,0)) sumamount from sa_orderitems t1 inner join sa_itemsaleclass t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid inner join (select itemclassid,find_top(itemclassid) topitemclassid,siteid from plm_itemclass where siteid!='ZZYOS') t3 on t2.itemclassid=t3.itemclassid and t2.siteid=t3.siteid where t1.sa_orderid="+sa_orderid+" group by t3.topitemclassid,t1.siteid");
|
|
|
@@ -2799,11 +2800,12 @@ public class Order extends Controller {
|
|
|
orderSumamount=orderSumamount.add(classamountrow.getBigDecimal("sumamount"));
|
|
|
}
|
|
|
if(orderSumamount.compareTo(getAmount(this,sa_orderid))!=0){
|
|
|
+ System.out.println(22222);
|
|
|
return sqlList;
|
|
|
}
|
|
|
|
|
|
RowsMap classamountrowsMap =classamountrows.toRowsMap("topitemclassid");
|
|
|
- Rows accountclassrows =dbConnect.runSqlQuery("select t1.*,ifnull(t2.balance,0) balance,ifnull(t2.creditquota,0) creditquota from sa_accountclass t1 left join sa_accountbalance t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid and t2.sys_enterpriseid="+orderRows.get(0).getLong("pay_enterpriseid")+" where isused=1 and t1.siteid='"+siteid+"'");
|
|
|
+ Rows accountclassrows =dbConnect.runSqlQuery("select t1.*,ifnull(t2.balance,0) balance,ifnull(t2.creditquota,0) creditquota from sa_accountclass t1 left join sa_accountbalance t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid and t2.sys_enterpriseid="+(sys_enterpriseid==0?orderRows.get(0).getLong("pay_enterpriseid"):sys_enterpriseid)+" where isused=1 and t1.siteid='"+siteid+"'");
|
|
|
BigDecimal firstpayamount = BigDecimal.ZERO;
|
|
|
|
|
|
|
|
|
@@ -2848,7 +2850,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
}
|
|
|
if(getAmount(this,sa_orderid).compareTo(BigDecimal.ZERO)==0){
|
|
|
- Rows xianjinaccountclassrows =dbConnect.runSqlQuery("select t1.*,ifnull(t2.balance,0) balance,ifnull(t2.creditquota,0) creditquota from sa_accountclass t1 left join sa_accountbalance t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid and t2.sys_enterpriseid="+orderRows.get(0).getLong("pay_enterpriseid")+" where isorder=1 and isused=1 and t1.sa_accountclassid="+(sa_accountclassid==0?orderRows.get(0).getLong("sa_accountclassid"):sa_accountclassid)+" and t1.siteid='"+siteid+"'");
|
|
|
+ Rows xianjinaccountclassrows =dbConnect.runSqlQuery("select t1.*,ifnull(t2.balance,0) balance,ifnull(t2.creditquota,0) creditquota from sa_accountclass t1 left join sa_accountbalance t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid and t2.sys_enterpriseid="+(sys_enterpriseid==0?orderRows.get(0).getLong("pay_enterpriseid"):sys_enterpriseid)+" where isorder=1 and isused=1 and t1.sa_accountclassid="+(sa_accountclassid==0?orderRows.get(0).getLong("sa_accountclassid"):sa_accountclassid)+" and t1.siteid='"+siteid+"'");
|
|
|
if(xianjinaccountclassrows.isNotEmpty()){
|
|
|
JSONObject jsonObject =new JSONObject();
|
|
|
jsonObject.put("amount", BigDecimal.ZERO);
|
|
|
@@ -2861,7 +2863,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
|
|
|
if(orderSumamount.compareTo(firstpayamount)>0){
|
|
|
- Rows xianjinaccountclassrows =dbConnect.runSqlQuery("select t1.*,ifnull(t2.balance,0) balance,ifnull(t2.creditquota,0) creditquota from sa_accountclass t1 left join sa_accountbalance t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid and t2.sys_enterpriseid="+orderRows.get(0).getLong("pay_enterpriseid")+" where isorder=1 and isused=1 and t1.sa_accountclassid="+(sa_accountclassid==0?orderRows.get(0).getLong("sa_accountclassid"):sa_accountclassid)+" and t1.siteid='"+siteid+"'");
|
|
|
+ Rows xianjinaccountclassrows =dbConnect.runSqlQuery("select t1.*,ifnull(t2.balance,0) balance,ifnull(t2.creditquota,0) creditquota from sa_accountclass t1 left join sa_accountbalance t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid and t2.sys_enterpriseid="+(sys_enterpriseid==0?orderRows.get(0).getLong("pay_enterpriseid"):sys_enterpriseid)+" where isorder=1 and isused=1 and t1.sa_accountclassid="+(sa_accountclassid==0?orderRows.get(0).getLong("sa_accountclassid"):sa_accountclassid)+" and t1.siteid='"+siteid+"'");
|
|
|
if(xianjinaccountclassrows.isNotEmpty()){
|
|
|
JSONObject jsonObject =new JSONObject();
|
|
|
jsonObject.put("amount", orderSumamount.subtract(firstpayamount));
|