Jelajahi Sumber

自动生成收支凭证设置分类

郭齐峰 2 tahun lalu
induk
melakukan
391b1bbc74

+ 6 - 67
src/custom/beans/accountbalance/Accountbalance.java

@@ -90,6 +90,8 @@ public class Accountbalance extends BaseClass {
         sqlFactory.addParameter("source", cashbillEntity.getSource());
         sqlFactory.addParameter("sourcenote", cashbillEntity.getSourcenote());
         sqlFactory.addParameter("sa_cashbillid_rebate", "null");
+        sqlFactory.addParameter("class", cashbillEntity.getType());
+        sqlFactory.addParameter("subclass", cashbillEntity.getTypemx());
         if (ischeck) {
             BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
             sqlFactory.addParameter("status", "审核");
@@ -166,6 +168,8 @@ public class Accountbalance extends BaseClass {
         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");
         if (ischeck) {
             BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
@@ -211,73 +215,6 @@ public class Accountbalance extends BaseClass {
         return sqlList;
     }
 
-    public static ArrayList<String> createCashbillIncome(Controller controller, long sys_enterpriseid, long sa_accountclassid,CashbillEntity cashbillEntity,Boolean ischeck,String type,String typemx) 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", 1);
-        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("sa_cashbillid_rebate", "null");
-        sqlFactory.addParameter("class", type);
-        sqlFactory.addParameter("subclass", typemx);
-        if (ischeck) {
-            BigDecimal balance;  //当前账户余额
-            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 accountbalanceaddSqlFactory = new SQLFactory(new Accountbalance(), "营销账户余额新增");
-                accountbalanceaddSqlFactory.addParameter("sa_accountbalanceid",
-                        controller.createTableID("sa_accountbalance"));
-                accountbalanceaddSqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-                accountbalanceaddSqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
-                accountbalanceaddSqlFactory.addParameter("siteid", controller.siteid);
-                accountbalanceaddSqlFactory.addParameter("balance", cashbillEntity.getAmount());
-                accountbalanceaddSqlFactory.addParameter("userid", controller.userid);
-                accountbalanceaddSqlFactory.addParameter("username", controller.username);
-                balance = cashbillEntity.getAmount();
-                sqlList.add(accountbalanceaddSqlFactory.getSQL());
-            } else {
-                BigDecimal newbalance = cashbillEntity.getAmount().add(rowsaccountbalance.get(0).getBigDecimal("balance"));
-                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);
-        } else {
-            sqlFactory.addParameter("status", "新建");
-            sqlFactory.addParameter("checkby", "null");
-            sqlFactory.addParameter("checkdate", "null");
-            sqlFactory.addParameter("balance", 0);
-        }
-        sqlList.add(sqlFactory.getSQL());
-        String content = "您有一项来自【" + cashbillEntity.getSource() + "】金额为" + cashbillEntity.getAmount() + "的【收入】凭证";
-        new Accountbalance().sendMsg(controller, content, cashbillEntity.getOwnerid(), sys_enterpriseid);
-        return sqlList;
-    }
 
     public static ArrayList<String> createCashbillPay(Controller controller, long sys_enterpriseid, long sa_accountclassid, CashbillEntity cashbillEntity, boolean ischeck, Long sa_cashbillid_rebate) throws YosException {
         ArrayList<String> sqlList = new ArrayList<>();
@@ -299,6 +236,8 @@ public class Accountbalance extends BaseClass {
         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());
         if (ischeck) {
             BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
             sqlFactory.addParameter("status", "审核");

+ 93 - 56
src/custom/beans/accountbalance/CashbillEntity.java

@@ -1,63 +1,100 @@
 package beans.accountbalance;
 
+import org.apache.commons.lang.StringUtils;
+
 import java.math.BigDecimal;
 
 public class CashbillEntity {
 
-	private BigDecimal amount;
-	private String remarks;
-	private String source;
-	private String sourcenote;
-	private String ownertable;
-	private long ownerid;
-
-	public CashbillEntity() {
-	}
-
-	public CashbillEntity(BigDecimal amount, String remarks, String source, String sourcenote, String ownertable, long ownerid) {
-		this.amount = amount;
-		this.remarks = remarks;
-		this.source = source;
-		this.sourcenote = sourcenote;
-		this.ownertable = ownertable;
-		this.ownerid = ownerid;
-	}
-
-
-	public BigDecimal getAmount() {
-		return amount;
-	}
-	public void setAmount(BigDecimal amount) {
-		this.amount = amount;
-	}
-	public String getRemarks() {
-		return remarks;
-	}
-	public void setRemarks(String remarks) {
-		this.remarks = remarks;
-	}
-	public String getSource() {
-		return source;
-	}
-	public void setSource(String source) {
-		this.source = source;
-	}
-	public String getSourcenote() {
-		return sourcenote;
-	}
-	public void setSourcenote(String sourcenote) {
-		this.sourcenote = sourcenote;
-	}
-	public String getOwnertable() {
-		return ownertable;
-	}
-	public void setOwnertable(String ownertable) {
-		this.ownertable = ownertable;
-	}
-	public long getOwnerid() {
-		return ownerid;
-	}
-	public void setOwnerid(long ownerid) {
-		this.ownerid = ownerid;
-	}
+    private BigDecimal amount;
+    private String remarks;
+    private String source;
+    private String sourcenote;
+    private String ownertable;
+    private long ownerid;
+
+
+    private String type = "货款";
+
+    private String typemx;
+
+    public CashbillEntity() {
+    }
+
+    public CashbillEntity(BigDecimal amount, String remarks, String source, String sourcenote, String ownertable, long ownerid, String type, String typemx) {
+        this.amount = amount;
+        this.remarks = remarks;
+        this.source = source;
+        this.sourcenote = sourcenote;
+        this.ownertable = ownertable;
+        this.ownerid = ownerid;
+        this.type = type;
+        this.typemx = typemx;
+    }
+
+    public String getType() {
+        if (this.type == null) type = "";
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getTypemx() {
+        if (this.typemx == null) typemx = "";
+        return typemx;
+    }
+
+    public void setTypemx(String typemx) {
+        this.typemx = typemx;
+    }
+
+    public BigDecimal getAmount() {
+        return amount;
+    }
+
+    public void setAmount(BigDecimal amount) {
+        this.amount = amount;
+    }
+
+    public String getRemarks() {
+        return remarks;
+    }
+
+    public void setRemarks(String remarks) {
+        this.remarks = remarks;
+    }
+
+    public String getSource() {
+        return source;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
+    public String getSourcenote() {
+        return sourcenote;
+    }
+
+    public void setSourcenote(String sourcenote) {
+        this.sourcenote = sourcenote;
+    }
+
+    public String getOwnertable() {
+        return ownertable;
+    }
+
+    public void setOwnertable(String ownertable) {
+        this.ownertable = ownertable;
+    }
+
+    public long getOwnerid() {
+        return ownerid;
+    }
+
+    public void setOwnerid(long ownerid) {
+        this.ownerid = ownerid;
+    }
 }

+ 2 - 2
src/custom/beans/accountbalance/SQL/收支凭证新增.sql

@@ -1,4 +1,4 @@
 insert into sa_cashbill (siteid, sa_cashbillid, createuserid,createby, createdate, billno,changeuserid,changeby, changedate,checkby,checkdate,
-                                sys_enterpriseid, sa_accountclassid,type,remarks,amount,status,source,sourcenote,ownertable,ownerid,balance,sa_cashbillid_rebate)
+                                sys_enterpriseid, sa_accountclassid,type,remarks,amount,status,source,sourcenote,ownertable,ownerid,balance,sa_cashbillid_rebate,class,subclass)
 values ($siteid$, $sa_cashbillid$,$userid$,$username$, CURRENT_TIME, $billno$,$userid$, $username$, CURRENT_TIME,$checkby$,$checkdate$,$sys_enterpriseid$,$sa_accountclassid$,$type$,$remarks$,
-        $amount$,$status$,$source$,$sourcenote$,$ownertable$,$ownerid$,$balance$,$sa_cashbillid_rebate$);
+        $amount$,$status$,$source$,$sourcenote$,$ownertable$,$ownerid$,$balance$,$sa_cashbillid_rebate$,$class$,$subclass$);

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

@@ -2492,7 +2492,7 @@ public class Order extends Controller {
             return getErrReturnObject().setErrMsg("存在未关闭的发货单,无法关闭").toString();
         }
         ArrayList<String> sqlList = new ArrayList<>();
-        sqlList.add("UPDATE sa_order SET STATUS='手工关闭',closedate=current_time,closeby='"+username+"' WHERE sa_orderid='" + sa_orderid + "' and siteid = '" + siteid + "'");
+        sqlList.add("UPDATE sa_order SET STATUS='手工关闭',closedate=current_time,closeby='" + username + "' WHERE sa_orderid='" + sa_orderid + "' and siteid = '" + siteid + "'");
         sqlList.add("UPDATE sa_orderitems SET isclose=1 WHERE sa_orderid='" + sa_orderid + "' and siteid = '" + siteid + "'");
 
         Rows rows = dbConnect.runSqlQuery("SELECT sum(undeliqty*price) totalprice from sa_orderitems WHERE sa_orderid=" + sa_orderid + " and siteid = '" + siteid + "'");
@@ -2519,13 +2519,13 @@ public class Order extends Controller {
 
     @API(title = "获取当前账号的角色名", apiversion = R.ID20230524160003.v1.class)
     public String getrolename() throws YosException {
-        Rows rows = dbConnect.runSqlQuery("select rolename from sys_userrole t1 inner join sys_role t2 on t1.roleid=t2.roleid and t1.siteid=t2.siteid where t1.siteid='"+siteid+"' and t1.userid="+userid);
-        RowsMap rowsMap =rows.toRowsMap("rolename");
-        String rolename ="其他";
-        if(rowsMap.containsKey("电商部")){
-            rolename="电商";
-        }else if(rowsMap.containsKey("工程部")){
-            rolename="工程";
+        Rows rows = dbConnect.runSqlQuery("select rolename from sys_userrole t1 inner join sys_role t2 on t1.roleid=t2.roleid and t1.siteid=t2.siteid where t1.siteid='" + siteid + "' and t1.userid=" + userid);
+        RowsMap rowsMap = rows.toRowsMap("rolename");
+        String rolename = "其他";
+        if (rowsMap.containsKey("电商部")) {
+            rolename = "电商";
+        } else if (rowsMap.containsKey("工程部")) {
+            rolename = "工程";
         }
         return getSucReturnObject().setData(rolename).toString();
     }

+ 2 - 2
src/custom/restcontroller/webmanage/sale/paybill/Paybill.java

@@ -198,8 +198,8 @@ public class Paybill extends Controller {
         String remarks = rows.get(0).getString("remarks");
         for (Row row : accountclassRows) {
             BigDecimal amount = row.getBigDecimal("amount");
-            CashbillEntity cashbillEntity = new CashbillEntity(amount, remarks, "打款凭证", billno, "sa_paybill", sa_paybillid);
-            sqlList.addAll(Accountbalance.createCashbillIncome(this, sys_enterpriseid, row.getLong("sa_accountclassid"), cashbillEntity, false, "货款", ""));
+            CashbillEntity cashbillEntity = new CashbillEntity(amount, remarks, "打款凭证", billno, "sa_paybill", sa_paybillid,"货款","");
+            sqlList.addAll(Accountbalance.createCashbillIncome(this, sys_enterpriseid, row.getLong("sa_accountclassid"), cashbillEntity, false));
         }
         dbConnect.runSqlUpdate(sqlList);
         return getSucReturnObject().toString();

+ 3 - 3
src/custom/restcontroller/webmanage/sale/transferbill/Transferbill.java

@@ -118,10 +118,10 @@ public class Transferbill extends Controller {
         }
         ArrayList<String> sqlList = new ArrayList<>();
         sqlList.add("update sa_transferbill set checkby='" + username + "',checkdate=current_date,status='审核' where siteid='" + siteid + "' and sa_transferbillid=" + sa_transferbillid);
-        CashbillEntity cashbillEntity = new CashbillEntity(amount.negate(), "", "转账单", rows.get(0).getString("billno"), "sa_transferbill", sa_transferbillid);
-        sqlList.addAll(Accountbalance.createCashbillIncome(this, sys_enterpriseid, sa_accountclassid, cashbillEntity, true,"货款",""));
+        CashbillEntity cashbillEntity = new CashbillEntity(amount.negate(), "", "转账单", rows.get(0).getString("billno"), "sa_transferbill", sa_transferbillid,"货款","");
+        sqlList.addAll(Accountbalance.createCashbillIncome(this, sys_enterpriseid, sa_accountclassid, cashbillEntity, true));
         cashbillEntity.setAmount(amount);
-        sqlList.addAll(Accountbalance.createCashbillIncome(this, sys_enterpriseid, inaccountclassid, cashbillEntity, true,"货款",""));
+        sqlList.addAll(Accountbalance.createCashbillIncome(this, sys_enterpriseid, inaccountclassid, cashbillEntity, true));
         dbConnect.runSqlUpdate(sqlList);
         return getSucReturnObject().toString();
     }