|
|
@@ -3,20 +3,20 @@ package restcontroller.sale.cashbill;
|
|
|
import beans.clear.ClearData;
|
|
|
import beans.data.BatchDeleteErr;
|
|
|
import beans.datacontrllog.DataContrlLog;
|
|
|
-import beans.datateam.DataTeam;
|
|
|
import beans.remind.Remind;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import common.Controller;
|
|
|
import common.YosException;
|
|
|
-import common.annotation.*;
|
|
|
-import common.data.*;
|
|
|
+import common.annotation.API;
|
|
|
+import common.annotation.CACHEING;
|
|
|
+import common.annotation.CACHEING_CLEAN;
|
|
|
import common.data.Row;
|
|
|
+import common.data.*;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
|
import restcontroller.R;
|
|
|
-import restcontroller.system.attachment.Attachment;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -24,7 +24,6 @@ import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
-import static beans.order.Order.getOrderRows;
|
|
|
import static restcontroller.webmanage.saletool.orderclue.orderclue.isBigDecimal;
|
|
|
|
|
|
public class cashbill extends Controller {
|
|
|
@@ -60,8 +59,7 @@ public class cashbill extends Controller {
|
|
|
XSSFCellStyle titleCellStyle2 = IncomeExportExcel.createTitleCellStyle2(xssfFWorkbook);
|
|
|
XSSFCellStyle titleCellStyle3 = IncomeExportExcel.createBodyCellStyle(xssfFWorkbook);
|
|
|
XSSFCellStyle titleCellStyle4 = IncomeExportExcel.createTitleCellStyle3(xssfFWorkbook);
|
|
|
- IncomeExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4,
|
|
|
- xssfFWorkbook);// 写入标题
|
|
|
+ IncomeExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4, xssfFWorkbook);// 写入标题
|
|
|
|
|
|
} else if (content.getString("type").equals("支出")) {
|
|
|
PayExportExcel.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
|
|
|
@@ -69,8 +67,7 @@ public class cashbill extends Controller {
|
|
|
XSSFCellStyle titleCellStyle2 = PayExportExcel.createTitleCellStyle2(xssfFWorkbook);
|
|
|
XSSFCellStyle titleCellStyle3 = PayExportExcel.createBodyCellStyle(xssfFWorkbook);
|
|
|
XSSFCellStyle titleCellStyle4 = PayExportExcel.createTitleCellStyle3(xssfFWorkbook);
|
|
|
- PayExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4,
|
|
|
- xssfFWorkbook);// 写入标题
|
|
|
+ PayExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4, xssfFWorkbook);// 写入标题
|
|
|
} else {
|
|
|
return getErrReturnObject().setErrMsg("凭证类型不匹配,无法下载导入文件").toString();
|
|
|
}
|
|
|
@@ -118,8 +115,7 @@ public class cashbill extends Controller {
|
|
|
|
|
|
Rows agentRows = dbConnect.runSqlQuery("select agentnum,sys_enterpriseid from sa_agents where siteid='" + siteid + "'");
|
|
|
RowsMap agentRowsMap = agentRows.toRowsMap("agentnum");
|
|
|
- if (!(content.getString("type") + "凭证导入")
|
|
|
- .equals(((String) getCellFormatValue(e.getSheet(0).getRow(0).getCell(0))).replace(" ", ""))) {
|
|
|
+ if (!(content.getString("type") + "凭证导入").equals(((String) getCellFormatValue(e.getSheet(0).getRow(0).getCell(0))).replace(" ", ""))) {
|
|
|
return getErrReturnObject().setErrMsg("导入失败,不符合" + content.getString("type") + "凭证导入要求").toString();
|
|
|
}
|
|
|
Rows rows = e.getSheetRows(0, keys, 3);
|
|
|
@@ -198,8 +194,7 @@ public class cashbill extends Controller {
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
- long[] sa_cashbillid = createTableID("sa_cashbill",
|
|
|
- rowssuc.size());
|
|
|
+ long[] sa_cashbillid = createTableID("sa_cashbill", rowssuc.size());
|
|
|
if (!rowssuc.isEmpty()) {
|
|
|
for (Row row : rowssuc) {
|
|
|
SQLFactory sqlFactoryupload = new SQLFactory(this, "收支凭证新增");
|
|
|
@@ -324,10 +319,7 @@ public class cashbill extends Controller {
|
|
|
BigDecimal discountamount = content.getBigDecimal("discountamount");
|
|
|
String remarks = content.getString("remarks");
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- if (sa_cashbillid <= 0 || dbConnect
|
|
|
- .runSqlQuery("select sa_cashbillid from sa_cashbill where sa_cashbillid="
|
|
|
- + sa_cashbillid)
|
|
|
- .isEmpty()) {
|
|
|
+ if (sa_cashbillid <= 0 || dbConnect.runSqlQuery("select sa_cashbillid from sa_cashbill where sa_cashbillid=" + sa_cashbillid).isEmpty()) {
|
|
|
if (sa_cashbillid <= 0) {
|
|
|
sa_cashbillid = createTableID("sa_cashbill");
|
|
|
}
|
|
|
@@ -359,8 +351,7 @@ public class cashbill extends Controller {
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "新增", "支出凭证新增成功").getSQL());
|
|
|
}
|
|
|
} else {
|
|
|
- Rows rowscount = dbConnect.runSqlQuery(
|
|
|
- "select status from sa_cashbill where sa_cashbillid=" + sa_cashbillid);
|
|
|
+ Rows rowscount = dbConnect.runSqlQuery("select status from sa_cashbill where sa_cashbillid=" + sa_cashbillid);
|
|
|
if (rowscount.isNotEmpty()) {
|
|
|
if (!rowscount.get(0).getString("status").equals("新建")) {
|
|
|
return getErrReturnObject().setErrMsg("非新建状态的收支凭证无法更新").toString();
|
|
|
@@ -450,20 +441,11 @@ public class cashbill extends Controller {
|
|
|
*/
|
|
|
|
|
|
boolean isExport = content.getBooleanValue("isExport");
|
|
|
- String where = " 1=1 and t1.type=1 ";
|
|
|
+ String where = " 1=1 ";
|
|
|
if (content.containsKey("where")) {
|
|
|
JSONObject whereObject = content.getJSONObject("where");
|
|
|
if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
- where = where + " and(t2.enterprisename like'%" + whereObject.getString("condition")
|
|
|
- + "%' or t3.accountname like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t2.abbreviation like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t1.billno like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t1.remarks like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t4.agentnum like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t1.class like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t1.subclass like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t1.amount like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + ")";
|
|
|
+ where = where + " and(t2.enterprisename like'%" + whereObject.getString("condition") + "%' or t3.accountname like '%" + whereObject.getString("condition") + "%'" + " or t2.abbreviation like '%" + whereObject.getString("condition") + "%'" + " or t1.billno like '%" + whereObject.getString("condition") + "%'" + " or t1.remarks like '%" + whereObject.getString("condition") + "%'" + " or t4.agentnum like '%" + whereObject.getString("condition") + "%'" + " or t1.class like '%" + whereObject.getString("condition") + "%'" + " or t1.subclass like '%" + whereObject.getString("condition") + "%'" + " or t1.amount like '%" + whereObject.getString("condition") + "%'" + ")";
|
|
|
}
|
|
|
if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
where = where + " and t1.status ='" + whereObject.getString("status") + "' ";
|
|
|
@@ -496,19 +478,16 @@ public class cashbill extends Controller {
|
|
|
where = where + " and t1.period like'%" + whereObject.getString("period") + "%' ";
|
|
|
}
|
|
|
if (whereObject.containsKey("agentinfo") && !"".equals(whereObject.getString("agentinfo"))) {
|
|
|
- where = where + " and(t2.enterprisename like'%" + whereObject.getString("agentinfo") + "%'"
|
|
|
- + " or t4.agentnum like '%" + whereObject.getString("agentinfo") + "%'"
|
|
|
- + ")";
|
|
|
+ where = where + " and(t2.enterprisename like'%" + whereObject.getString("agentinfo") + "%'" + " or t4.agentnum like '%" + whereObject.getString("agentinfo") + "%'" + ")";
|
|
|
}
|
|
|
}
|
|
|
-// if (pageSorting.equals("''")) {
|
|
|
-// pageSorting = "status desc, period desc";
|
|
|
-// }
|
|
|
- QuerySQL querySQL = queryList(where);
|
|
|
+ if (pageSorting.equals("''")) {
|
|
|
+ pageSorting = "status desc, sa_cashbillid desc";
|
|
|
+ }
|
|
|
+
|
|
|
+ QuerySQL querySQL = queryList(where, 1);
|
|
|
querySQL.setOrderBy(pageSorting);
|
|
|
-// if (!isExport) {
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
-// }
|
|
|
Rows rows = querySQL.query();
|
|
|
|
|
|
SQLFactory areasqlFactory = new SQLFactory(this, "收支凭证关联区域列表查询");
|
|
|
@@ -534,58 +513,17 @@ public class cashbill extends Controller {
|
|
|
row.put("areaname", "");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-// if (isExport) {
|
|
|
-// //去除不需要导出项
|
|
|
-// rows.getFieldList().remove("sa_accountclassid");
|
|
|
-// rows.getFieldList().remove("period");
|
|
|
-// rows.getFieldList().remove("sys_enterpriseid");
|
|
|
-// rows.getFieldList().remove("abbreviation");
|
|
|
-// rows.getFieldList().remove("enterprisename");
|
|
|
-// rows.getFieldList().remove("sa_accountclassid");
|
|
|
-// rows.getFieldList().remove("status");
|
|
|
-// rows.getFieldList().remove("sourcenote");
|
|
|
-// rows.getFieldList().remove("ownertable");
|
|
|
-// rows.getFieldList().remove("ownerid");
|
|
|
-// rows.getFieldList().remove("createuserid");
|
|
|
-// rows.getFieldList().remove("createby");
|
|
|
-// rows.getFieldList().remove("createdate");
|
|
|
-// rows.getFieldList().remove("changeuserid");
|
|
|
-// rows.getFieldList().remove("changeby");
|
|
|
-// rows.getFieldList().remove("changedate");
|
|
|
-// rows.getFieldList().remove("subclass");
|
|
|
-// rows.getFieldList().remove("class");
|
|
|
-// rows.getFieldList().remove("unwriteoffamount");
|
|
|
-// rows.getFieldList().remove("offsettingbillno");
|
|
|
-//
|
|
|
-// Rows uploadRows = uploadExcelToObs("cashBill", "收入凭证列表", rows, getTitleMap());
|
|
|
-// return getSucReturnObject().setData(uploadRows).toString();
|
|
|
-// }
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
- @API(title = "支出收入凭证列表", apiversion = R.ID20221010102903.v1.class)
|
|
|
+ @API(title = "支出凭证列表", apiversion = R.ID20221010102903.v1.class)
|
|
|
@CACHEING
|
|
|
public String queryPayCashbillList() throws YosException, IOException {
|
|
|
-
|
|
|
- /*
|
|
|
- * 过滤条件设置
|
|
|
- */
|
|
|
- boolean isExport = content.getBooleanValue("isExport");
|
|
|
- String where = " 1=1 and t1.type=0 ";
|
|
|
+ String where = " 1=1 ";
|
|
|
if (content.containsKey("where")) {
|
|
|
JSONObject whereObject = content.getJSONObject("where");
|
|
|
if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
- where = where + " and(t2.enterprisename like'%" + whereObject.getString("condition")
|
|
|
- + "%' or t3.accountname like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t2.abbreviation like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t1.billno like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t4.agentnum like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t1.remarks like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t1.class like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t1.subclass like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + " or t1.amount like '%" + whereObject.getString("condition") + "%'"
|
|
|
- + ")";
|
|
|
+ where = where + " and(t2.enterprisename like'%" + whereObject.getString("condition") + "%' or t3.accountname like '%" + whereObject.getString("condition") + "%'" + " or t2.abbreviation like '%" + whereObject.getString("condition") + "%'" + " or t1.billno like '%" + whereObject.getString("condition") + "%'" + " or t4.agentnum like '%" + whereObject.getString("condition") + "%'" + " or t1.remarks like '%" + whereObject.getString("condition") + "%'" + " or t1.class like '%" + whereObject.getString("condition") + "%'" + " or t1.subclass like '%" + whereObject.getString("condition") + "%'" + " or t1.amount like '%" + whereObject.getString("condition") + "%'" + ")";
|
|
|
}
|
|
|
if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
where = where + " and t1.status ='" + whereObject.getString("status") + "' ";
|
|
|
@@ -615,17 +553,14 @@ public class cashbill extends Controller {
|
|
|
where = where + " and t1.remarks like'%" + whereObject.getString("remarks") + "%' ";
|
|
|
}
|
|
|
if (whereObject.containsKey("agentinfo") && !"".equals(whereObject.getString("agentinfo"))) {
|
|
|
- where = where + " and(t2.enterprisename like'%" + whereObject.getString("agentinfo") + "%'"
|
|
|
- + " or t4.agentnum like '%" + whereObject.getString("agentinfo") + "%'"
|
|
|
- + ")";
|
|
|
+ where = where + " and(t2.enterprisename like'%" + whereObject.getString("agentinfo") + "%'" + " or t4.agentnum like '%" + whereObject.getString("agentinfo") + "%'" + ")";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if (pageSorting.equals("''")) {
|
|
|
- pageSorting = "status desc, createdate desc";
|
|
|
+ pageSorting = "status desc, sa_cashbillid desc";
|
|
|
}
|
|
|
- QuerySQL querySQL = queryList(where);
|
|
|
+ QuerySQL querySQL = queryList(where, 0);
|
|
|
querySQL.setOrderBy(pageSorting);
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
Rows rows = querySQL.query();
|
|
|
@@ -644,51 +579,20 @@ public class cashbill extends Controller {
|
|
|
row.put("areaname", "");
|
|
|
}
|
|
|
}
|
|
|
-// if (isExport) {
|
|
|
-// //去除不需要导出项
|
|
|
-// rows.getFieldList().remove("sa_accountclassid");
|
|
|
-// rows.getFieldList().remove("period");
|
|
|
-// rows.getFieldList().remove("sys_enterpriseid");
|
|
|
-// rows.getFieldList().remove("abbreviation");
|
|
|
-// rows.getFieldList().remove("enterprisename");
|
|
|
-// rows.getFieldList().remove("sa_accountclassid");
|
|
|
-// rows.getFieldList().remove("status");
|
|
|
-// rows.getFieldList().remove("sourcenote");
|
|
|
-// rows.getFieldList().remove("ownertable");
|
|
|
-// rows.getFieldList().remove("ownerid");
|
|
|
-// rows.getFieldList().remove("createuserid");
|
|
|
-// rows.getFieldList().remove("createby");
|
|
|
-// rows.getFieldList().remove("createdate");
|
|
|
-// rows.getFieldList().remove("changeuserid");
|
|
|
-// rows.getFieldList().remove("changeby");
|
|
|
-// rows.getFieldList().remove("changedate");
|
|
|
-// rows.getFieldList().remove("subclass");
|
|
|
-// rows.getFieldList().remove("class");
|
|
|
-// rows.getFieldList().remove("unwriteoffamount");
|
|
|
-// rows.getFieldList().remove("offsettingbillno");
|
|
|
-//
|
|
|
-// Rows uploadRows = uploadExcelToObs("cashBill", "支出凭证列表", rows, getTitleMap());
|
|
|
-// return getSucReturnObject().setData(uploadRows).toString();
|
|
|
-// }
|
|
|
-
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
- public QuerySQL queryList(String where) throws YosException {
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_cashbill","*");
|
|
|
- querySQL.setTableAlias("t1");
|
|
|
- querySQL.addQueryFields("unwriteoffamount", "t1.amount - t1.writeoffamount");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.sys_enterpriseid = t2.sys_enterpriseid and t1.siteid = t2.siteid",
|
|
|
- "enterprisename", "abbreviation", "sys_enterpriseid");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t4.sys_enterpriseid = t2.sys_enterpriseid and t4.siteid = t2.siteid",
|
|
|
- "agentnum");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sa_accountclass", "t3", "t1.sa_accountclassid = t3.sa_accountclassid and t1.siteid = t3.siteid and t3.isused = 1",
|
|
|
- "accountno", "accountname");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sa_cashbill", "t5", "t1.siteid = t5.siteid and t5.ownerid = t1.sa_cashbillid and t5.ownertable = 'sa_cashbill'");
|
|
|
-
|
|
|
- querySQL.addQueryFields("offsettingbillno", "t5.billno");
|
|
|
+ public QuerySQL queryList(String where, int type) throws YosException {
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_cashbill", "*").setTableAlias("t1");
|
|
|
+ if (type == 1) {
|
|
|
+ querySQL.addQueryFields("unwriteoffamount", "t1.amount - t1.writeoffamount");
|
|
|
+ }
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.sys_enterpriseid = t2.sys_enterpriseid and t1.siteid = t2.siteid", "enterprisename", "abbreviation", "sys_enterpriseid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t4.sys_enterpriseid = t2.sys_enterpriseid and t4.siteid = t2.siteid", "agentnum");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_accountclass", "t3", "t1.sa_accountclassid = t3.sa_accountclassid and t1.siteid = t3.siteid and t3.isused = 1", "accountno", "accountname");
|
|
|
querySQL.setWhere(where);
|
|
|
- querySQL.setWhere("t1.siteid", siteid);
|
|
|
+ querySQL.setWhere("type", type);
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
return querySQL;
|
|
|
|
|
|
}
|
|
|
@@ -721,8 +625,7 @@ public class cashbill extends Controller {
|
|
|
long sa_cashbillid = content.getLong("sa_cashbillid");
|
|
|
String[] s = {"sa_cashbillid"};
|
|
|
for (String s1 : s) {
|
|
|
- if (!content.containsKey(s1))
|
|
|
- return getErrReturnObject().setErrMsg("缺少" + s1 + "参数").toString();
|
|
|
+ if (!content.containsKey(s1)) return getErrReturnObject().setErrMsg("缺少" + s1 + "参数").toString();
|
|
|
}
|
|
|
//List<String> list = sa_creditbillids.toJavaList(String.class);
|
|
|
//String[] stringArray = list.toArray(new String[0]);
|
|
|
@@ -732,12 +635,10 @@ public class cashbill extends Controller {
|
|
|
Rows rows = dbConnect.runSqlQuery("select t1.sa_cashbillid,t1.sys_enterpriseid,t1.sa_accountclassid,t1.status,t1.billno,t1.amount,ifnull(t1.discountamount,0) discountamount,t1.type,t1.ownerid,t2.accountname,t1.remarks from sa_cashbill t1 left join sa_accountclass t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid where t1.sa_cashbillid ='" + sa_cashbillid + "' and t1.siteid='" + siteid + "'");
|
|
|
for (Row row : rows) {
|
|
|
if (row.getString("status").equals("审核")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的收支凭证已审核,无法再次审核")
|
|
|
- .toString();
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的收支凭证已审核,无法再次审核").toString();
|
|
|
}
|
|
|
if (!row.getString("status").equals("新建")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的收支凭证为非新建状态,无法审核")
|
|
|
- .toString();
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的收支凭证为非新建状态,无法审核").toString();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -768,13 +669,12 @@ public class cashbill extends Controller {
|
|
|
sqlList.add(sqlFactory.getSQL());
|
|
|
} else {
|
|
|
BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("balance")).add(rowsaccountbalance.get(0).getBigDecimal("discountamount"));
|
|
|
- if ((rows.get(0).getBigDecimal("amount").add(canuseamount)).compareTo(BigDecimal.ZERO) == -1 && rows.get(0).getBigDecimal("amount").compareTo(BigDecimal.ZERO)<=0) {
|
|
|
- return getErrReturnObject().setErrMsg("该营销账户可用余额不足,收入凭证无法审核")
|
|
|
- .toString();
|
|
|
+ if ((rows.get(0).getBigDecimal("amount").add(canuseamount)).compareTo(BigDecimal.ZERO) == -1 && rows.get(0).getBigDecimal("amount").compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ return getErrReturnObject().setErrMsg("该营销账户可用余额不足,收入凭证无法审核").toString();
|
|
|
}
|
|
|
balance = rows.get(0).getBigDecimal("amount").add(rowsaccountbalance.get(0).getBigDecimal("balance"));
|
|
|
discountamount = rows.get(0).getBigDecimal("discountamount").add(rowsaccountbalance.get(0).getBigDecimal("discountamount"));
|
|
|
- sqlList.add("update sa_accountbalance set balance='" + rows.get(0).getBigDecimal("amount").add(rowsaccountbalance.get(0).getBigDecimal("balance")) + "',discountamount="+discountamount+",changedate=CURRENT_TIME,changeby ='" + username + "',changeuserid='" + userid + "' where sys_enterpriseid ='" + sys_enterpriseid + "' and sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
|
|
|
+ sqlList.add("update sa_accountbalance set balance='" + rows.get(0).getBigDecimal("amount").add(rowsaccountbalance.get(0).getBigDecimal("balance")) + "',discountamount=" + discountamount + ",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());
|
|
|
@@ -789,18 +689,16 @@ public class cashbill extends Controller {
|
|
|
// sqlFactory.addParameter("userid", userid);
|
|
|
// sqlFactory.addParameter("username", username);
|
|
|
// sqlList.add(sqlFactory.getSQL());
|
|
|
- return getErrReturnObject().setErrMsg("该营销账户不存在,支出凭证无法审核")
|
|
|
- .toString();
|
|
|
+ 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 ) {
|
|
|
- return getErrReturnObject().setErrMsg("该营销账户可用余额不足,支出凭证无法审核")
|
|
|
- .toString();
|
|
|
+ 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;
|
|
|
discountamount = rowsaccountbalance.get(0).getBigDecimal("discountamount").subtract(rows.get(0).getBigDecimal("discountamount"));
|
|
|
- sqlList.add("update sa_accountbalance set balance='" + newbalance + "',discountamount="+discountamount+",changedate=CURRENT_TIME,changeby ='" + username + "',changeuserid='" + userid + "' where sys_enterpriseid ='" + sys_enterpriseid + "' and sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
|
|
|
+ sqlList.add("update sa_accountbalance set balance='" + newbalance + "',discountamount=" + discountamount + ",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());
|
|
|
@@ -847,12 +745,10 @@ public class cashbill extends Controller {
|
|
|
Date date = new Date();
|
|
|
for (Row row : rows) {
|
|
|
if (!row.getString("status").equals("审核")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的收支凭证为非审核状态,无法反审核")
|
|
|
- .toString();
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的收支凭证为非审核状态,无法反审核").toString();
|
|
|
}
|
|
|
if (row.getLong("type") != 1) {
|
|
|
- return getErrReturnObject().setErrMsg("非收入凭证无法反审核")
|
|
|
- .toString();
|
|
|
+ return getErrReturnObject().setErrMsg("非收入凭证无法反审核").toString();
|
|
|
}
|
|
|
if (!isMonth(row.getDate("checkdate"), date)) {
|
|
|
return getErrReturnObject().setErrMsg("跨月禁止反审").toString();
|
|
|
@@ -875,18 +771,16 @@ public class cashbill extends Controller {
|
|
|
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();
|
|
|
+ return getErrReturnObject().setErrMsg("该营销账户不存在,收入凭证无法反审核").toString();
|
|
|
} else {
|
|
|
BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("balance")).add(rowsaccountbalance.get(0).getBigDecimal("discountamount"));
|
|
|
if (rows.get(0).getBigDecimal("amount").compareTo(canuseamount) == 1) {
|
|
|
- return getErrReturnObject().setErrMsg("该营销账户可用余额不足,收入凭证无法反审核")
|
|
|
- .toString();
|
|
|
+ return getErrReturnObject().setErrMsg("该营销账户可用余额不足,收入凭证无法反审核").toString();
|
|
|
}
|
|
|
BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(rows.get(0).getBigDecimal("amount"));
|
|
|
balance = newbalance;
|
|
|
- discountamount= rowsaccountbalance.get(0).getBigDecimal("discountamount").subtract(rows.get(0).getBigDecimal("discountamount"));
|
|
|
- sqlList.add("update sa_accountbalance set balance='" + newbalance + "',discountamount="+discountamount+",changedate=CURRENT_TIME,changeby ='" + username + "',changeuserid='" + userid + "' where sys_enterpriseid ='" + sys_enterpriseid + "' and sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
|
|
|
+ discountamount = rowsaccountbalance.get(0).getBigDecimal("discountamount").subtract(rows.get(0).getBigDecimal("discountamount"));
|
|
|
+ sqlList.add("update sa_accountbalance set balance='" + newbalance + "',discountamount=" + discountamount + ",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());
|
|
|
@@ -912,8 +806,7 @@ public class cashbill extends Controller {
|
|
|
BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_cashbillids.size());
|
|
|
for (Object o : sa_cashbillids) {
|
|
|
long sa_cashbillid = Long.parseLong(o.toString());
|
|
|
- Rows RowsStatus = dbConnect.runSqlQuery("select billno,class,subclass,amount,status,sa_cashbillid,source,sourcenote,remarks from sa_cashbill where siteid='"
|
|
|
- + siteid + "' and sa_cashbillid='" + sa_cashbillid + "'");
|
|
|
+ Rows RowsStatus = dbConnect.runSqlQuery("select billno,class,subclass,amount,status,sa_cashbillid,source,sourcenote,remarks from sa_cashbill where siteid='" + siteid + "' and sa_cashbillid='" + sa_cashbillid + "'");
|
|
|
ArrayList<String> list = new ArrayList<>();
|
|
|
if (RowsStatus.isNotEmpty()) {
|
|
|
if (!RowsStatus.get(0).getString("status").equals("新建")) {
|
|
|
@@ -923,8 +816,7 @@ public class cashbill extends Controller {
|
|
|
list.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "删除", RowsStatus.get(0).toString()).getSQL());
|
|
|
}
|
|
|
|
|
|
- list.add("delete from sa_cashbill where siteid='" + siteid
|
|
|
- + "' and sa_cashbillid=" + sa_cashbillid);
|
|
|
+ list.add("delete from sa_cashbill where siteid='" + siteid + "' and sa_cashbillid=" + sa_cashbillid);
|
|
|
|
|
|
dbConnect.runSqlUpdate(list);
|
|
|
}
|
|
|
@@ -986,18 +878,17 @@ public class cashbill extends Controller {
|
|
|
// sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
// sqlFactory.addParameter("siteid", siteid);
|
|
|
// Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_cashbill", "billno", "type",
|
|
|
- "amount","remarks","balance","source","checkby","checkdate","sa_accountclassid");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_cashbill", "billno", "type", "amount", "remarks", "balance", "source", "checkby", "checkdate", "sa_accountclassid");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addQueryFields("type_ch", "if(t1.type=1,'收入','支出')");
|
|
|
querySQL.addQueryFields("unwriteoffamount", "t1.amount - t1.writeoffamount");
|
|
|
- querySQL.addJoinTable(JOINTYPE.inner, "sa_accountclass", "t2", "t1.sa_accountclassid = t2.sa_accountclassid and t1.siteid = t2.siteid","accountname");
|
|
|
- querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t3", "t1.sys_enterpriseid = t3.sys_enterpriseid and t1.siteid = t3.siteid","enterprisename");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t1.sys_enterpriseid = t4.sys_enterpriseid AND t1.siteid = t4.siteid","agentnum");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "sa_accountclass", "t2", "t1.sa_accountclassid = t2.sa_accountclassid and t1.siteid = t2.siteid", "accountname");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t3", "t1.sys_enterpriseid = t3.sys_enterpriseid and t1.siteid = t3.siteid", "enterprisename");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t1.sys_enterpriseid = t4.sys_enterpriseid AND t1.siteid = t4.siteid", "agentnum");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
querySQL.setWhere("t1.status = '审核'");
|
|
|
- querySQL.setWhere("t1.sa_accountclassid",sa_accountclassid);
|
|
|
- querySQL.setWhere("t1.sys_enterpriseid",sys_enterpriseid);
|
|
|
+ querySQL.setWhere("t1.sa_accountclassid", sa_accountclassid);
|
|
|
+ querySQL.setWhere("t1.sys_enterpriseid", sys_enterpriseid);
|
|
|
querySQL.setWhere(where.toString());
|
|
|
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
@@ -1049,10 +940,7 @@ public class cashbill extends Controller {
|
|
|
if (content.containsKey("where")) {
|
|
|
JSONObject whereObject = content.getJSONObject("where");
|
|
|
if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
- where = where + " and(t1.class like '%" + whereObject.getString("condition")
|
|
|
- + "%' or t1.subclass like '%" + whereObject.getString("condition")
|
|
|
- + "%' or t1.billno like '%" + whereObject.getString("condition")
|
|
|
- + "%' or t1.remarks like '%" + whereObject.getString("condition") + "%')";
|
|
|
+ where = where + " and(t1.class like '%" + whereObject.getString("condition") + "%' or t1.subclass like '%" + whereObject.getString("condition") + "%' or t1.billno like '%" + whereObject.getString("condition") + "%' or t1.remarks like '%" + whereObject.getString("condition") + "%')";
|
|
|
}
|
|
|
if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
|
|
|
where = where + " and DATE_FORMAT(t1.checkdate,'%Y-%m-%d') >=DATE_FORMAT('" + whereObject.getString("begindate") + "','%Y-%m-%d')";
|
|
|
@@ -1094,15 +982,14 @@ public class cashbill extends Controller {
|
|
|
// factory.addParameter("siteid", siteid);
|
|
|
// factory.addParameter_SQL("where", where);
|
|
|
// Rows rows = dbConnect.runSqlQuery(factory.getSQL());
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_cashbill", "billno", "type",
|
|
|
- "class","subclass","amount","remarks","source","sourcenote","ownerid","ownertable","createdate","createby","checkby","checkdate","sa_accountclassid");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_cashbill", "billno", "type", "class", "subclass", "amount", "remarks", "source", "sourcenote", "ownerid", "ownertable", "createdate", "createby", "checkby", "checkdate", "sa_accountclassid");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addQueryFields("balance", "ifnull(t1.balance,0)");
|
|
|
- querySQL.addJoinTable(JOINTYPE.inner, "sa_accountclass", "t4", "t1.sa_accountclassid = t4.sa_accountclassid and t1.siteid = t4.siteid","accountname");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "sa_accountclass", "t4", "t1.sa_accountclassid = t4.sa_accountclassid and t1.siteid = t4.siteid", "accountname");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
querySQL.setWhere("t1.status = '审核'");
|
|
|
- querySQL.setWhere("t1.sa_accountclassid",sa_accountclassid);
|
|
|
- querySQL.setWhere("t1.sys_enterpriseid",sys_enterpriseid);
|
|
|
+ querySQL.setWhere("t1.sa_accountclassid", sa_accountclassid);
|
|
|
+ querySQL.setWhere("t1.sys_enterpriseid", sys_enterpriseid);
|
|
|
querySQL.setWhere(where);
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
querySQL.setOrderBy(pageSorting);
|
|
|
@@ -1138,11 +1025,10 @@ public class cashbill extends Controller {
|
|
|
// sqlFactory.addParameter("sa_cashbillid", sa_cashbillid);
|
|
|
// sqlFactory.addParameter("siteid", siteid);
|
|
|
// Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_writeoffbill", "billno", "billnodate",
|
|
|
- "unwriteoffamount","writeoffamount","sys_enterpriseid","status","remarks","createuserid","createby","createdate","changeuserid","checkby","checkdate","changeby","changedate");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_writeoffbill", "billno", "billnodate", "unwriteoffamount", "writeoffamount", "sys_enterpriseid", "status", "remarks", "createuserid", "createby", "createdate", "changeuserid", "checkby", "checkdate", "changeby", "changedate");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("t1.sa_cashbillid",sa_cashbillid);
|
|
|
+ querySQL.setWhere("t1.sa_cashbillid", sa_cashbillid);
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
Rows rows = querySQL.query();
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
@@ -1240,8 +1126,7 @@ public class cashbill extends Controller {
|
|
|
return cellValue;
|
|
|
}
|
|
|
|
|
|
- public XSSFSheet addSheetIncome(ExcelFactory excelFactory, String sheetname, Rows datarows,
|
|
|
- HashMap<String, String> titlemap) {
|
|
|
+ public XSSFSheet addSheetIncome(ExcelFactory excelFactory, String sheetname, Rows datarows, HashMap<String, String> titlemap) {
|
|
|
ArrayList<String> keylist = datarows.getFieldList();
|
|
|
XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
|
|
|
XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
|
|
|
@@ -1284,8 +1169,7 @@ public class cashbill extends Controller {
|
|
|
return sheet;
|
|
|
}
|
|
|
|
|
|
- public XSSFSheet addSheetPay(ExcelFactory excelFactory, String sheetname, Rows datarows,
|
|
|
- HashMap<String, String> titlemap) {
|
|
|
+ public XSSFSheet addSheetPay(ExcelFactory excelFactory, String sheetname, Rows datarows, HashMap<String, String> titlemap) {
|
|
|
ArrayList<String> keylist = datarows.getFieldList();
|
|
|
XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
|
|
|
XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
|
|
|
@@ -1376,7 +1260,8 @@ public class cashbill extends Controller {
|
|
|
remind.setTouserid(userList);
|
|
|
remind.sendByDialogMsg().createSys_message();
|
|
|
}
|
|
|
- public boolean isValidFormat(String date) throws ParseException {
|
|
|
+
|
|
|
+ public boolean isValidFormat(String date) throws ParseException {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
dateFormat.setLenient(false); // 设置解析日期时是否宽松,即是否允许解析不严格符合格式的日期字符串
|
|
|
try {
|