From 55334da20cff4dac840c320eda1d0ca53ba27eda Mon Sep 17 00:00:00 2001
From: fwq <582742538@qq.com>
Date: 星期一, 23 九月 2024 14:26:36 +0800
Subject: [PATCH] Merge branch 'master-stander' into master-xlk

---
 src/main/java/com/hx/mp/util/CorpMpClientUtil.java |  240 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 240 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/hx/mp/util/CorpMpClientUtil.java b/src/main/java/com/hx/mp/util/CorpMpClientUtil.java
index 8009df7..98c888b 100644
--- a/src/main/java/com/hx/mp/util/CorpMpClientUtil.java
+++ b/src/main/java/com/hx/mp/util/CorpMpClientUtil.java
@@ -1,5 +1,8 @@
 package com.hx.mp.util;
 
+import com.hx.util.StringUtils;
+import com.hz.util.http.HttpHzUtil;
+import com.hz.util.http.dto.HttpHzResponse;
 import net.sf.json.JSONArray;
 import net.sf.json.JSONException;
 import net.sf.json.JSONObject;
@@ -8,6 +11,7 @@
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.util.List;
 
 /**
  * 浼佷笟寰俊瀹㈡埛宸ュ叿
@@ -47,6 +51,52 @@
      * 鑾峰彇鍛樺伐瀹㈡埛鍒楄〃url
      */
     public static final String EXTERNAL_CONTACT_LIST = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list";
