|
|
@@ -240,7 +240,7 @@ public class Accountbalance extends BaseClass {
|
|
|
throw new YosException(false, "该营销账户不存在,支出凭证无法审核");
|
|
|
} else {
|
|
|
BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("balance"));
|
|
|
- if (cashbillEntity.getAmount().compareTo(canuseamount) == 1|| canuseamount.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ if (cashbillEntity.getAmount().compareTo(canuseamount) == 1) {
|
|
|
throw new YosException(false, "该营销账户可用余额不足,支出凭证无法审核");
|
|
|
}
|
|
|
BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(cashbillEntity.getAmount());
|
|
|
@@ -268,6 +268,83 @@ public class Accountbalance extends BaseClass {
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
+ //订单手动关闭专用
|
|
|
+ public static JSONObject createCashbillPay2(Controller controller, long sys_enterpriseid, long sa_accountclassid, CashbillEntity cashbillEntity, boolean ischeck) throws YosException {
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ long sa_cashbillid = controller.createTableID("sa_cashbill");
|
|
|
+ String billcode = controller.createBillCode("cashbill");
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(new Accountbalance(), "收支凭证新增");
|
|
|
+ sqlFactory.addParameter("billno", billcode);
|
|
|
+ sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
|
|
|
+ sqlFactory.addParameter("type", 0);
|
|
|
+ sqlFactory.addParameter("siteid", controller.siteid);
|
|
|
+ sqlFactory.addParameter("remarks", cashbillEntity.getRemarks());
|
|
|
+ sqlFactory.addParameter("amount", cashbillEntity.getAmount());
|
|
|
+ sqlFactory.addParameter("sa_cashbillid", sa_cashbillid);
|
|
|
+ sqlFactory.addParameter("userid", controller.userid);
|
|
|
+ sqlFactory.addParameter("username", controller.username);
|
|
|
+ sqlFactory.addParameter("ownertable", cashbillEntity.getOwnertable());
|
|
|
+ sqlFactory.addParameter("ownerid", cashbillEntity.getOwnerid());
|
|
|
+ sqlFactory.addParameter("source", cashbillEntity.getSource());
|
|
|
+ sqlFactory.addParameter("sourcenote", cashbillEntity.getSourcenote());
|
|
|
+ sqlFactory.addParameter("class", cashbillEntity.getType());
|
|
|
+ sqlFactory.addParameter("subclass", cashbillEntity.getTypemx());
|
|
|
+ sqlFactory.addParameter("sa_cashbillid_rebate", "null");
|
|
|
+ sqlFactory.addParameter("updatek3flag", "");
|
|
|
+ if (ischeck) {
|
|
|
+ BigDecimal balance = BigDecimal.ZERO; //当前账户余额
|
|
|
+ sqlFactory.addParameter("status", "审核");
|
|
|
+ sqlFactory.addParameter("checkby", controller.username);
|
|
|
+ sqlFactory.addParameter_SQL("checkdate", "CURRENT_TIME");
|
|
|
+
|
|
|
+ // 审核逻辑判断
|
|
|
+ Rows rowsaccountbalance = controller.dbConnect.runSqlQuery(
|
|
|
+ "select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='"
|
|
|
+ + sys_enterpriseid + "' and sa_accountclassid='" + sa_accountclassid + "' and siteid='"
|
|
|
+ + controller.siteid + "'");
|
|
|
+ if (rowsaccountbalance.isEmpty()) {
|
|
|
+// SQLFactory sqlFactory = new SQLFactory(this, "营销账户余额新增");
|
|
|
+// sqlFactory.addParameter("sa_accountbalanceid", createTableID("sa_accountbalance"));
|
|
|
+// sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
+// sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
|
|
|
+// sqlFactory.addParameter("siteid", siteid);
|
|
|
+// sqlFactory.addParameter("balance", -rows.get(0).getLong("amount"));
|
|
|
+// sqlFactory.addParameter("userid", userid);
|
|
|
+// sqlFactory.addParameter("username", username);
|
|
|
+// sqlList.add(sqlFactory.getSQL());
|
|
|
+ throw new YosException(false, "该营销账户不存在,支出凭证无法审核");
|
|
|
+ } else {
|
|
|
+// BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("balance"));
|
|
|
+// if (cashbillEntity.getAmount().compareTo(canuseamount) == 1) {
|
|
|
+// throw new YosException(false, "该营销账户可用余额不足,支出凭证无法审核");
|
|
|
+// }
|
|
|
+ BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(cashbillEntity.getAmount());
|
|
|
+ sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + controller.username + "',changeuserid='" + controller.userid + "' where sys_enterpriseid ='" + sys_enterpriseid + "' and sa_accountclassid='" + sa_accountclassid + "' and siteid='" + controller.siteid + "'");
|
|
|
+ balance = newbalance;
|
|
|
+ }
|
|
|
+ sqlFactory.addParameter("balance", balance);
|
|
|
+ Rows accountclassrows = controller.dbConnect.runSqlQuery("select * from sa_accountclass where siteid='" + controller.siteid + "' and sa_accountclassid=" + sa_accountclassid);
|
|
|
+ if (!accountclassrows.isEmpty()) {
|
|
|
+ String content = "您的" + accountclassrows.get(0).getString("accountname") + "已支出【" + cashbillEntity.getAmount() + "】元";
|
|
|
+ new Accountbalance().sendMsg(controller, content, cashbillEntity.getOwnerid(), sys_enterpriseid);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ sqlFactory.addParameter("status", "新建");
|
|
|
+ sqlFactory.addParameter("checkby", "");
|
|
|
+ sqlFactory.addParameter("checkdate", "");
|
|
|
+ sqlFactory.addParameter("balance", 0);
|
|
|
+ sqlFactory.addParameter("updatek3flag", "");
|
|
|
+ }
|
|
|
+ sqlList.add(sqlFactory.getSQL());
|
|
|
+
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("sa_cashbillid", sa_cashbillid);
|
|
|
+ jsonObject.put("sqlList", sqlList);
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
public static JSONObject createCashbillPay(Controller controller, long sys_enterpriseid, long sa_accountclassid, CashbillEntity cashbillEntity, boolean ischeck, Long sa_cashbillid_rebate) throws YosException {
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
@@ -306,7 +383,7 @@ public class Accountbalance extends BaseClass {
|
|
|
throw new YosException(false, "该营销账户不存在,支出凭证无法审核");
|
|
|
} else {
|
|
|
BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("balance"));
|
|
|
- if (cashbillEntity.getAmount().compareTo(canuseamount) == 1 || canuseamount.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ if (cashbillEntity.getAmount().compareTo(canuseamount) == 1 ) {
|
|
|
throw new YosException(false, "该营销账户可用余额不足,支出凭证无法审核");
|
|
|
}
|
|
|
BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(cashbillEntity.getAmount());
|