From 6b479c5774ed3d6e2dc92693ddeda3e7ad1494db Mon Sep 17 00:00:00 2001
From: Andru <769883346@qq.com>
Date: 星期一, 23 十月 2023 17:34:08 +0800
Subject: [PATCH] 添加获客方法

---
 src/main/java/com/hx/mp/util/CorpMpClientUtil.java |   68 ++++++++++++++++++++++++++++++++++
 1 files changed, 68 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..79badce 100644
--- a/src/main/java/com/hx/mp/util/CorpMpClientUtil.java
+++ b/src/main/java/com/hx/mp/util/CorpMpClientUtil.java
@@ -49,6 +49,16 @@
     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=";
+
+    /**
      * 鐢熸垚浼佷笟鎴愬憳鑱旂郴鎴戠殑id-鍗曚汉
      *
      * @param accessToken 浼佷笟鐨刟ccessToken
@@ -267,4 +277,62 @@
 
         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
+     * @return 杩斿洖
+     */
+    public static JSONObject getCustomerAcquisitionCustomerList(String accessToken, String linkId) {
+        JSONObject data = new JSONObject();
+        data.put("link_id", linkId);
+        /** 杩斿洖鏁版嵁
+         * {
+         *     "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());
+    }
 }

--
Gitblit v1.8.0