From a538020ae3d1af171816187a16ebb0072ea68892 Mon Sep 17 00:00:00 2001
From: Andru <769883346@qq.com>
Date: 星期五, 03 十一月 2023 18:31:11 +0800
Subject: [PATCH] 添加企业微信发送邮件方法

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

diff --git a/src/main/java/com/hx/mp/util/CorpMpClientUtil.java b/src/main/java/com/hx/mp/util/CorpMpClientUtil.java
index 79badce..5e89e85 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;
 
 /**
  * 浼佷笟寰俊瀹㈡埛宸ュ叿
@@ -57,6 +61,24 @@
      * 鑾峰彇鑾峰瀹㈡埛鍒楄〃
      */
     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=";
+
+
 
     /**
      * 鐢熸垚浼佷笟鎴愬憳鑱旂郴鎴戠殑id-鍗曚汉
@@ -312,11 +334,17 @@
      *
      * @param accessToken 浼佷笟鐨刟ccessToken
      * @param linkId  閾炬帴id
+     * @param cursor  鍒嗛〉娓告爣
      * @return 杩斿洖
      */
-    public static JSONObject getCustomerAcquisitionCustomerList(String accessToken, String linkId) {
+    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,
@@ -335,4 +363,61 @@
          */
         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());
+    }
 }

--
Gitblit v1.8.0