|
|
@@ -646,7 +646,6 @@ public class Order extends Controller {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- boolean isExport = content.getBooleanValue("isExport");
|
|
|
// SQLFactory sqlFactory = new SQLFactory(this, "订单(管理端)_列表", pageSize, pageNumber, pageSorting);
|
|
|
// if (isExport) {
|
|
|
// sqlFactory = new SQLFactory(this, "订单(管理端)_列表");
|
|
|
@@ -659,9 +658,7 @@ public class Order extends Controller {
|
|
|
QuerySQL querySQL = queryListManage(where.toString());
|
|
|
querySQL.setOrderBy(pageSorting);
|
|
|
Rows rows;
|
|
|
- if (!isExport) {
|
|
|
- querySQL.setPage(pageSize, pageNumber);
|
|
|
- }
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
rows = querySQL.query();
|
|
|
|
|
|
ArrayList<Long> ids = rows.toArrayList("sa_orderid", new ArrayList<>());
|
|
|
@@ -789,6 +786,8 @@ public class Order extends Controller {
|
|
|
"enterprisename");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t6", "t6.sys_enterpriseid=t1.sys_enterpriseid and t6.siteid = t1.siteid",
|
|
|
"agentnum");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_promotion", "t7", "t7.sa_promotionid=t1.sa_promotionid and t7.siteid = t1.siteid",
|
|
|
+ "promnum","promname");
|
|
|
querySQL.addQueryFields("amount", "CAST(0 AS CHAR(20))");
|
|
|
querySQL.addQueryFields("qty", "CAST(0 AS CHAR(20))");
|
|
|
querySQL.setWhere("t1.siteid", siteid);
|
|
|
@@ -908,9 +907,9 @@ public class Order extends Controller {
|
|
|
QuerySQL querySQL = queryList(where.toString());
|
|
|
querySQL.setOrderBy(pageSorting);
|
|
|
Rows rows;
|
|
|
- if (!isExport) {
|
|
|
- querySQL.setPage(pageSize, pageNumber);
|
|
|
- }
|
|
|
+// if (!isExport) {
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+// }
|
|
|
rows = querySQL.query();
|
|
|
//查询数据:amount,defaultamount,qty
|
|
|
ArrayList<Long> sa_orderids = rows.toArrayList("sa_orderid", new ArrayList<>());
|
|
|
@@ -1239,16 +1238,40 @@ public class Order extends Controller {
|
|
|
}
|
|
|
|
|
|
//促销订单经销商限购金额判断
|
|
|
- Rows promotion_auth = dbConnect.runSqlQuery(" select * from sa_promotion_auth where sys_enterpriseid="+sys_enterpriseid+" and sa_promotionid="+sa_promotionid);
|
|
|
+ String promotiontype="";
|
|
|
+ BigDecimal associationamount=BigDecimal.ZERO;
|
|
|
+ Rows promotion = dbConnect.runSqlQuery(" select * from sa_promotion where siteid='"+siteid+"'and sa_promotionid="+sa_promotionid);
|
|
|
+ Rows promotion_auth = dbConnect.runSqlQuery(" select * from sa_promotion_auth where siteid='"+siteid+"'and sys_enterpriseid="+sys_enterpriseid+" and sa_promotionid="+sa_promotionid);
|
|
|
+ if(promotion.isNotEmpty()){
|
|
|
+ promotiontype=promotion.get(0).getString("type");
|
|
|
+ associationamount=promotion.get(0).getBigDecimal("associationamount");
|
|
|
+ }
|
|
|
if(promotion_auth.isNotEmpty()){
|
|
|
boolean islimit = promotion_auth.get(0).getBoolean("islimit");
|
|
|
BigDecimal limitamount = promotion_auth.get(0).getBigDecimal("limitamount");
|
|
|
BigDecimal saledamount = promotion_auth.get(0).getBigDecimal("saledamount");
|
|
|
+ System.out.println("limitamount:"+limitamount);
|
|
|
+ System.out.println("saledamount:"+saledamount);
|
|
|
+ System.out.println("associationamount:"+associationamount);
|
|
|
if(islimit){
|
|
|
- if(amount.compareTo(limitamount.subtract(saledamount))>0){
|
|
|
- return getErrReturnObject().setErrMsg("已超过促销方案限定金额,无法提交").toString();
|
|
|
+ if(!promotiontype.equals("返利促销")){
|
|
|
+ if(amount.compareTo(limitamount.subtract(saledamount))>0){
|
|
|
+ return getErrReturnObject().setErrMsg("已超过促销方案限定金额,无法提交").toString();
|
|
|
+ }
|
|
|
+ sqlList.add("update sa_promotion_auth set saledamount=saledamount+" + amount + " where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
|
|
|
+ }else{
|
|
|
+ if(amount.subtract((limitamount.subtract(saledamount))).compareTo(associationamount)>0){
|
|
|
+ return getErrReturnObject().setErrMsg("已超过促销方案限定金额,无法提交").toString();
|
|
|
+ }
|
|
|
+ if(amount.compareTo((limitamount.subtract(saledamount)))>0){
|
|
|
+ sqlList.add("update sa_promotion_auth set saledamount=saledamount+" + (limitamount.subtract(saledamount)) + " where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
|
|
|
+ }else{
|
|
|
+ sqlList.add("update sa_promotion_auth set saledamount=saledamount+" + amount + " where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- sqlList.add("update sa_promotion_auth set saledamount=saledamount+" + amount + " where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2825,7 +2848,7 @@ public class Order extends Controller {
|
|
|
if (orderRow.isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("订单不存在").toString();
|
|
|
}
|
|
|
- if (orderRow.get(0).getString("status").equals("关闭")) {
|
|
|
+ if (orderRow.get(0).getString("status").equals("手工关闭")) {
|
|
|
return getErrReturnObject().setErrMsg("订单已关闭,无法再次手工关闭").toString();
|
|
|
}
|
|
|
if (!orderRow.get(0).getString("status").equals("审核")) {
|
|
|
@@ -2845,7 +2868,24 @@ public class Order extends Controller {
|
|
|
Rows rows = dbConnect.runSqlQuery("SELECT sum(undeliqty*price) totalprice from sa_orderitems WHERE sa_orderid=" + sa_orderid + " and siteid = '" + siteid + "'");
|
|
|
if (rows.isNotEmpty()) {
|
|
|
BigDecimal totalprice = rows.get(0).getBigDecimal("totalprice");
|
|
|
- if (totalprice.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ JSONArray sa_accountclassinfos = orderRow.get(0).getJSONArray("sa_accountclassinfos");
|
|
|
+ JSONObject orderaccountclassinfo = new JSONObject();
|
|
|
+ JSONObject promotionaccountclassinfo = new JSONObject();
|
|
|
+ for (Object object:sa_accountclassinfos) {
|
|
|
+ JSONObject jsonObject=(JSONObject)object;
|
|
|
+ if(jsonObject.getLong("sa_accountclassid")==sa_accountclassid){
|
|
|
+ orderaccountclassinfo=jsonObject;
|
|
|
+ }else{
|
|
|
+ promotionaccountclassinfo=jsonObject;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Rows promotion_auth = dbConnect.runSqlQuery(" select * from sa_promotion_auth where siteid='"+siteid+"'and sys_enterpriseid="+sys_enterpriseid+" and sa_promotionid="+ orderRow.get(0).getLong("sa_promotionid"));
|
|
|
+ long sa_promotion_authid=0;
|
|
|
+ if(promotion_auth.isNotEmpty()){
|
|
|
+ sa_promotion_authid=promotion_auth.get(0).getLong("sa_promotion_authid");
|
|
|
+ }
|
|
|
+ if(orderaccountclassinfo.getBigDecimal("amount").compareTo(totalprice)>=0){
|
|
|
+ System.out.println("1111");
|
|
|
CashbillEntity entity = new CashbillEntity();
|
|
|
entity.setAmount(totalprice.negate());
|
|
|
entity.setSource("订单手工关闭");
|
|
|
@@ -2854,7 +2894,32 @@ public class Order extends Controller {
|
|
|
entity.setRemarks("由" + orderRow.get(0).getString("sonum") + "订单手工关闭时自动产生");
|
|
|
entity.setType("普通费用");
|
|
|
entity.setTypemx("订单关闭退款");
|
|
|
- sqlList.addAll(Accountbalance.createCashbillPay(this, sys_enterpriseid, sa_accountclassid, entity, true));
|
|
|
+ sqlList.addAll(Accountbalance.createCashbillPay(this, sys_enterpriseid, orderaccountclassinfo.getLongValue("sa_accountclassid"), entity, true));
|
|
|
+ sqlList.add("update sa_promotion_auth set saledamount=saledamount-" + totalprice + " where sa_promotion_authid=" + sa_promotion_authid);
|
|
|
+ }else if(orderaccountclassinfo.getBigDecimal("amount").compareTo(totalprice)<0){
|
|
|
+ System.out.println("222");
|
|
|
+ CashbillEntity entity = new CashbillEntity();
|
|
|
+ entity.setAmount(orderaccountclassinfo.getBigDecimal("amount").negate());
|
|
|
+ entity.setSource("订单手工关闭");
|
|
|
+ entity.setOwnerid(sa_orderid);
|
|
|
+ entity.setOwnertable("sa_order");
|
|
|
+ entity.setRemarks("由" + orderRow.get(0).getString("sonum") + "订单手工关闭时自动产生");
|
|
|
+ entity.setType("普通费用");
|
|
|
+ entity.setTypemx("订单关闭退款");
|
|
|
+ sqlList.addAll(Accountbalance.createCashbillPay(this, sys_enterpriseid, orderaccountclassinfo.getLongValue("sa_accountclassid"), entity, true));
|
|
|
+
|
|
|
+ sqlList.add("update sa_promotion_auth set saledamount=saledamount-" + orderaccountclassinfo.getBigDecimal("amount") + " where sa_promotion_authid=" + sa_promotion_authid);
|
|
|
+
|
|
|
+ CashbillEntity promotionentity = new CashbillEntity();
|
|
|
+ promotionentity.setAmount((totalprice.subtract(orderaccountclassinfo.getBigDecimal("amount"))).negate());
|
|
|
+ promotionentity.setSource("订单手工关闭");
|
|
|
+ promotionentity.setOwnerid(sa_orderid);
|
|
|
+ promotionentity.setOwnertable("sa_order");
|
|
|
+ promotionentity.setRemarks("由" + orderRow.get(0).getString("sonum") + "订单手工关闭时自动产生");
|
|
|
+ promotionentity.setType("普通费用");
|
|
|
+ promotionentity.setTypemx("订单关闭退款");
|
|
|
+ sqlList.addAll(Accountbalance.createCashbillPay(this, sys_enterpriseid, promotionaccountclassinfo.getLongValue("sa_accountclassid"), promotionentity, true));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -2886,92 +2951,82 @@ public class Order extends Controller {
|
|
|
|
|
|
Rows orderRows = getOrderRows(this, sa_orderid);
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
-
|
|
|
-// if (orderRows.isEmpty()) {
|
|
|
-// System.out.println(111111);
|
|
|
-// return sqlList;
|
|
|
-// }
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
- BigDecimal orderSumamount = BigDecimal.ZERO;
|
|
|
- Rows classamountrows = dbConnect.runSqlQuery("select t2.marketingcategory topitemclassid,t1.siteid,sum(ifnull(t1.amount,0)) sumamount from sa_orderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.sa_orderid='" + sa_orderid + "' and t1.siteid='" + siteid + "' group by t2.marketingcategory,t1.siteid");
|
|
|
- for (Row classamountrow : classamountrows) {
|
|
|
- orderSumamount = orderSumamount.add(classamountrow.getBigDecimal("sumamount"));
|
|
|
- }
|
|
|
- if (orderSumamount.compareTo(getAmount(this, sa_orderid)) != 0) {
|
|
|
- System.out.println(22222);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ BigDecimal orderamount = getAmount(this, sa_orderid);
|
|
|
+ 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 + "' and t1.sa_accountclassid="+(sa_accountclassid == 0 ? orderRows.get(0).getLong("sa_accountclassid") : sa_accountclassid));
|
|
|
+ if (orderRows.isEmpty()) {
|
|
|
+ //全部优先账户扣款
|
|
|
+ jsonObject.put("amount", orderamount);
|
|
|
+ jsonObject.put("sa_accountclassid", accountclassrows.get(0).getLong("sa_accountclassid"));
|
|
|
+ jsonObject.put("accountname", accountclassrows.get(0).getString("accountname"));
|
|
|
+ jsonObject.put("balance", accountclassrows.get(0).getBigDecimal("balance"));
|
|
|
+ jsonObject.put("creditquota", accountclassrows.get(0).getBigDecimal("creditquota"));
|
|
|
+ jsonArray.add(jsonObject);
|
|
|
+ sqlList.add("update sa_order set sa_accountclassinfos='" + jsonArray + "' where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'");
|
|
|
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=" + (sys_enterpriseid == 0 ? orderRows.get(0).getLong("pay_enterpriseid") : sys_enterpriseid) + " where isused=1 and t1.siteid='" + siteid + "'");
|
|
|
- BigDecimal firstpayamount = BigDecimal.ZERO;
|
|
|
-
|
|
|
-
|
|
|
- if (!accountclassrows.isEmpty()) {
|
|
|
- for (Row row : accountclassrows) {
|
|
|
- BigDecimal sumamount = BigDecimal.ZERO;
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- if (row.getJSONArray("bindingcategories") != null && !row.getJSONArray("bindingcategories").isEmpty()) {
|
|
|
- for (Object object : row.getJSONArray("bindingcategories")) {
|
|
|
- Long topitemclassid = Long.valueOf(object.toString());
|
|
|
- if (classamountrowsMap.containsKey(object.toString())) {
|
|
|
- if (classamountrowsMap.get(object.toString()).isNotEmpty()) {
|
|
|
- sumamount = sumamount.add(classamountrowsMap.get(object.toString()).get(0).getBigDecimal("sumamount").multiply(row.getBigDecimal("maximumdiscount")).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (sumamount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- if ((row.getBigDecimal("balance").add(row.getBigDecimal("creditquota"))).compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
- continue;
|
|
|
- } else if ((row.getBigDecimal("balance").add(row.getBigDecimal("creditquota"))).compareTo(sumamount) < 0) {
|
|
|
- //部分优先账户扣款,部分现金扣款
|
|
|
- jsonObject.put("amount", row.getBigDecimal("balance").add(row.getBigDecimal("creditquota")));
|
|
|
- jsonObject.put("sa_accountclassid", row.getLong("sa_accountclassid"));
|
|
|
- jsonObject.put("accountname", row.getString("accountname"));
|
|
|
- jsonObject.put("balance", row.getBigDecimal("balance"));
|
|
|
- jsonObject.put("creditquota", row.getBigDecimal("creditquota"));
|
|
|
+ String type="";
|
|
|
+ Rows promotionrows =dbConnect.runSqlQuery("select * from sa_promotion where siteid='"+siteid+"' and sa_promotionid="+ orderRows.get(0).getLong("sa_promotionid"));
|
|
|
+ Rows promotionenterpriserows =dbConnect.runSqlQuery("select * from sa_promotion_auth where siteid='"+siteid+"'and sys_enterpriseid="+(sys_enterpriseid == 0 ? orderRows.get(0).getLong("pay_enterpriseid") : sys_enterpriseid)+" and sa_promotionid="+ orderRows.get(0).getLong("sa_promotionid"));
|
|
|
+ if(promotionrows.isNotEmpty()){
|
|
|
+ type=promotionrows.get(0).getString("type");
|
|
|
+ }
|
|
|
+ if(type.equals("返利促销")){
|
|
|
+ BigDecimal associationamount = promotionrows.get(0).getBigDecimal("associationamount");
|
|
|
+ long associationaccountclassid = promotionrows.get(0).getLong("associationaccountclassid");
|
|
|
+ Rows associationaccountclassrows = 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 + "' and t1.sa_accountclassid="+associationaccountclassid);
|
|
|
+ if(promotionenterpriserows.isNotEmpty()){
|
|
|
+ if(promotionenterpriserows.get(0).getBoolean("islimit")){
|
|
|
+ BigDecimal limitamount = promotionenterpriserows.get(0).getBigDecimal("limitamount");
|
|
|
+ BigDecimal saledamount = promotionenterpriserows.get(0).getBigDecimal("saledamount");
|
|
|
+ if(orderamount.compareTo(limitamount.subtract(saledamount))<=0){
|
|
|
+ //全部优先账户扣款
|
|
|
+ jsonObject.put("amount", orderamount);
|
|
|
+ jsonObject.put("sa_accountclassid", accountclassrows.get(0).getLong("sa_accountclassid"));
|
|
|
+ jsonObject.put("accountname", accountclassrows.get(0).getString("accountname"));
|
|
|
+ jsonObject.put("balance", accountclassrows.get(0).getBigDecimal("balance"));
|
|
|
+ jsonObject.put("creditquota", accountclassrows.get(0).getBigDecimal("creditquota"));
|
|
|
jsonArray.add(jsonObject);
|
|
|
- firstpayamount = firstpayamount.add(row.getBigDecimal("balance").add(row.getBigDecimal("creditquota")));
|
|
|
-
|
|
|
- } else if ((row.getBigDecimal("balance").add(row.getBigDecimal("creditquota"))).compareTo(sumamount) >= 0) {
|
|
|
+ }else if(orderamount.compareTo(limitamount.subtract(saledamount))>0){
|
|
|
//全部优先账户扣款
|
|
|
- jsonObject.put("amount", sumamount);
|
|
|
- jsonObject.put("sa_accountclassid", row.getLong("sa_accountclassid"));
|
|
|
- jsonObject.put("accountname", row.getString("accountname"));
|
|
|
- jsonObject.put("balance", row.getBigDecimal("balance"));
|
|
|
- jsonObject.put("creditquota", row.getBigDecimal("creditquota"));
|
|
|
+ jsonObject.put("amount", limitamount.subtract(saledamount));
|
|
|
+ jsonObject.put("sa_accountclassid", accountclassrows.get(0).getLong("sa_accountclassid"));
|
|
|
+ jsonObject.put("accountname", accountclassrows.get(0).getString("accountname"));
|
|
|
+ jsonObject.put("balance", accountclassrows.get(0).getBigDecimal("balance"));
|
|
|
+ jsonObject.put("creditquota", accountclassrows.get(0).getBigDecimal("creditquota"));
|
|
|
jsonArray.add(jsonObject);
|
|
|
- firstpayamount = firstpayamount.add(sumamount);
|
|
|
+
|
|
|
+ JSONObject associationjsonObject = new JSONObject();
|
|
|
+ associationjsonObject.put("amount", orderamount.subtract((limitamount.subtract(saledamount))));
|
|
|
+ associationjsonObject.put("sa_accountclassid", associationaccountclassrows.get(0).getLong("sa_accountclassid"));
|
|
|
+ associationjsonObject.put("accountname", associationaccountclassrows.get(0).getString("accountname"));
|
|
|
+ associationjsonObject.put("balance", associationaccountclassrows.get(0).getBigDecimal("balance"));
|
|
|
+ associationjsonObject.put("creditquota", associationaccountclassrows.get(0).getBigDecimal("creditquota"));
|
|
|
+ jsonArray.add(associationjsonObject);
|
|
|
+ }else{
|
|
|
+ return sqlList;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- 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=" + (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);
|
|
|
- jsonObject.put("sa_accountclassid", xianjinaccountclassrows.get(0).getLong("sa_accountclassid"));
|
|
|
- jsonObject.put("accountname", xianjinaccountclassrows.get(0).getString("accountname"));
|
|
|
- jsonObject.put("balance", xianjinaccountclassrows.get(0).getBigDecimal("balance"));
|
|
|
- jsonObject.put("creditquota", xianjinaccountclassrows.get(0).getBigDecimal("creditquota"));
|
|
|
+ }else{
|
|
|
+ //全部优先账户扣款
|
|
|
+ jsonObject.put("amount", orderamount);
|
|
|
+ jsonObject.put("sa_accountclassid", accountclassrows.get(0).getLong("sa_accountclassid"));
|
|
|
+ jsonObject.put("accountname", accountclassrows.get(0).getString("accountname"));
|
|
|
+ jsonObject.put("balance", accountclassrows.get(0).getBigDecimal("balance"));
|
|
|
+ jsonObject.put("creditquota", accountclassrows.get(0).getBigDecimal("creditquota"));
|
|
|
jsonArray.add(jsonObject);
|
|
|
}
|
|
|
+ }else{
|
|
|
+ //全部优先账户扣款
|
|
|
+ jsonObject.put("amount", orderamount);
|
|
|
+ jsonObject.put("sa_accountclassid", accountclassrows.get(0).getLong("sa_accountclassid"));
|
|
|
+ jsonObject.put("accountname", accountclassrows.get(0).getString("accountname"));
|
|
|
+ jsonObject.put("balance", accountclassrows.get(0).getBigDecimal("balance"));
|
|
|
+ jsonObject.put("creditquota", accountclassrows.get(0).getBigDecimal("creditquota"));
|
|
|
+ jsonArray.add(jsonObject);
|
|
|
}
|
|
|
|
|
|
- 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=" + (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));
|
|
|
- jsonObject.put("sa_accountclassid", xianjinaccountclassrows.get(0).getLong("sa_accountclassid"));
|
|
|
- jsonObject.put("accountname", xianjinaccountclassrows.get(0).getString("accountname"));
|
|
|
- jsonObject.put("balance", xianjinaccountclassrows.get(0).getBigDecimal("balance"));
|
|
|
- jsonObject.put("creditquota", xianjinaccountclassrows.get(0).getBigDecimal("creditquota"));
|
|
|
- jsonArray.add(jsonObject);
|
|
|
- }
|
|
|
- }
|
|
|
sqlList.add("update sa_order set sa_accountclassinfos='" + jsonArray + "' where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'");
|
|
|
return sqlList;
|
|
|
}
|