|
|
@@ -19,6 +19,7 @@ import common.YosException;
|
|
|
import common.annotation.API;
|
|
|
import common.annotation.CACHEING;
|
|
|
import common.annotation.CACHEING_CLEAN;
|
|
|
+import common.api.YOSAPI;
|
|
|
import common.data.*;
|
|
|
import common.data.db.DBConnect;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
@@ -2290,26 +2291,6 @@ public class Order extends Controller {
|
|
|
if (sa_accountclassid <= 0) {
|
|
|
return getErrReturnObject().setErrMsg("请选择支付账号").toString();
|
|
|
}
|
|
|
- if (siteid.equalsIgnoreCase("CCYOSG") && !type.equals("促销订单")) {
|
|
|
- if (typemx.equals("工程") || typemx.equals("电商") || typemx.equals("内部")) {
|
|
|
-
|
|
|
- } else {
|
|
|
- String tradefield = row.getString("tradefield");
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_optiontypemx");
|
|
|
- querySQL.addJoinTable(JOINTYPE.inner, "sys_optiontype", "t2", "t2.optiontypeid=t1.optiontypeid");
|
|
|
- querySQL.setWhere("t2.typename='domainrelatedaccounts'");
|
|
|
- querySQL.setWhere("(t1.value='" + tradefield + "' or t1.remarks='" + tradefield + "')");
|
|
|
- querySQL.setTableAlias("t1");
|
|
|
- Rows accountsTows = querySQL.query();
|
|
|
- if (accountsTows.isNotEmpty()) {
|
|
|
- JSONArray subvalues = accountsTows.get(0).getJSONArray("subvalues");
|
|
|
- if (!subvalues.contains(sa_accountclassid.toString())) {
|
|
|
- return getErrReturnObject().setErrMsg("扣款账户不对,禁止提交,请更换支付账户后提交").toString();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
Long sys_enterpriseid = row.getLong("sys_enterpriseid");
|
|
|
if (sys_enterpriseid <= 0) {
|
|
|
@@ -2609,7 +2590,7 @@ public class Order extends Controller {
|
|
|
BigDecimal amount1 = jsonObject.getBigDecimal("amount");
|
|
|
if (index == accountclassinfos.size() && costamount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
if (Accountbalance.judgeBalance(this, pay_enterpriseid, jsonObject.getLong("sa_accountclassid"), amount1.add(costamount))) {
|
|
|
- CashbillEntity entity = getCashbillEntity(getDate_Str(),amount1, sa_orderid, "订单提交", sonum, "由订单号" + sonum + "提交时生成");
|
|
|
+ CashbillEntity entity = getCashbillEntity(getDate_Str(), amount1, sa_orderid, "订单提交", sonum, "由订单号" + sonum + "提交时生成");
|
|
|
//
|
|
|
if (accountclassrowsMap.containsKey(jsonObject.getString("sa_accountclassid")) && accountclassrowsMap.get(jsonObject.getString("sa_accountclassid")).isNotEmpty()) {
|
|
|
jsonObject.put("balance", accountclassrowsMap.get(jsonObject.getString("sa_accountclassid")).get(0).getBigDecimal("balance").subtract(amount1));
|
|
|
@@ -2625,7 +2606,7 @@ public class Order extends Controller {
|
|
|
|
|
|
//定制费用
|
|
|
|
|
|
- CashbillEntity entityCost = getCashbillEntity(getDate_Str(),costamount, sa_orderid, "订单提交", sonum, "由" + sonum + "【定制费用】订单提交时自动产生");
|
|
|
+ CashbillEntity entityCost = getCashbillEntity(getDate_Str(), costamount, sa_orderid, "订单提交", sonum, "由" + sonum + "【定制费用】订单提交时自动产生");
|
|
|
JSONObject cashbillPayCost = Accountbalance.createCashbillPay(this, pay_enterpriseid, sa_accountclassid, entityCost, true);
|
|
|
sqlList.addAll(cashbillPayCost.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
sa_cashbillidList.add(cashbillPayCost.getLong("sa_cashbillid"));
|
|
|
@@ -2636,7 +2617,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
} else {
|
|
|
if (Accountbalance.judgeBalance(this, pay_enterpriseid, jsonObject.getLong("sa_accountclassid"), amount1)) {
|
|
|
- CashbillEntity entity = getCashbillEntity(getDate_Str(),amount1, sa_orderid, "订单提交", sonum, "由订单号" + sonum + "提交时生成");
|
|
|
+ CashbillEntity entity = getCashbillEntity(getDate_Str(), amount1, sa_orderid, "订单提交", sonum, "由订单号" + sonum + "提交时生成");
|
|
|
//
|
|
|
if (accountclassrowsMap.containsKey(jsonObject.getString("sa_accountclassid")) && accountclassrowsMap.get(jsonObject.getString("sa_accountclassid")).isNotEmpty()) {
|
|
|
jsonObject.put("balance", accountclassrowsMap.get(jsonObject.getString("sa_accountclassid")).get(0).getBigDecimal("balance").subtract(amount1));
|
|
|
@@ -2654,7 +2635,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
} else {
|
|
|
if (Accountbalance.judgeBalance(this, pay_enterpriseid, sa_accountclassid, amount.add(costamount))) {
|
|
|
- CashbillEntity entity = getCashbillEntity(getDate_Str(),amount, sa_orderid, "订单提交", sonum, "由" + sonum + "订单提交时自动产生");
|
|
|
+ CashbillEntity entity = getCashbillEntity(getDate_Str(), amount, sa_orderid, "订单提交", sonum, "由" + sonum + "订单提交时自动产生");
|
|
|
JSONObject cashbillPay = Accountbalance.createCashbillPay(this, pay_enterpriseid, sa_accountclassid, entity, true);
|
|
|
// sqlList.addAll(cashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
ArrayList<String> sqlList2 = (ArrayList<String>) cashbillPay.getJSONArray("sqlList").toJavaList(String.class);
|
|
|
@@ -2663,7 +2644,7 @@ public class Order extends Controller {
|
|
|
|
|
|
//定制费用
|
|
|
if (costamount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- CashbillEntity entityCost = getCashbillEntity(getDate_Str(),costamount, sa_orderid, "订单提交", sonum, "由" + sonum + "【定制费用】订单提交时自动产生");
|
|
|
+ CashbillEntity entityCost = getCashbillEntity(getDate_Str(), costamount, sa_orderid, "订单提交", sonum, "由" + sonum + "【定制费用】订单提交时自动产生");
|
|
|
JSONObject cashbillPayCost = Accountbalance.createCashbillPay(this, pay_enterpriseid, sa_accountclassid, entityCost, true);
|
|
|
sqlList.addAll(cashbillPayCost.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
sa_cashbillidList.add(cashbillPayCost.getLong("sa_cashbillid"));
|
|
|
@@ -2709,6 +2690,48 @@ public class Order extends Controller {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ if (agentrows.get(0).getBoolean("submitautocheck") && type.equals("配件订单")) {
|
|
|
+ boolean isautocheck = true;
|
|
|
+ Rows countRows = dbConnect.runSqlQuery("SELECT sum(t1.amount) amount,count(t1.sa_orderitemsid) counts,sum(ispartorderautocheck) ispartorderautocheck,sum(IF(LENGTH(t1.remarks)> 0,1,0)) remarks FROM sa_orderitems t1 " + "INNER JOIN plm_item t2 ON t2.itemid=t1.itemid WHERE t1.sa_orderid=" + sa_orderid);
|
|
|
+ if (countRows.isEmpty()) {
|
|
|
+ isautocheck = false;
|
|
|
+ }
|
|
|
+ Row countRow = countRows.get(0);
|
|
|
+ if (countRow.getLong("remarks") > 0) {
|
|
|
+ isautocheck = false;
|
|
|
+ }
|
|
|
+ if (countRow.getLong("ispartorderautocheck") != countRow.getLong("counts")) {
|
|
|
+ isautocheck = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ Rows accountbalanceRows = dbConnect.runSqlQuery("SELECT IFNULL(balance,0)+IFNULL(creditquota,0)+IFNULL(discountamount,0)-IFNULL(freezamount,0) AS canuseamount FROM sa_accountbalance WHERE sys_enterpriseid=" + sys_enterpriseid + " AND sa_accountclassid=" + sa_accountclassid);
|
|
|
+ if (accountbalanceRows.isEmpty()) {
|
|
|
+ isautocheck = false;
|
|
|
+ }
|
|
|
+ BigDecimal canuseamount = accountbalanceRows.get(0).getBigDecimal("canuseamount");
|
|
|
+ if (canuseamount.compareTo(countRow.getBigDecimal("amount")) < 0) {
|
|
|
+ isautocheck = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ Rows otherRows = dbConnect.runSqlQuery(" SELECT count(t3.sa_orderid) counts from sa_orderitems t1 " +
|
|
|
+ " INNER JOIN sa_warrantycard t2 ON t2.cardno=t1.cardno " +
|
|
|
+ " INNER JOIN sa_order t3 ON t3.sa_orderid=t1.sa_orderid " +
|
|
|
+ " WHERE t1.billingstatus in ('保内收费') and t1.sa_orderid!='" + sa_orderid + "' " +
|
|
|
+ " and t1.cardno in (SELECT cardno from sa_orderitems WHERE sa_orderid=" + sa_orderid + ") " +
|
|
|
+ " and t3.submitdate> NOW() - INTERVAL " + Parameter.getLong("MD", "warrantywarndays") + " DAY and t3.status='提交' ");
|
|
|
+
|
|
|
+ if (otherRows.get(0).getLong("counts") > 0) {
|
|
|
+ isautocheck = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isautocheck) {
|
|
|
+ String result = check();
|
|
|
+ if (result.contains("成功")) {
|
|
|
+ dbConnect.runSqlUpdate("update sa_order set checkby='自动审核' where sa_orderid=" + sa_orderid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return getSucReturnObject().toString();
|
|
|
@@ -2746,7 +2769,7 @@ public class Order extends Controller {
|
|
|
//金额=金额-返利金金额
|
|
|
BigDecimal amount = beans.order.Order.getAmount(this, sa_orderid);
|
|
|
//创建支出凭证
|
|
|
- CashbillEntity entity = getCashbillEntity(getDate_Str(),amount, sa_orderid, source, sonum, "由" + sonum + source + "时自动产生");
|
|
|
+ CashbillEntity entity = getCashbillEntity(getDate_Str(), amount, sa_orderid, source, sonum, "由" + sonum + source + "时自动产生");
|
|
|
JSONObject cashbillPay = Accountbalance.createCashbillPay(this, pay_enterpriseid, sa_accountclassid, entity, true);
|
|
|
sqlList.addAll(cashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
Long sa_cashbillid1 = cashbillPay.getLong("sa_cashbillid");
|
|
|
@@ -2765,7 +2788,7 @@ public class Order extends Controller {
|
|
|
|
|
|
//返利代金券小于返利金金额,例如:rebate_balance:10,rebateamount:50
|
|
|
if (rebate_balance.compareTo(rebateamount) == -1) {
|
|
|
- entity2 = getCashbillEntity(getDate_Str(),rebate_balance, sa_orderid, source, sonum, "【返利金】由" + sonum + source + "时自动产生");
|
|
|
+ entity2 = getCashbillEntity(getDate_Str(), rebate_balance, sa_orderid, source, sonum, "【返利金】由" + sonum + source + "时自动产生");
|
|
|
rebateamount = rebateamount.subtract(rebate_balance);
|
|
|
rebate_balance = BigDecimal.ZERO;
|
|
|
|
|
|
@@ -2773,14 +2796,14 @@ public class Order extends Controller {
|
|
|
}
|
|
|
//返利代金券等于返利金金额
|
|
|
if (rebate_balance.compareTo(rebateamount) == 0) {
|
|
|
- entity2 = getCashbillEntity(getDate_Str(),rebate_balance, sa_orderid, source, sonum, "【返利金】由" + sonum + source + "时自动产生");
|
|
|
+ entity2 = getCashbillEntity(getDate_Str(), rebate_balance, sa_orderid, source, sonum, "【返利金】由" + sonum + source + "时自动产生");
|
|
|
rebateamount = BigDecimal.ZERO;
|
|
|
rebate_balance = BigDecimal.ZERO;
|
|
|
|
|
|
}
|
|
|
//返利代金券大于返利金金额
|
|
|
if (rebate_balance.compareTo(rebateamount) == 1) {
|
|
|
- entity2 = getCashbillEntity(getDate_Str(),rebateamount, sa_orderid, source, sonum, "【返利金】由" + sonum + source + "时自动产生");
|
|
|
+ entity2 = getCashbillEntity(getDate_Str(), rebateamount, sa_orderid, source, sonum, "【返利金】由" + sonum + source + "时自动产生");
|
|
|
rebate_balance = rebate_balance.subtract(rebateamount);
|
|
|
rebateamount = BigDecimal.ZERO;
|
|
|
|
|
|
@@ -2885,7 +2908,7 @@ public class Order extends Controller {
|
|
|
for (Object object : accountclassinfos) {
|
|
|
JSONObject jsonObject = (JSONObject) object;
|
|
|
if (Accountbalance.judgeBalance(this, pay_enterpriseid, jsonObject.getLong("sa_accountclassid"), jsonObject.getBigDecimal("amount"))) {
|
|
|
- CashbillEntity entity = getCashbillEntity(getDate_Str(),jsonObject.getBigDecimal("amount"), sa_orderid, "订单审核", sonum, "由订单号" + sonum + "审核时生成");
|
|
|
+ CashbillEntity entity = getCashbillEntity(getDate_Str(), jsonObject.getBigDecimal("amount"), sa_orderid, "订单审核", sonum, "由订单号" + sonum + "审核时生成");
|
|
|
jsonObject.put("balance", jsonObject.getBigDecimal("balance").subtract(jsonObject.getBigDecimal("amount")));
|
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(this, pay_enterpriseid, jsonObject.getLong("sa_accountclassid"), entity, true);
|
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
@@ -2896,7 +2919,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
} else {
|
|
|
if (Accountbalance.judgeBalance(this, pay_enterpriseid, sa_accountclassid, amount)) {
|
|
|
- CashbillEntity entity = getCashbillEntity(getDate_Str(),amount, sa_orderid, "订单审核", sonum, "由" + sonum + "订单审核时自动产生");
|
|
|
+ CashbillEntity entity = getCashbillEntity(getDate_Str(), amount, sa_orderid, "订单审核", sonum, "由" + sonum + "订单审核时自动产生");
|
|
|
JSONObject cashbillPay = Accountbalance.createCashbillPay(this, pay_enterpriseid, sa_accountclassid, entity, true);
|
|
|
sqlList.addAll(cashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
sa_cashbillidList.add(cashbillPay.getLong("sa_cashbillid"));
|
|
|
@@ -3498,7 +3521,7 @@ public class Order extends Controller {
|
|
|
amount = rebateRow.getBigDecimal("amount");
|
|
|
if (amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
Long sa_cashbillid_rebate = rebateRow.getLong("sa_cashbillid_rebate");
|
|
|
- CashbillEntity entity = getCashbillEntity(getDate_Str(),amount.negate(), sa_orderid, source, sourcenotes, "【返利金】" + remarks);
|
|
|
+ CashbillEntity entity = getCashbillEntity(getDate_Str(), amount.negate(), sa_orderid, source, sourcenotes, "【返利金】" + remarks);
|
|
|
sqlList.addAll(beans.order.Order.createRebateBillPay(this, entity, pay_enterpriseid, sa_cashbillid_rebate));
|
|
|
}
|
|
|
}
|
|
|
@@ -3523,7 +3546,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
}
|
|
|
if (amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- CashbillEntity entity = getCashbillEntity(getDate_Str(),amount.negate(), sa_orderid, source, sourcenotes, remarks);
|
|
|
+ CashbillEntity entity = getCashbillEntity(getDate_Str(), amount.negate(), sa_orderid, source, sourcenotes, remarks);
|
|
|
JSONObject cashbillPay = Accountbalance.createCashbillPay(this, pay_enterpriseid, row.getLong("sa_accountclassid"), entity, true);
|
|
|
sqlList.addAll(cashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
cashJsonObject.put("sa_cashbillid", cashbillPay.getLongValue("sa_cashbillid"));
|