吴志根 4 лет назад
Родитель
Сommit
9281c2170f

+ 5 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/tfolderauth/SQL/查询某个文件路径的授权详情.sql

@@ -0,0 +1,5 @@
+SELECT frole, fauthtype, wechat_name
+FROM tfolderauth t1
+         LEFT JOIN tuser t2
+                   ON t1.tuserid = t2.tuserid
+WHERE tfolderid = (SELECT tfolderid FROM tfolder WHERE fpath = $fpath$)

+ 21 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/tfolderauth/tfolderauth.java

@@ -111,4 +111,25 @@ public class tfolderauth extends Controller {
         return getSucReturnObject().setData(rows).toString();
         return getSucReturnObject().setData(rows).toString();
     }
     }
 
 
+    /**
+     * 查询某个文件夹的授权详情
+     *
+     * @return
+     */
+    public String selectFolderauthDetail() {
+        String fpath = content.getString("fpath");
+
+        SQLFactory sqlFactory = new SQLFactory(this, "查询资料中心授权列表");
+        sqlFactory.addParameter("fpath", fpath);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("frole", rows.toArrayList("frole"));
+        jsonObject.put("fauthtype", rows.toArrayList("fauthtype"));
+        jsonObject.put("wechat_name", rows.toArrayList("wechat_name"));
+
+        return getSucReturnObject().setData(jsonObject).toString();
+
+
+    }
+
 }
 }

+ 5 - 2
src/dsb/com/cnd3b/restcontroller/publicmethod/wechatapplet/wechatapplet.java

