Ver Fonte

收入凭证反审核及订单反审核反提交去除相应的审核人时间及提交人时间

hu há 2 anos atrás
pai
commit
bc2d05b6e3

+ 1 - 0
src/custom/restcontroller/sale/cashbill/SQL/收支凭证反审核.sql

@@ -0,0 +1 @@
+update sa_cashbill set status='新建',checkby='',checkdate=null,balance=$balance$ where sa_cashbillid = $sa_cashbillid$ and siteid=$siteid$

+ 1 - 1
src/custom/restcontroller/sale/cashbill/SQL/收支凭证审核.sql

@@ -1 +1 @@
-update sa_cashbill set status='审核',checkby=$checkby$,checkdate=CURRENT_TIMESTAMP,balance=$balance$ where sa_cashbillid = $sa_cashbillid$ and siteid=$siteid$ 
+update sa_cashbill set status='审核',checkby=$checkby$,checkdate=CURRENT_TIMESTAMP,balance=$balance$ where sa_cashbillid = $sa_cashbillid$ and siteid=$siteid$

+ 66 - 0
src/custom/restcontroller/sale/cashbill/cashbill.java

@@ -608,7 +608,73 @@ public class cashbill extends Controller {
         dbConnect.runSqlUpdate(sqlList);
         dbConnect.runSqlUpdate(sqlList);
         return getSucReturnObject().toString();
         return getSucReturnObject().toString();
     }
     }
+    /**
+     * 收支凭证反审核
+     *
+     * @return
+     */
+    @API(title = "收入凭证反审核", apiversion = R.ID20230509085703.v1.class)
+    @CACHEING_CLEAN(apiversions = {R.ID20221009102903.v1.class, R.ID20221010102903.v1.class, R.ID20221009103003.v1.class, R.ID20221008145903.v1.class, R.ID20221009160003.v1.class, R.ID20230111103403.v1.class})
+    public String unrelease() throws YosException {
+        long sa_cashbillid = content.getLong("sa_cashbillid");
+        //List<String> list = sa_creditbillids.toJavaList(String.class);
+        //String[] stringArray = list.toArray(new String[0]);
+        //SQLFactory sqlFactoryquery = new SQLFactory(this, "信用额度调整单状态查询");
+        //sqlFactoryquery.addParameter("siteid", siteid);
+        //sqlFactoryquery.addParameter_in("sa_creditbillids", stringArray);
+        Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='" + siteid + "'");
+        for (Row row : rows) {
+            if (!row.getString("status").equals("审核")) {
+                return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的收支凭证为非审核状态,无法反审核")
+                        .toString();
+            }
+            if ( rows.get(0).getLong("type")!=1) {
+                return getErrReturnObject().setErrMsg("非收入凭证无法反审核")
+                        .toString();
+            }
+        }
+
+        ArrayList<String> sqlList = new ArrayList<>();
+        BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
+        if (!rows.isEmpty()) {
+            long sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
+            long sa_accountclassid = rows.get(0).getLong("sa_accountclassid");
+            long type = rows.get(0).getLong("type");
+            Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
+             System.out.println("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
+            if (type == 1) {
+                Rows offsettingRows = dbConnect.runSqlQuery("select amount from sa_cashbill where siteid='" + siteid + "' and ownertable='sa_cashbill' and ownerid=" + rows.get(0).getLong("ownerid"));
+                if (offsettingRows.isNotEmpty()) {
+                    sqlList.add("update sa_cashbill set writeoffamount=writeoffamount+" + offsettingRows.get(0).getBigDecimal("amount").abs() + " where siteid='" + siteid + "' and sa_cashbillid=" + rows.get(0).getLong("ownerid"));
+                }
+                if (rowsaccountbalance.isEmpty()) {
+                    return getErrReturnObject().setErrMsg("该营销账户不存在,收入凭证无法反审核")
+                            .toString();
+                } else {
+                    BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("balance"));
+                    if (rows.get(0).getBigDecimal("amount").compareTo(canuseamount) == 1) {
+                        return getErrReturnObject().setErrMsg("该营销账户可用余额不足,收入凭证无法反审核")
+                                .toString();
+                    }
+                    BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(rows.get(0).getBigDecimal("amount"));
+                    balance = newbalance;
+                    sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + username + "',changeuserid='" + userid + "' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
+                }
+
+                sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "反审核", "收入凭证反审核成功").getSQL());
+            }
+
 
 
+        }
+
+        SQLFactory sqlFactoryupdate = new SQLFactory(this, "收支凭证反审核");
+        sqlFactoryupdate.addParameter("siteid", siteid);
+        sqlFactoryupdate.addParameter("sa_cashbillid", sa_cashbillid);
+        sqlFactoryupdate.addParameter("balance", balance);
+        sqlList.add(sqlFactoryupdate.getSQL());
+        dbConnect.runSqlUpdate(sqlList);
+        return getSucReturnObject().toString();
+    }
 
 
     @API(title = "删除", apiversion = R.ID20221009103203.v1.class)
     @API(title = "删除", apiversion = R.ID20221009103203.v1.class)
     @CACHEING_CLEAN(apiversions = {R.ID20221009102903.v1.class, R.ID20221010102903.v1.class, R.ID20221009103003.v1.class, R.ID20230111103403.v1.class})
     @CACHEING_CLEAN(apiversions = {R.ID20221009102903.v1.class, R.ID20221010102903.v1.class, R.ID20221009103003.v1.class, R.ID20230111103403.v1.class})

+ 2 - 0
src/custom/restcontroller/webmanage/sale/order/SQL/订单_反审核.sql

@@ -2,6 +2,8 @@ update sa_order
 set changeuserid=$userid$,
 set changeuserid=$userid$,
     changeby    = $username$,
     changeby    = $username$,
     changedate  = current_time,
     changedate  = current_time,
+    checkby='',
+    checkdate=null,
     status      = '提交'
     status      = '提交'
 where siteid = $siteid$
 where siteid = $siteid$
   and sa_orderid in $sa_orderid$
   and sa_orderid in $sa_orderid$

+ 2 - 0
src/custom/restcontroller/webmanage/sale/order/SQL/订单_撤回.sql

@@ -2,6 +2,8 @@ update sa_order
 set changeuserid=$userid$,
 set changeuserid=$userid$,
     changeby    = $username$,
     changeby    = $username$,
     changedate  = current_time,
     changedate  = current_time,
+    submitby='',
+    submitdate=null,
     status      = '新建'
     status      = '新建'
 where siteid = $siteid$
 where siteid = $siteid$
   and sa_orderid in $sa_orderid$
   and sa_orderid in $sa_orderid$

+ 2 - 0
src/custom/restcontroller/webmanage/sale/order/SQL/订单_退回.sql

@@ -2,6 +2,8 @@ update sa_order
 set changeuserid=$userid$,
 set changeuserid=$userid$,
     changeby    = $username$,
     changeby    = $username$,
     changedate  = current_time,
     changedate  = current_time,
+    submitby='',
+    submitdate=null,
     status      = '新建'
     status      = '新建'
 where siteid = $siteid$
 where siteid = $siteid$
   and sa_orderid in $sa_orderid$
   and sa_orderid in $sa_orderid$