eganwu hai 1 ano
pai
achega
d2e3453fd5

+ 5 - 0
src/custom/restcontroller/R.java

@@ -6553,6 +6553,11 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2024061110312202 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 54 - 1
src/custom/restcontroller/webmanage/saletool/data/DataDashboard.java

@@ -4,6 +4,10 @@ import com.alibaba.fastjson.JSONObject;
 import common.Controller;
 import common.YosException;
 import common.annotation.API;
+import common.data.QuerySQL;
+import common.data.Row;
+import common.data.Rows;
+import common.data.SQLFactory;
 import restcontroller.R;
 
 /**
@@ -22,9 +26,58 @@ public class DataDashboard extends Controller {
     @API(title = "账户使用概况", apiversion = R.ID2024061109144502.v1.class)
     public String accountUseOverview() throws YosException {
 
+        Row row = new Row();
+        row.put("company_used", DataDashboardHelper.getUsedCount(this, 1));
+        row.put("company_unbind", DataDashboardHelper.getUnBindCount(this, 1));
+        row.put("company_stop", DataDashboardHelper.getStopCount(this, 1));
+        row.put("company_all", DataDashboardHelper.getAllCount(this, 1));
 
+        row.put("agent_used", DataDashboardHelper.getUsedCount(this, 21));
+        row.put("agent_unbind", DataDashboardHelper.getUnBindCount(this, 21));
+        row.put("agent_stop", DataDashboardHelper.getStopCount(this, 21));
+        row.put("agent_all", DataDashboardHelper.getAllCount(this, 21));
 
-        return getSucReturnObject().toString();
+        row.put("agentstaff_used", DataDashboardHelper.getUsedCount(this, 22));
+        row.put("agentstaff_unbind", DataDashboardHelper.getUnBindCount(this, 22));
+        row.put("agentstaff_stop", DataDashboardHelper.getStopCount(this, 22));
+        row.put("agentstaff_all", DataDashboardHelper.getAllCount(this, 22));
+
+
+        return getSucReturnObject().setData(row).toString();
+    }
+
+    @API(title = "账号列表", apiversion = R.ID2024061110312202.v1.class)
+    public String accountList() throws YosException {
+
+        int usertype = content.getIntValue("usertype");
+        int type = content.getIntValue("type");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_users",
+                "accountno", "name", "phonenumber", "userid").setTableAlias("t");
+
+        if (type == 1) {
+            querySQL.setWhere("t.userid in (" + DataDashboardHelper.getUsedSql(this, usertype) + ")");
+        }
+        if (type == 2) {
+            querySQL.setWhere("t.userid in (" + DataDashboardHelper.getUnBindSql(this, usertype) + ")");
+        }
+        if (type == 3) {
+            querySQL.setWhere("t.userid in (" + DataDashboardHelper.getStopSql(this, usertype) + ")");
+        }
+
+        System.err.println(querySQL.getSQL());
+        querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
+        Rows rows = querySQL.query();
+
+        for (Row row : rows) {
+
+            row.put("usertype", usertype);
+            row.put("rolename", userInfo.getUserRoleName(this, row.getLong("userid")));
+
+        }
+
+
+        return getSucReturnObject().setData(rows).toString();
     }
 
 

+ 117 - 5
src/custom/restcontroller/webmanage/saletool/data/DataDashboardHelper.java

@@ -2,16 +2,128 @@ package restcontroller.webmanage.saletool.data;
 
 import common.BaseClass;
 import common.Controller;
+import common.YosException;
+import common.data.Row;
 import common.data.Rows;
 
 public class DataDashboardHelper extends BaseClass {
 
 
-//    public Long getUsedCount(Controller controller, int usertype) {
-//
-////        Rows rows =controller.dbConnect.runSqlQuery("");
-//
-//    }
+    //启用状态且绑定小程序的账号数量;
+    public static Long getUsedCount(Controller controller, int usertype) throws YosException {
+
+        Row row = controller.dbConnect.runSqlQuery(0, "SELECT count(0) count from sys_usersite t1 " +
+                "INNER JOIN sys_users t2 ON t2.userid=t1.userid " +
+                "WHERE" +
+                " t1.siteid='" + controller.siteid + "' and " +
+                " t1.usertype=" + usertype + " and " +
+                " t2.status='ACTIVE' and " +
+                " t1.userid in " +
+                " (" +
+                "SELECT userid FROM sys_wechatapp_openids WHERE systemclient='marketingtool' " +
+                "UNION ALL " +
+                "SELECT userid FROM sys_wechatapp_unionids" +
+                ")");
+
+        return row.getLong("count");
+
+    }
+
+    public static String getUsedSql(Controller controller, int usertype) throws YosException {
+
+        String sql = ("SELECT t1.userid  from sys_usersite t1 " +
+                "INNER JOIN sys_users t2 ON t2.userid=t1.userid " +
+                "WHERE" +
+                " t1.siteid='" + controller.siteid + "' and " +
+                " t1.usertype=" + usertype + " and " +
+                " t2.status='ACTIVE' and " +
+                " t1.userid in " +
+                " (" +
+                "SELECT userid FROM sys_wechatapp_openids WHERE systemclient='marketingtool' " +
+                "UNION ALL " +
+                "SELECT userid FROM sys_wechatapp_unionids" +
+                ")");
+
+        return sql;
+
+    }
+
+    //启用状态且未绑定小程序的账号数量;
+    public static Long getUnBindCount(Controller controller, int usertype) throws YosException {
+
+        Row row = controller.dbConnect.runSqlQuery(0, "SELECT count(0) count from sys_usersite t1 " +
+                "INNER JOIN sys_users t2 ON t2.userid=t1.userid " +
+                "WHERE" +
+                " t1.siteid='" + controller.siteid + "' and " +
+                " t1.usertype=" + usertype + " and " +
+                " t2.status='ACTIVE' and " +
+                " t1.userid not in " +
+                " (" +
+                "SELECT userid FROM sys_wechatapp_openids WHERE systemclient='marketingtool' " +
+                "UNION ALL " +
+                "SELECT userid FROM sys_wechatapp_unionids" +
+                ")");
+
+        return row.getLong("count");
+
+    }
+
+    public static String getUnBindSql(Controller controller, int usertype) throws YosException {
+
+       String sql=( "SELECT t1.userid from sys_usersite t1 " +
+                "INNER JOIN sys_users t2 ON t2.userid=t1.userid " +
+                "WHERE" +
+                " t1.siteid='" + controller.siteid + "' and " +
+                " t1.usertype=" + usertype + " and " +
+                " t2.status='ACTIVE' and " +
+                " t1.userid not in " +
+                " (" +
+                "SELECT userid FROM sys_wechatapp_openids WHERE systemclient='marketingtool' " +
+                "UNION ALL " +
+                "SELECT userid FROM sys_wechatapp_unionids" +
+                ")");
+
+        return sql;
+
+    }
+
+    //停用的账号数量;
+    public static Long getStopCount(Controller controller, int usertype) throws YosException {
+
+        Row row = controller.dbConnect.runSqlQuery(0, "SELECT count(0) count from sys_usersite t1 " +
+                "INNER JOIN sys_users t2 ON t2.userid=t1.userid " +
+                "WHERE" +
+                " t1.siteid='" + controller.siteid + "' and " +
+                " t1.usertype=" + usertype + " and " +
+                " t2.status='INACTIVE'");
+        return row.getLong("count");
+
+    }
+
+    public static String getStopSql(Controller controller, int usertype) throws YosException {
+
+        String sql=( "SELECT t1.userid from sys_usersite t1 " +
+                "INNER JOIN sys_users t2 ON t2.userid=t1.userid " +
+                "WHERE" +
+                " t1.siteid='" + controller.siteid + "' and " +
+                " t1.usertype=" + usertype + " and " +
+                " t2.status='INACTIVE'");
+        return sql;
+
+    }
+
+    //全部账号数量;
+    public static Long getAllCount(Controller controller, int usertype) throws YosException {
+
+        Row row = controller.dbConnect.runSqlQuery(0, "SELECT count(0) count from sys_usersite t1 " +
+                "INNER JOIN sys_users t2 ON t2.userid=t1.userid " +
+                "WHERE" +
+                " t1.siteid='" + controller.siteid + "' and " +
+                " t1.usertype=" + usertype + " and " +
+                " t2.status in ('ACTIVE','INACTIVE')");
+        return row.getLong("count");
+
+    }
 
 
 }