@@ -24,11 +24,14 @@ public class wechatapplet extends Controller {
     public String wechatappletLogin() {
     public String wechatappletLogin() {
         String code = content.getString("code");
         String code = content.getString("code");
         int type = content.getIntValue("type");
         int type = content.getIntValue("type");
-        String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=" + WechatDock_Enterprise.getMiniAppAccessToken(type) + "&code=" + code;
+        String access_token = WechatDock_Enterprise.getMiniAppAccessToken(type);
+        System.err.println(access_token);
+
+        String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=" + access_token + "&code=" + code;
 //        System.err.println(url);
 //        System.err.println(url);
         String response = new WebRequest().doGet(url);
         String response = new WebRequest().doGet(url);
         JSONObject object = JSONObject.parseObject(response);
         JSONObject object = JSONObject.parseObject(response);
-//        System.err.println(object);
+        System.err.println(object);
         int errcode = object.getIntValue("errcode");
         int errcode = object.getIntValue("errcode");
         String errmsg = object.getString("errmsg");
         String errmsg = object.getString("errmsg");
         if (errcode != 0) {
         if (errcode != 0) {

+ 49 - 1
src/dsb/com/cnd3b/service/GetWechatData.java

@@ -257,7 +257,7 @@ public class GetWechatData extends BaseClass implements Runnable {
         dbConnect.runSqlUpdate(listSql);
         dbConnect.runSqlUpdate(listSql);
 
 
         getDepartmentUsers(3, 1, positionSeller, "业务员");
         getDepartmentUsers(3, 1, positionSeller, "业务员");
-        getDepartmentUsers(144, 1, positionAgent, "经销商");
+
 
 
 
 
     }
     }
@@ -305,6 +305,54 @@ public class GetWechatData extends BaseClass implements Runnable {
 
 
         dbConnect.runSqlUpdate(listSql);
         dbConnect.runSqlUpdate(listSql);
 
 
+        getDepartmentUsers2(144, 1, positionAgent, "经销商");
+
+        return array;
+    }
+
+    /**
+     * 获取企业微信部门成员列表
+     *
+     * @return
+     */
+    public JSONArray getDepartmentUsers2(int id, int fetch_child, String[] strArray, String fusertype) {
+        String url = "https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=" + WechatDock_Enterprise.getAccessToken() + "&department_id=" + id + "&fetch_child=" + fetch_child;
+        String response = new WebRequest().doGet(url);
+        JSONObject object = JSONObject.parseObject(response);
+        JSONArray array = object.getJSONArray("userlist");
+        ArrayList<String> listSql = new ArrayList<>();
+        for (Object obj : array) {
+            JSONObject jsonObject = (JSONObject) obj;
+            String position = jsonObject.getString("position");
+            String name = jsonObject.getString("name");
+            String userid = jsonObject.getString("userid");
+            int main_department = jsonObject.getIntValue("main_department");
+            String mobile = jsonObject.getString("mobile");
+            String open_userid = jsonObject.getString("open_userid");
+            List<String> list = Arrays.asList(strArray);
+            if (list.contains(position)) {
+                SQLFactory sqlFactory = new SQLFactory(this, "插入微信成员");
+                sqlFactory.addParameter("tuserid", createTableID("tuser", "tuserid"));
+                sqlFactory.addParameter("wechat_depid", main_department);
+                sqlFactory.addParameter("wechat_userid", userid);
+                sqlFactory.addParameter("wechat_name", name);
+                sqlFactory.addParameter("wechat_open_userid", open_userid);
+                sqlFactory.addParameter("wechat_mobile", mobile);
+                sqlFactory.addParameter("wechat_position", position);
+                sqlFactory.addParameter("fusertype", fusertype);
+                listSql.add(sqlFactory.getSQL());
+                if (listSql.size() > 50) {
+                    System.err.println("start user...");
+                    dbConnect.runSqlUpdate(listSql);
+                    listSql.clear();
+                }
+
+            }
+
+        }
+
+        dbConnect.runSqlUpdate(listSql);
+
         if (fusertype.equals("经销商")) {
         if (fusertype.equals("经销商")) {
             updateAgents(array);
             updateAgents(array);
         }
         }

+ 4 - 3
src/dsb/com/cnd3b/utility/wechatdock/WechatDock_Enterprise.java

@@ -21,6 +21,7 @@ public class WechatDock_Enterprise extends BaseClass {
     public static String corpsecret1 = "uf8PZCPRPIB9pSLrgQJuK0z4kifrSIcH_VxqeyjYAt4";
     public static String corpsecret1 = "uf8PZCPRPIB9pSLrgQJuK0z4kifrSIcH_VxqeyjYAt4";
     //应用的凭证密钥(培训学习)
     //应用的凭证密钥(培训学习)
     public static String corpsecret2 = "hBJRVc0VZ5hNk-3ItOrqcWAImWmimhQMZWhtOcX08yI";
     public static String corpsecret2 = "hBJRVc0VZ5hNk-3ItOrqcWAImWmimhQMZWhtOcX08yI";
+
     //企业应用agentid
     //企业应用agentid
     public static long agentid = 1000003;
     public static long agentid = 1000003;
     //有效期2小时,需定时刷新,重复获取将导致上次获取的失效
     //有效期2小时,需定时刷新,重复获取将导致上次获取的失效
@@ -70,7 +71,7 @@ public class WechatDock_Enterprise extends BaseClass {
      */
      */
     public static String getMiniAppAccessToken(int type) {
     public static String getMiniAppAccessToken(int type) {
         String corpsecret = "";
         String corpsecret = "";
-        String access_token = "";
+        Object access_token = "";
         if (type == 1) {
         if (type == 1) {
             corpsecret = corpsecret1;
             corpsecret = corpsecret1;
         } else {
         } else {
@@ -82,10 +83,10 @@ public class WechatDock_Enterprise extends BaseClass {
         JSONObject resobject = JSONObject.parseObject(res);
         JSONObject resobject = JSONObject.parseObject(res);
         System.err.println(resobject);
         System.err.println(resobject);
         if (resobject.containsKey("access_token")) {
         if (resobject.containsKey("access_token")) {
-            access_token = resobject.getString("access_token");
+            access_token = resobject.get("access_token");
         }
         }
 
 
-        return access_token;
+        return access_token.toString();
     }
     }