Browse Source

订单一键出库时增加销售出库单联系人信息及负数支出凭证审核时不做余额判断

hu 5 tháng trước cách đây
mục cha
commit
68e1f1c265

+ 64 - 64
src/custom/beans/accountbalance/Accountbalance.java

@@ -252,7 +252,7 @@ public class Accountbalance extends BaseClass {
                 throw new YosException(false, "该营销账户不存在,支出凭证无法审核");
             } else {
                 BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("balance")).add(rowsaccountbalance.get(0).getBigDecimal("discountamount"));
-                if ((cashbillEntity.getAmount().add(cashbillEntity.getDiscountamountamount())).compareTo(canuseamount) == 1) {
+                if ((cashbillEntity.getAmount().add(cashbillEntity.getDiscountamountamount())).compareTo(canuseamount) == 1 && (cashbillEntity.getAmount().add(cashbillEntity.getDiscountamountamount())).compareTo(BigDecimal.ZERO)>=0) {
                     throw new YosException(false, "该营销账户可用余额不足,支出凭证无法审核");
                 }
                 BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(cashbillEntity.getAmount());
@@ -359,69 +359,69 @@ public class Accountbalance extends BaseClass {
     }
 
 
-    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<>();
-        long sa_cashbillid = controller.createTableID("sa_cashbill");
-        String billcode = controller.createBillCode("cashbill1");
-        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("discountamount", cashbillEntity.getDiscountamountamount());
-        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("sa_cashbillid_rebate", sa_cashbillid_rebate);
-        sqlFactory.addParameter("class", cashbillEntity.getType());
-        sqlFactory.addParameter("subclass", cashbillEntity.getTypemx());
-        sqlFactory.addParameter("period", cashbillEntity.getPeriod());
-        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()) {
-                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());
-                BigDecimal newdiscountamount = rowsaccountbalance.get(0).getBigDecimal("discountamount").subtract(cashbillEntity.getDiscountamountamount());
-                sqlList.add("update sa_accountbalance set balance='" + newbalance + "',discountamount='" + newdiscountamount + "',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);
-        }
-        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<>();
+//        long sa_cashbillid = controller.createTableID("sa_cashbill");
+//        String billcode = controller.createBillCode("cashbill1");
+//        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("discountamount", cashbillEntity.getDiscountamountamount());
+//        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("sa_cashbillid_rebate", sa_cashbillid_rebate);
+//        sqlFactory.addParameter("class", cashbillEntity.getType());
+//        sqlFactory.addParameter("subclass", cashbillEntity.getTypemx());
+//        sqlFactory.addParameter("period", cashbillEntity.getPeriod());
+//        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()) {
+//                throw new YosException(false, "该营销账户不存在,支出凭证无法审核");
+//            } else {
+//                BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("balance"));
+//                if (cashbillEntity.getAmount().compareTo(canuseamount) == 1 && (cashbillEntity.getAmount().add(cashbillEntity.getDiscountamountamount())).compareTo(BigDecimal.ZERO)>=0) {
+//                    throw new YosException(false, "该营销账户可用余额不足,支出凭证无法审核");
+//                }
+//                BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(cashbillEntity.getAmount());
+//                BigDecimal newdiscountamount = rowsaccountbalance.get(0).getBigDecimal("discountamount").subtract(cashbillEntity.getDiscountamountamount());
+//                sqlList.add("update sa_accountbalance set balance='" + newbalance + "',discountamount='" + newdiscountamount + "',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);
+//        }
+//        sqlList.add(sqlFactory.getSQL());
+//
+//        JSONObject jsonObject = new JSONObject();
+//        jsonObject.put("sa_cashbillid", sa_cashbillid);
+//        jsonObject.put("sqlList", sqlList);
+//        return jsonObject;
+//    }
 
     /**
      * 创建收入凭证(直接执行SQL语句)

+ 1 - 1
src/custom/restcontroller/sale/cashbill/cashbill.java

@@ -686,7 +686,7 @@ public class cashbill extends Controller {
                     return getErrReturnObject().setErrMsg("该营销账户不存在,支出凭证无法审核").toString();
                 } else {
                     BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("amount")).add(rowsaccountbalance.get(0).getBigDecimal("discountamount"));
-                    if (rows.get(0).getBigDecimal("amount").compareTo(canuseamount) == 1) {
+                    if (rows.get(0).getBigDecimal("amount").compareTo(canuseamount) == 1 && rows.get(0).getBigDecimal("amount").compareTo(BigDecimal.ZERO)>=0) {
                         return getErrReturnObject().setErrMsg("该营销账户可用余额不足,支出凭证无法审核").toString();
                     }
                     BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(rows.get(0).getBigDecimal("amount"));

+ 13 - 3
src/custom/restcontroller/webmanage/sale/order/Order.java

@@ -1586,6 +1586,11 @@ public class Order extends Controller {
         if(enterprisefinancerows.isNotEmpty()){
             enterprisefinancerow=enterprisefinancerows.get(0);
         }
+        Row reccontactrow =new Row();
+        Rows reccontactrows = dbConnect.runSqlQuery("select t1.* from sys_enterprise_contacts t1 inner join sa_order t2 on t1.contactsid=t2.rec_contactsid where t2.sa_orderid="+sa_orderid);
+        if(reccontactrows.isNotEmpty()){
+            reccontactrow=reccontactrows.get(0);
+        }
         if(stockbillRows.isNotEmpty()){
             return getErrReturnObject().setErrMsg("存在订单明细已生成销售出库单,无法一键出库").toString();
         }
@@ -1632,6 +1637,11 @@ public class Order extends Controller {
         insertSQL.setValue("invoice_enterprisename", enterprisefinancerow.getString("enterprisename"));
         insertSQL.setValue("invoice_address", enterprisefinancerow.getString("address"));
         insertSQL.setValue("invoice_taxno", enterprisefinancerow.getString("taxno"));
+        insertSQL.setValue("rec_contactsid", reccontactrow.getString("contactsid"));
+        insertSQL.setValue("name", reccontactrow.getString("name"));
+        insertSQL.setValue("phonenumber", reccontactrow.getString("phonenumber"));
+        insertSQL.setValue("address", reccontactrow.getString("address"));
+
         insertSQL.setValue("tracknumber",enterprisefinancerow.getString(""));
         insertSQL.setValue("isconfirm", 0);
 
@@ -2637,10 +2647,10 @@ public class Order extends Controller {
 
             }
             //不要放到sqlList中,多张返利金时会出现同时使用同一个余额减
-            JSONObject cashbillPay1 = Accountbalance.createCashbillPay(this, pay_enterpriseid, sa_accountclassid, entity2, true, sa_cashbillid);
-            dbConnect.runSqlUpdate(new ArrayList<>(cashbillPay1.getJSONArray("sqlList").toJavaList(String.class)));
+            //JSONObject cashbillPay1 = Accountbalance.createCashbillPay(this, pay_enterpriseid, sa_accountclassid, entity2, true, sa_cashbillid);
+            //dbConnect.runSqlUpdate(new ArrayList<>(cashbillPay1.getJSONArray("sqlList").toJavaList(String.class)));
 
-            Accountbalance.remindSend(this, pay_enterpriseid, cashbillPay1.getLong("sa_cashbillid"));
+           // Accountbalance.remindSend(this, pay_enterpriseid, cashbillPay1.getLong("sa_cashbillid"));
 
             sqlList.add(updateCashbillSql(sa_cashbillid, rebate_balance));
             count++;