郭齐峰 il y a 3 ans
Parent
commit
9def554c4b

+ 14 - 1
src/custom/beans/accountbalance/CashbillEntity.java

@@ -10,7 +10,20 @@ public class CashbillEntity {
 	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;
 	}

+ 30 - 0
src/custom/restcontroller/R.java

@@ -4736,6 +4736,36 @@ public class R {
         }
     }
 
+    public static class ID20230511144904 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20230511144804 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20230511144704 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20230511144604 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20230511144504 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20230511144404 {
+        public static class v1 {
+        }
+    }
+
 
 }
 

+ 6 - 0
src/custom/restcontroller/webmanage/sale/promotion/promotion.java

@@ -64,6 +64,9 @@ public class promotion extends Controller {
                     sqlFactory = new SQLFactory(this, "促销方案更新");
                     sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "更新", "促销方案更新成功").getSQL());
                     if (rows.get(0).getLong("authmethod") != authmethod) {
+                        if (dbConnect.runSqlQuery("select * from sa_promotion_auth where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid).isNotEmpty()) {
+                            return getErrReturnObject().setErrMsg("已有授权经销商,无法更改授权方式").toString();
+                        }
                         sqlList.add("delete from sa_promotion_auth where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
                     }
                 } else {
@@ -346,6 +349,9 @@ public class promotion extends Controller {
         if (!rows.get(0).getString("status").equals("新建")) {
             return getErrReturnObject().setErrMsg("非新建状态不能修改授权方式").toString();
         }
+        if (dbConnect.runSqlQuery("select * from sa_promotion_auth where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid).isNotEmpty()) {
+            return getErrReturnObject().setErrMsg("已有授权经销商,无法更改授权方式").toString();
+        }
         ArrayList<String> sqlList = new ArrayList<>();
         sqlList.add("delete from sa_promotion_auth where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
         if (rows.get(0).getLong("authmethod") == 0) {

+ 0 - 17
src/custom/restcontroller/webmanage/sale/promotion/promotionAuth.java

@@ -27,13 +27,6 @@ public class promotionAuth extends Controller {
         Long sa_promotionid = content.getLong("sa_promotionid");
         JSONArray enterpriseinfos = content.getJSONArray("enterpriseinfos");
         ArrayList<String> sqlList = new ArrayList<>();
-        Rows rowscount = dbConnect.runSqlQuery(
-                "select status,sa_promotionid from sa_promotion where sa_promotionid=" + sa_promotionid);
-        if (!rowscount.isEmpty()) {
-            if (!rowscount.get(0).getString("status").equals("新建")) {
-                return getErrReturnObject().setErrMsg("非新建状态的促销方案无法新增修改").toString();
-            }
-        }
         int i = 0;
         long[] sa_promotion_authid = createTableID("sa_promotion_auth", enterpriseinfos.size());
         for (Object obj : enterpriseinfos) {
@@ -138,16 +131,6 @@ public class promotionAuth extends Controller {
         BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_promotion_authids.size());
         for (Object o : sa_promotion_authids) {
             long sa_promotion_authid = Long.parseLong(o.toString());
-            Rows RowsStatus = dbConnect.runSqlQuery(
-                    "select t1.sa_promotion_authid,t2.status,t1.sa_promotionid from sa_promotion_auth t1 left join sa_promotion t2 on t1.sa_promotionid=t2.sa_promotionid and t1.siteid=t2.siteid where t1.siteid='"
-                            + siteid + "' and t1.sa_promotion_authid='" + sa_promotion_authid + "'");
-
-            if (RowsStatus.isNotEmpty()) {
-                if (!RowsStatus.get(0).getString("status").equals("新建")) {
-                    batchDeleteErr.addErr(sa_promotion_authid, "非新建状态的授权范围明细无法删除");
-                    continue;
-                }
-            }
             ArrayList<String> list = new ArrayList<>();
             SQLFactory deletesql = new SQLFactory("sql:delete from sa_promotion_auth where siteid='" + siteid
                     + "' and sa_promotion_authid=" + sa_promotion_authid);

+ 6 - 0
src/custom/restcontroller/webmanage/sale/transferbill/SQL/关联收入凭证查询.sql

@@ -0,0 +1,6 @@
+select t1.billno, t1.type, t2.accountname, t1.amount, t1.billdate
+from sa_cashbill t1
+         left join sa_accountclass t2 on t1.siteid = t2.siteid and t1.sa_accountclassid = t2.sa_accountclassid
+where t1.siteid = $siteid$
+  and t1.ownertable = 'sa_transferbill'
+  and t1.ownerid = $sa_transferbillid$

+ 20 - 0
src/custom/restcontroller/webmanage/sale/transferbill/SQL/转账单列表查询.sql

@@ -0,0 +1,20 @@
+select t1.sa_transferbillid,
+       t1.remarks,
+       t1.status,
+       t1.billno,
+       t1.billdate,
+       t1.amount,
+       t2.enterprisename,
+       t3.agentnum,
+       t4.accountname inaccountname,
+       t5.accountname,
+       t1.sa_accountclassid,
+       t1.inaccountclassid,
+       t1.sys_enterpriseid
+from sa_transferbill t1
+         left join sys_enterprise t2 on t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid
+         left join sa_agents t3 on t2.siteid = t3.siteid and t2.sys_enterpriseid = t3.sys_enterpriseid
+         left join sa_accountclass t4 on t1.siteid = t4.siteid and t1.inaccountclassid = t4.sa_accountclassid
+         left join sa_accountclass t5 on t1.siteid = t5.siteid and t1.sa_accountclassid = t5.sa_accountclassid
+where t1.siteid = $siteid$
+  and $where$

+ 6 - 0
src/custom/restcontroller/webmanage/sale/transferbill/SQL/转账单新增.sql

@@ -0,0 +1,6 @@
+insert into sa_transferbill(sa_transferbillid, remarks, status, billno, billdate, amount, inaccountclassid,
+                            sa_accountclassid, sys_enterpriseid, createuserid, createby, createdate, changeuserid,
+                            changeby, changedate,siteid)
+values ($sa_transferbillid$,$remarks$, '新建', $billno$, $billdate$, $amount$, $inaccountclassid$,
+        $sa_accountclassid$, $sys_enterpriseid$, $userid$, $username$, current_time, $userid$,
+        $username$, current_time,$siteid$)

+ 11 - 0
src/custom/restcontroller/webmanage/sale/transferbill/SQL/转账单更新.sql

@@ -0,0 +1,11 @@
+update sa_transferbill
+set remarks=$remarks$,
+    billdate=$billdate$,
+    amount=$amount$,
+    inaccountclassid=$inaccountclassid$,
+    sa_accountclassid=$sa_accountclassid$,
+    changeuserid=$userid$,
+    changeby=$username$,
+    changedate=current_time
+where siteid = $siteid$
+  and sa_transferbillid = $sa_transferbillid$

+ 24 - 0
src/custom/restcontroller/webmanage/sale/transferbill/SQL/转账单详情.sql

@@ -0,0 +1,24 @@
+select t1.sa_transferbillid,
+       t1.remarks,
+       t1.status,
+       t1.billno,
+       t1.billdate,
+       t1.amount,
+       t2.enterprisename,
+       t3.agentnum,
+       t4.accountname inaccountname,
+       t5.accountname,
+       t1.createby,
+       t1.createdate,
+       t1.changeby,
+       t1.changedate,
+       t1.sa_accountclassid,
+       t1.inaccountclassid,
+       t1.sys_enterpriseid
+from sa_transferbill t1
+         left join sys_enterprise t2 on t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid
+         left join sa_agents t3 on t2.siteid = t3.siteid and t2.sys_enterpriseid = t3.sys_enterpriseid
+         left join sa_accountclass t4 on t1.siteid = t4.siteid and t1.inaccountclassid = t4.sa_accountclassid
+         left join sa_accountclass t5 on t1.siteid = t5.siteid and t1.sa_accountclassid = t5.sa_accountclassid
+where t1.siteid = $siteid$
+  and t1.sa_transferbillid = $sa_transferbillid$

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

@@ -0,0 +1,160 @@
+package restcontroller.webmanage.sale.transferbill;
+
+import beans.accountbalance.Accountbalance;
+import beans.accountbalance.AccountbalanceEntity;
+import beans.accountbalance.CashbillEntity;
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.annotation.CACHEING;
+import common.annotation.CACHEING_CLEAN;
+import common.data.Rows;
+import common.data.SQLFactory;
+import restcontroller.R;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+
+@API(title = "转账单")
+public class Transferbill extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public Transferbill(JSONObject content) throws YosException {
+        super(content);
+    }
+
+    @API(title = "列表", apiversion = R.ID20230511144904.v1.class)
+    @CACHEING
+    public String queryList() throws YosException {
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.billno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t3.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+
+            if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
+                where.append(" and t1.billdate >='").append(whereObject.getString("begindate")).append("'");
+            }
+            if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
+                where.append(" and t1.enddate <='").append(whereObject.getString("enddate")).append("'");
+            }
+        }
+        SQLFactory sqlFactory = new SQLFactory(this, "转账单列表查询", pageSize, pageNumber, pageSorting);
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter_SQL("where", where);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "新增或更新", apiversion = R.ID20230511144804.v1.class)
+    @CACHEING_CLEAN(apiversions = {R.ID20230511144904.v1.class})
+    public String insertOrUpdate() throws YosException {
+        Long sa_transferbillid = content.getLong("sa_transferbillid");
+        Long sys_enterpriseid = content.getLong("sys_enterpriseid");
+        Long inaccountclassid = content.getLong("inaccountclassid");
+        Long sa_accountclassid = content.getLong("sa_accountclassid");
+        String billdate = content.getString("billdate");
+        BigDecimal amount = content.getBigDecimal("amount");
+        String remarks = content.getStringValue("remarks");
+        if (inaccountclassid.equals(sa_accountclassid)) {
+            return getErrReturnObject().setErrMsg("转出账户和转入账户不能一致").toString();
+        }
+        Rows rows = dbConnect.runSqlQuery("select status from sa_transferbill where siteid='" + siteid + "' and sa_transferbillid=" + sa_transferbillid);
+        SQLFactory sqlFactory = new SQLFactory(this, "转账单新增");
+        if (sa_transferbillid <= 0 || rows.isEmpty()) {
+            sa_transferbillid = createTableID("sa_transferbill");
+            String billno = createBillCode("transferbill");
+            sqlFactory.addParameter("billno", billno);
+        } else {
+            if (!rows.get(0).getString("status").equals("新建")) {
+                return getErrReturnObject().setErrMsg("非新建状态转账单不能修改").toString();
+            }
+            sqlFactory = new SQLFactory(this, "转账单更新");
+        }
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("userid", userid);
+        sqlFactory.addParameter("username", username);
+        sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
+        sqlFactory.addParameter("inaccountclassid", inaccountclassid);
+        sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
+        sqlFactory.addParameter("billdate", billdate);
+        sqlFactory.addParameter("amount", amount);
+        sqlFactory.addParameter("remarks", remarks);
+        sqlFactory.addParameter("sa_transferbillid", sa_transferbillid);
+        dbConnect.runSqlUpdate(sqlFactory.getSQL());
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "审核", apiversion = R.ID20230511144704.v1.class)
+    @CACHEING_CLEAN(apiversions = {R.ID20230511144904.v1.class, R.ID20221009102903.v1.class, R.ID20230111103403.v1.class, R.ID20221008145903.v1.class, R.ID20221009160003.v1.class})
+    public String check() throws YosException {
+        Long sa_transferbillid = content.getLong("sa_transferbillid");
+        SQLFactory sqlFactory = new SQLFactory(this, "转账单详情");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("sa_transferbillid", sa_transferbillid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        if (rows.isEmpty()) {
+            return getErrReturnObject().setErrMsg("无效转账单").toString();
+        }
+        if (!rows.get(0).getString("status").equals("新建")) {
+            return getErrReturnObject().setErrMsg("非新建状态转账单不能审核").toString();
+        }
+        long sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
+        long sa_accountclassid = rows.get(0).getLong("sa_accountclassid");
+        long inaccountclassid = rows.get(0).getLong("inaccountclassid");
+        BigDecimal amount = rows.get(0).getBigDecimal("amount");
+        if (!Accountbalance.judgeBalance(this, sys_enterpriseid, sa_accountclassid, amount)) {
+            return getErrReturnObject().setErrMsg("账户余额不足").toString();
+        }
+        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.setAmount(amount);
+        sqlList.addAll(Accountbalance.createCashbillIncome(this, sys_enterpriseid, inaccountclassid, cashbillEntity, true));
+        dbConnect.runSqlUpdate(sqlList);
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "删除", apiversion = R.ID20230511144604.v1.class)
+    @CACHEING_CLEAN(apiversions = {R.ID20230511144904.v1.class})
+    public String delete() throws YosException {
+        Long sa_transferbillid = content.getLong("sa_transferbillid");
+        Rows rows = dbConnect.runSqlQuery("select * from sa_transferbill where siteid='" + siteid + "' and sa_transferbillid=" + sa_transferbillid);
+        if (rows.isNotEmpty() && !rows.get(0).getString("status").equals("新建")) {
+            return getErrReturnObject().setErrMsg("非新建转账单无法删除").toString();
+        }
+        dbConnect.runSqlUpdate("delete from sa_transferbill where siteid='" + siteid + "' and sa_transferbillid=" + sa_transferbillid);
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "详情", apiversion = R.ID20230511144504.v1.class)
+    public String queryById() throws YosException {
+        Long sa_transferbillid = content.getLong("sa_transferbillid");
+        SQLFactory sqlFactory = new SQLFactory(this, "转账单详情");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("sa_transferbillid", sa_transferbillid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        return getSucReturnObject().setData(rows.get(0)).toString();
+    }
+
+    @API(title = "关联收入凭证查询", apiversion = R.ID20230511144404.v1.class)
+    public String queryCashbill() throws YosException {
+        Long sa_transferbillid = content.getLong("sa_transferbillid");
+        SQLFactory sqlFactory = new SQLFactory(this, "关联收入凭证查询");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("sa_transferbillid", sa_transferbillid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+}