Просмотр исходного кода

数据看板增加【回款】统计规则

hu 1 месяц назад
Родитель
Сommit
9a9e09ea75

+ 1 - 1
src/custom/restcontroller/webmanage/sale/databoard/SQL/回款统计查询.sql

@@ -1 +1 @@
-select sum(t1.amount) typestatistics from sa_cashbill t1 where t1.status='审核' and t1.type=1 and t1.siteid=$siteid$ and $where$
+select sum(t1.amount) typestatistics from sa_cashbill t1 inner join sa_accountclass t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid where t1.status='审核' and t1.type=1 and t1.siteid=$siteid$ and $where$

+ 57 - 0
src/custom/restcontroller/webmanage/sale/databoard/databoard.java

@@ -366,6 +366,60 @@ public class databoard extends Controller {
         jsonArray.add(jsonObject);
 
         //回款
+        Rows siteparameterrows = dbConnect.runSqlQuery("select statisticsrule_account,statisticsrule_type,statisticsrule_typemx from sys_site_parameter where siteid='"+siteid+"'");
+        JSONArray statisticsrule_account=new JSONArray();
+        JSONArray statisticsrule_type=new JSONArray();
+        JSONArray statisticsrule_typemx=new JSONArray();
+        if(siteparameterrows.isNotEmpty()){
+            statisticsrule_account=siteparameterrows.get(0).getJSONArray("statisticsrule_account");
+            statisticsrule_type=siteparameterrows.get(0).getJSONArray("statisticsrule_type");
+            statisticsrule_typemx=siteparameterrows.get(0).getJSONArray("statisticsrule_typemx");
+        }
+        if(!statisticsrule_account.isEmpty()){
+            StringBuffer str=new StringBuffer("(");
+            for(Object o :statisticsrule_account){
+                str.append("'"+(String)o+"',");
+            }
+            String result = str.substring(0, str.length() - 1);
+            result=result+")";
+            where.append(" and(");
+            where.append("t2.accountname in"+result);
+            where.append(")");
+
+            whereLastYear.append(" and(");
+            whereLastYear.append("t2.accountname in"+result);
+            whereLastYear.append(")");
+        }
+        if(!statisticsrule_type.isEmpty()){
+            StringBuffer str=new StringBuffer("(");
+            for(Object o :statisticsrule_type){
+                str.append("'"+(String)o+"',");
+            }
+            String result = str.substring(0, str.length() - 1);
+            result=result+")";
+            where.append(" and(");
+            where.append("t1.class in"+result);
+            where.append(")");
+
+            whereLastYear.append(" and(");
+            whereLastYear.append("t1.class in"+result);
+            whereLastYear.append(")");
+        }
+        if(!statisticsrule_typemx.isEmpty()){
+            StringBuffer str=new StringBuffer("(");
+            for(Object o :statisticsrule_typemx){
+                str.append("'"+(String)o+"',");
+            }
+            String result = str.substring(0, str.length() - 1);
+            result=result+")";
+            where.append(" and(");
+            where.append("t1.subclass in"+result);
+            where.append(")");
+
+            whereLastYear.append(" and(");
+            whereLastYear.append("t1.subclass in"+result);
+            whereLastYear.append(")");
+        }
         jsonObject = new JSONObject();
         factory = new SQLFactory(this, "回款统计查询");
         factory.addParameter("siteid", siteid);
@@ -407,6 +461,9 @@ public class databoard extends Controller {
         } else {
             jsonObject.put("rate", (rows.get(0).getBigDecimal("typestatistics")).divide(sumAmount.multiply(new BigDecimal(100)), 4, BigDecimal.ROUND_HALF_UP));
         }
+        jsonObject.put("statisticsrule_account", statisticsrule_account);
+        jsonObject.put("statisticsrule_type", statisticsrule_type);
+        jsonObject.put("statisticsrule_typemx", statisticsrule_typemx);
         jsonArray.add(jsonObject);
 
         return getSucReturnObject().setData(jsonArray).toString();