|
@@ -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})
|