Explorar el Código

ID20221008164103新增参数sa_creditbillid

wu hace 2 semanas
padre
commit
eca2bd6dea

+ 3 - 0
src/custom/restcontroller/sale/creditbill/SQL/营销账户类别列表查询2.sql

@@ -0,0 +1,3 @@
+select t1.sa_accountclassid,t1.accountno,t1.accountname,t1.isorder,ifnull(t2.creditquota,0) creditquota,t2.sys_enterpriseid from sa_accountclass t1
+left join sa_accountbalance t2 on t1.sa_accountclassid=t2.sa_accountclassid and t2.sys_enterpriseid in $sys_enterpriseid$ and t1.accountno='01'
+where t1.isused=1 and t1.siteid=$siteid$  and t1.sa_accountclassid not in (select sa_accountclassid from sa_creditbilldetail where sa_creditbillid=$sa_creditbillid$ and sys_enterpriseid in $sys_enterpriseid$ and siteid=$siteid$)

+ 36 - 6
src/custom/restcontroller/sale/creditbill/creditbill.java

@@ -91,18 +91,48 @@ public class creditbill extends Controller {
                         "or t2.erpagentnum like '%" + whereObject.getString("condition") + "%')";
             }
         }
+
+        long sa_creditbillid = content.getLongValue("sa_creditbillid");
 //        SQLFactory sqlFactory = new SQLFactory(this, "合作企业档案列表查询", pageSize, pageNumber, pageSorting);
 //        sqlFactory.addParameter_SQL("where", where);
 //        Rows rows = dbConnect.runSqlQuery(sqlFactory);
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_enterprise", "sys_enterpriseid", "enterprisename","abbreviation",
-                "province","city","county","address","contact","phonenumber","taxno");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_enterprise", "sys_enterpriseid", "enterprisename", "abbreviation",
+                "province", "city", "county", "address", "contact", "phonenumber", "taxno");
         querySQL.setTableAlias("t1");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_dataextend", "t2", "t1.sys_enterpriseid = t2.ownerid and t2.ownertable = 'sys_enterprise' and t1.siteid = t2.siteid","erpagentnum");
-        querySQL.addJoinTable(JOINTYPE.inner, "sa_agents", "t3", "t1.sys_enterpriseid=t3.sys_enterpriseid and t1.siteid=t3.siteid","agentnum");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_dataextend", "t2", "t1.sys_enterpriseid = t2.ownerid and t2.ownertable = 'sys_enterprise' and t1.siteid = t2.siteid", "erpagentnum");
+        querySQL.addJoinTable(JOINTYPE.inner, "sa_agents", "t3", "t1.sys_enterpriseid=t3.sys_enterpriseid and t1.siteid=t3.siteid", "agentnum");
         querySQL.setSiteid(siteid);
         querySQL.setWhere(where);
         querySQL.setPage(pageSize, pageNumber);
         Rows rows = querySQL.query();
+
+        ArrayList<Long> sys_enterpriseids = rows.toArrayList("sys_enterpriseid", new ArrayList<>());
+        sys_enterpriseids.add(0l);
+        SQLFactory sqlFactory = new SQLFactory(this, "营销账户类别列表查询2");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter_in("sys_enterpriseid", sys_enterpriseids);
+        sqlFactory.addParameter("sa_creditbillid", sa_creditbillid);
+        RowsMap accountRowsMap = dbConnect.runSqlQuery(sqlFactory).toRowsMap("sys_enterpriseid");
+
+        for (Row row : rows) {
+            Long sys_enterpriseid = row.getLong("sys_enterpriseid");
+            if (accountRowsMap.containsKey(String.valueOf(sys_enterpriseid))) {
+                Rows accountRows = accountRowsMap.get(row.getString("sys_enterpriseid"));
+                row.put("accountname", accountRows.get(0).getString("accountname"));
+                row.put("accountno", accountRows.get(0).getString("accountno"));
+                row.put("creditquota", accountRows.get(0).getBigDecimal("creditquota"));
+                row.put("isorder", accountRows.get(0).getString("isorder"));
+                row.put("sa_accountclassid", accountRows.get(0).getString("sa_accountclassid"));
+            }
+            row.putIfAbsent("creditquota", 0);
+            row.putIfAbsent("accountname", "");
+            row.putIfAbsent("accountno", "");
+            row.putIfAbsent("isorder", "");
+            row.putIfAbsent("sa_accountclassid", "");
+
+        }
+
+
         return getSucReturnObject().setData(rows).toString();
     }
 
@@ -146,9 +176,9 @@ public class creditbill extends Controller {
         sqlFactory.addParameter_SQL("where", where);
         sqlFactory.addParameter("siteid", siteid);
 //        Rows rows = dbConnect.runSqlQuery(sqlFactory);
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter",  "sys_site_parameterid");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
         querySQL.setTableAlias("t0");
-        querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'","*");
+        querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'", "*");
         querySQL.setPage(pageSize, pageNumber);
         Rows rows = querySQL.query();
         return getSucReturnObject().setData(rows).toString();