| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- package restcontroller.webmanage.sale.transferbill;
- import beans.accountbalance.Accountbalance;
- import beans.accountbalance.CashbillEntity;
- import com.alibaba.fastjson2.JSONObject;
- import common.Controller;
- import common.YosException;
- import common.annotation.API;
- import common.annotation.CACHEING;
- import common.annotation.CACHEING_CLEAN;
- import common.data.QuerySQL;
- import common.data.Rows;
- import common.data.db.SQLList;
- 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, "转账单列表查询");
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter_SQL("where", where);
- // Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
- querySQL.setTableAlias("t0");
- querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'","*");
- querySQL.setPage(pageSize, pageNumber);
- Rows rows = querySQL.query();
- 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());
- content.put("sa_transferbillid", sa_transferbillid);
- return queryById();
- }
- @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();
- }
- SQLList sqlList = new SQLList();
- ArrayList<Long> sa_cashbillidList = 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(),BigDecimal.ZERO, "", "转账单", rows.get(0).getString("billno"), "sa_transferbill", sa_transferbillid, "货款", "");
- cashbillEntity.setPeriod(rows.get(0).getString("billno"));
- SQLList cashbillIncome = Accountbalance.createCashbillIncome(this, sys_enterpriseid, sa_accountclassid, cashbillEntity, true, false);
- sqlList.addAll(cashbillIncome);
- sa_cashbillidList.add((Long) cashbillIncome.getLong("sa_cashbillid"));
- cashbillEntity.setAmount(amount);
- cashbillEntity.setDiscountamountamount(BigDecimal.ZERO);
- SQLList cashbillIncome1 = Accountbalance.createCashbillIncome(this, sys_enterpriseid, inaccountclassid, cashbillEntity, true, false);
- sqlList.addAll(cashbillIncome1);
- sa_cashbillidList.add((Long) cashbillIncome1.getLong("sa_cashbillid"));
- dbConnect.runSqlUpdate(sqlList);
- String billdate = rows.get(0).getString("billdate");
- if (!billdate.isEmpty()) {
- dbConnect.runSqlUpdate("update sa_cashbill set period= '" + billdate + "' WHERE ownertable='sa_transferbill' and ownerid='" + sa_transferbillid + "'");
- }
- for (Long sa_cashbillid : sa_cashbillidList) {
- Accountbalance.remindSend(this, sys_enterpriseid, sa_cashbillid);
- }
- 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();
- }
- }
|