+
+    /**
+     * 鍒涘缓鑾峰閾炬帴url
+     */
+    public static final String CUSTOMER_ACQUISITION_CREATE_LINK = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/create_link?access_token=";
+
+    /**
+     * 鑾峰彇鑾峰瀹㈡埛鍒楄〃
+     */
+    public static final String CUSTOMER_ACQUISITION_CUSTOMER_LIST = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/customer?access_token=";
+
+    /**
+     * 鑾峰彇閰嶇疆杩囧鎴风兢绠$悊鐨勫鎴风兢鍒楄〃
+     */
+    public static final String GROUP_CHAT_LIST = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/list?access_token=";
+
+
+    /**
+     * 閫氳繃瀹㈡埛缇D锛岃幏鍙栬鎯呫�傚寘鎷兢鍚嶃�佺兢鎴愬憳鍒楄〃銆佺兢鎴愬憳鍏ョ兢鏃堕棿銆佸叆缇ゆ柟寮忋�傦紙瀹㈡埛缇ゆ槸鐢卞叿鏈夊鎴风兢浣跨敤鏉冮檺鐨勬垚鍛樺垱寤虹殑澶栭儴缇わ級
+     */
+    public static final String GROUP_CHAT_DETAIL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/get?access_token=";
+
+    /**
+     * 浼佷笟寰俊鍙戦�佹櫘閫氶偖浠�
+     */
+    public static final String GROUP_SENT_EMAIL = "https://qyapi.weixin.qq.com/cgi-bin/exmail/app/compose_send?access_token=";
+
+    /**
+     * 瀹㈡埛缇ゃ�屽姞鍏ョ兢鑱娿�嶆煡鐪�
+     */
+    public static final String GROUP_JOIN_WAY_SEE = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/get_join_way?access_token=";
+    /**
+     * 瀹㈡埛缇ゃ�屽姞鍏ョ兢鑱娿�嶆柊澧�
+     * 浼佷笟鍙皟鐢ㄦ鎺ュ彛鏉ョ敓鎴愬苟閰嶇疆銆屽姞鍏ョ兢鑱娿�嶇殑浜岀淮鐮佹垨鑰呭皬绋嬪簭鎸夐挳
+     * 瀹㈡埛閫氳繃鎵弿浜岀淮鐮佹垨鐐瑰嚮灏忕▼搴忎笂鐨勬寜閽紝鍗冲彲鍔犲叆鐗瑰畾鐨勫鎴风兢
+     */
+    public static final String GROUP_JOIN_WAY_ADD = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/add_join_way?access_token=";
+    /**
+     * 瀹㈡埛缇ゃ�屽姞鍏ョ兢鑱娿�嶄慨鏀�
+     */
+    public static final String GROUP_JOIN_WAY_EDIT = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/update_join_way?access_token=";
+    /**
+     * 瀹㈡埛缇ゃ�屽姞鍏ョ兢鑱娿�嶅垹闄�
+     */
+    public static final String GROUP_JOIN_WAY_EDL= "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/del_join_way?access_token=";
+
 
     /**
      * 鐢熸垚浼佷笟鎴愬憳鑱旂郴鎴戠殑id-鍗曚汉
@@ -267,4 +317,194 @@
 
         return HttpURLUtil(CREATE_CONTACT_ID_URL+accessToken,data.toString());
     }
+
+    /**
+     * 鍒涘缓鑾峰閾炬帴
+     *
+     * @param accessToken 浼佷笟鐨刟ccessToken
+     * @param linkName  閾炬帴鍚嶇О
+     * @param userList 鍛樺伐鐢ㄦ埛userId
+     * @return 杩斿洖
+     */
+    public static JSONObject createCustomerAcquisitionLink(String accessToken, String linkName, JSONArray userList) {
+        JSONObject data = new JSONObject();
+        data.put("link_name", linkName);
+        JSONObject subData = new JSONObject();
+        subData.accumulate("user_list", userList);
+        data.put("range", subData);
+        /** 杩斿洖鏁版嵁
+         * {
+         *    "link_id":"LINK_ID",
+         *    "link_name":"鑾峰閾炬帴1鍙�",
+         *    "range":
+         *    {
+         *    		"user_list":["zhangsan","lisi"],
+         * 		"department_list":[2,3]
+         *    },
+         *    "skip_verify":true
+         * }
+         */
+        return HttpURLUtil(CUSTOMER_ACQUISITION_CREATE_LINK + accessToken, data.toString());
+    }
+
+    /**
+     * 鑾峰彇鑾峰瀹㈡埛鍒楄〃
+     *
+     * @param accessToken 浼佷笟鐨刟ccessToken
+     * @param linkId  閾炬帴id
+     * @param cursor  鍒嗛〉娓告爣
+     * @return 杩斿洖
+     */
+    public static JSONObject getCustomerAcquisitionCustomerList(String accessToken, String linkId, String cursor) {
+        JSONObject data = new JSONObject();
+        data.put("link_id", linkId);
+        data.put("limit", 1000);
+        // 鍒嗛〉娓告爣
+        if (!StringUtils.isEmpty(cursor)) {
+            data.put("cursor", cursor);
+        }
+        /** 杩斿洖鏁版嵁
+         * {
+         *     "errcode": 0,
+         *     "errmsg": "ok",
+         * 	"customer_list":
+         * 	[
+         *                {
+         * 			"external_userid":"woAJ2GCAAAXtWyujaWJHDDGi0mACAAA",
+         * 			"userid":"zhangsan",
+         * 			"chat_status":0,
+         * 			"state":"CHANNEL_A"
+         *        }
+         * 	],
+         * 	"next_cursor":"CURSOR"
+         * }
+         */
+        return HttpURLUtil(CUSTOMER_ACQUISITION_CUSTOMER_LIST + accessToken, data.toString());
+    }
+
+
+    /**
+     * 璇ユ帴鍙g敤浜庤幏鍙栭厤缃繃瀹㈡埛缇ょ鐞嗙殑瀹㈡埛缇ゅ垪琛ㄣ��
+     *
+     * @param accessToken  浼佷笟鐨刟ccessToken
+     * @param statusFilter 瀹㈡埛缇よ窡杩涚姸鎬佽繃婊ゃ��0 - 鎵�鏈夊垪琛�(鍗充笉杩囨护) 1 - 绂昏亴寰呯户鎵� 2 - 绂昏亴缁ф壙涓� 3 - 绂昏亴缁ф壙瀹屾垚
+     * @param userIdList   缇や富杩囨护 濡傛灉涓嶅~锛岃〃绀鸿幏鍙栧簲鐢ㄥ彲瑙佽寖鍥村唴鍏ㄩ儴缇や富鐨勬暟鎹彲瑙佽寖鍥翠汉鏁拌秴杩�1000浜猴紝涓轰簡闃叉鏁版嵁鍖呰繃澶э紝浼氭姤閿� 81017 鐢ㄦ埛ID鍒楄〃銆傛渶澶�100涓�
+     * @param cursor       鍒嗛〉涓嬫爣
+     * @param limit        鍒楄〃
+     * @return 杩斿洖
+     */
+    public static HttpHzResponse getGroupChatList(String accessToken, Integer statusFilter, List<String> userIdList, String cursor, Integer limit) {
+        JSONObject bodyData = new JSONObject();
+        bodyData.put("status_filter", statusFilter);
+        //鍒嗛〉涓嬫爣
+        if (StringUtils.noNull(cursor)) {
+            bodyData.put("cursor", cursor);
+        }
+        //榛樿100鏉�
+        if (limit == null) {
+            limit = 100;
+        }
+        bodyData.put("limit", limit);
+        //杩囨护
+        if (userIdList != null && userIdList.size() > 0) {
+            JSONObject filter = new JSONObject();
+            filter.put("userid_list", userIdList);
+            bodyData.put("owner_filter", filter);
+        }
+        return HttpHzUtil.HttpURLUtilJson(GROUP_CHAT_LIST + accessToken, bodyData.toString(), null, null, "GET", null);
+    }
+
+    /**
+     * 閫氳繃瀹㈡埛缇D锛岃幏鍙栬鎯呫�傚寘鎷兢鍚嶃�佺兢鎴愬憳鍒楄〃銆佺兢鎴愬憳鍏ョ兢鏃堕棿銆佸叆缇ゆ柟寮忋�傦紙瀹㈡埛缇ゆ槸鐢卞叿鏈夊鎴风兢浣跨敤鏉冮檺鐨勬垚鍛樺垱寤虹殑澶栭儴缇わ級
+     *
+     * @param chatId   瀹㈡埛缇D
+     * @param needName 鏄惁闇�瑕佽繑鍥炵兢鎴愬憳鐨勫悕瀛�0-涓嶈繑鍥烇紱1-杩斿洖
+     */
+    public static HttpHzResponse getGroupChatDetail(String accessToken, String chatId, Integer needName) {
+        JSONObject bodyData = new JSONObject();
+        bodyData.put("chat_id", chatId);
+        if (needName == null) {
+            needName = 0;
+        }
+        bodyData.put("need_name", needName);
+        return HttpHzUtil.HttpURLUtilJson(GROUP_CHAT_DETAIL + accessToken, bodyData.toString(), null, null, "GET", null);
+    }
+
+    /**
+     * 浼佷笟寰俊鍙戦�佹櫘閫氶偖浠�
+     * 鎺ュ彛鍦板潃: https://developer.work.weixin.qq.com/document/path/97445
+     * @param bodyData  鍙傛暟
+     */
+    public static JSONObject sentEmail(String accessToken, JSONObject bodyData) {
+        return HttpURLUtil(GROUP_SENT_EMAIL + accessToken, bodyData.toString());
+    }
+
+    /**
+     * 瀹㈡埛缇ゃ�屽姞鍏ョ兢鑱娿�嶆煡鐪嬭鎯�
+     * @param config_id 鑱旂郴鏂瑰紡閰嶇疆ID
+     * */
+    public static HttpHzResponse groupJoinSee(String accessToken, String config_id) {
+        JSONObject bodyData = new JSONObject();
+        bodyData.put("config_id", config_id);
+        return HttpHzUtil.HttpURLUtilJson(GROUP_JOIN_WAY_SEE + accessToken, bodyData.toString(), null, null, "POST", null);
+    }
+
+    /**
+     * 瀹㈡埛缇ゃ�屽姞鍏ョ兢鑱娿�嶆柊澧�
+     * @param scene 鍦烘櫙銆�1 - 缇ょ殑灏忕▼搴忔彃浠�, 2 - 缇ょ殑浜岀淮鐮佹彃浠�
+     * @param remark 鑱旂郴鏂瑰紡鐨勫娉ㄤ俊鎭紝鐢ㄤ簬鍔╄锛岃秴杩�30涓瓧绗﹀皢琚埅鏂�
+     * @param auto_create_room 褰撶兢婊′簡鍚庯紝鏄惁鑷姩鏂板缓缇ゃ��0-鍚︼紱1-鏄�� 榛樿涓�1
+     * @param room_base_name 鑷姩寤虹兢鐨勭兢鍚嶅墠缂�锛屽綋auto_create_room涓�1鏃舵湁鏁堛�傛渶闀�40涓猽tf8瀛楃
+     * @param room_base_id 鑷姩寤虹兢鐨勭兢璧峰搴忓彿锛屽綋auto_create_room涓�1鏃舵湁鏁�
+     * @param chat_id_list 浣跨敤璇ラ厤缃殑瀹㈡埛缇D鍒楄〃锛屾渶澶氭敮鎸�5涓�
+     * */
+    public static HttpHzResponse groupJoinAdd(String accessToken, Integer scene, String remark
+            ,Integer auto_create_room,String room_base_name,Integer room_base_id,List<String> chat_id_list,String state) {
+        JSONObject bodyData = new JSONObject();
+        bodyData.put("scene", scene);
+        bodyData.put("remark", remark);
+        bodyData.put("auto_create_room", auto_create_room);
+        bodyData.put("room_base_name", room_base_name);
+        bodyData.put("room_base_id", room_base_id);
+        bodyData.put("chat_id_list", chat_id_list);
+        bodyData.put("state", state);
+        return HttpHzUtil.HttpURLUtilJson(GROUP_JOIN_WAY_ADD + accessToken, bodyData.toString(), null, null, "POST", null);
+    }
+
+    /**
+     * 瀹㈡埛缇ゃ�屽姞鍏ョ兢鑱娿�嶄慨鏀�
+     * @param config_id 鑱旂郴鏂瑰紡閰嶇疆ID
+     * @param scene 鍦烘櫙銆�1 - 缇ょ殑灏忕▼搴忔彃浠�, 2 - 缇ょ殑浜岀淮鐮佹彃浠�
+     * @param remark 鑱旂郴鏂瑰紡鐨勫娉ㄤ俊鎭紝鐢ㄤ簬鍔╄锛岃秴杩�30涓瓧绗﹀皢琚埅鏂�
+     * @param auto_create_room 褰撶兢婊′簡鍚庯紝鏄惁鑷姩鏂板缓缇ゃ��0-鍚︼紱1-鏄�� 榛樿涓�1
+     * @param room_base_name 鑷姩寤虹兢鐨勭兢鍚嶅墠缂�锛屽綋auto_create_room涓�1鏃舵湁鏁堛�傛渶闀�40涓猽tf8瀛楃
+     * @param room_base_id 鑷姩寤虹兢鐨勭兢璧峰搴忓彿锛屽綋auto_create_room涓�1鏃舵湁鏁�
+     * @param chat_id_list 浣跨敤璇ラ厤缃殑瀹㈡埛缇D鍒楄〃锛屾渶澶氭敮鎸�5涓�
+     * */
+    public static HttpHzResponse groupJoinEdit(String accessToken,String config_id, Integer scene, String remark
+            ,Integer auto_create_room,String room_base_name,Integer room_base_id,List<String> chat_id_list,String state) {
+        JSONObject bodyData = new JSONObject();
+        bodyData.put("config_id", config_id);
+        bodyData.put("scene", scene);
+        bodyData.put("remark", remark);
+        bodyData.put("auto_create_room", auto_create_room);
+        bodyData.put("room_base_name", room_base_name);
+        bodyData.put("room_base_id", room_base_id);
+        bodyData.put("chat_id_list", chat_id_list);
+        bodyData.put("state", state);
+        return HttpHzUtil.HttpURLUtilJson(GROUP_JOIN_WAY_EDIT + accessToken, bodyData.toString(), null, null, "POST", null);
+    }
+
+    /**
+     * 瀹㈡埛缇ゃ�屽姞鍏ョ兢鑱娿�嶅垹闄�
+     * @param config_id 鑱旂郴鏂瑰紡閰嶇疆ID
+     * */
+    public static HttpHzResponse groupJoinDel(String accessToken, String config_id) {
+        JSONObject bodyData = new JSONObject();
+        bodyData.put("config_id", config_id);
+        return HttpHzUtil.HttpURLUtilJson(GROUP_JOIN_WAY_EDL + accessToken, bodyData.toString(), null, null, "POST", null);
+    }
+
+
+
 }

--
Gitblit v1.8.0