From b9cbfe2653e9b4cf343b9aa1e390f6b1e77206b9 Mon Sep 17 00:00:00 2001
From: fwq <582742538@qq.com>
Date: 星期一, 23 十月 2023 19:25:33 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/main/java/com/hx/mp/util/CorpMpClientUtil.java |   68 ++++++++++++++++++++++++++++++++++
 src/main/java/com/hx/mp/util/MpUtil.java           |   43 +++++++++++++++++++++
 2 files changed, 111 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());
+    }
 }
diff --git a/src/main/java/com/hx/mp/util/MpUtil.java b/src/main/java/com/hx/mp/util/MpUtil.java
index 1c64291..2dbc9cc 100644
--- a/src/main/java/com/hx/mp/util/MpUtil.java
+++ b/src/main/java/com/hx/mp/util/MpUtil.java
@@ -374,4 +374,47 @@
         data.put("env_version", env_version);
         return HttpMethodUtil.HttpURLUtilJson("https://api.weixin.qq.com/wxa/generate_urllink", data.toString(), map, null, "POST");
     }
+
+
+    /**
+     * 鍏紬鍙峰彂閫佸皬绋嬪簭鍗$墖瀹㈡埛娑堟伅
+     * @param access_token  access_token
+     * @param toUser 鐢ㄦ埛openid
+     * @param title 鏍囬
+     * @param appid 灏忕▼搴廰ppid
+     * @param pagepath 璺宠浆椤甸潰璺緞
+     * @param thumb_media_id 缂╃暐鍥�/灏忕▼搴忓崱鐗囧浘鐗囩殑濯掍綋ID锛屽皬绋嬪簭鍗$墖鍥剧墖寤鸿澶у皬涓�520*416
+     * @return
+     */
+    public static String sendMpMsg(String access_token, String toUser, String title,String appid,String pagepath,String thumb_media_id) {
+        String result = "fail";
+
+        try {
+            JSONObject obj = new JSONObject();
+            obj.put("touser", toUser);
+            obj.put("msgtype", "miniprogrampage");
+
+            JSONObject pObj = new JSONObject();
+            pObj.put("title", title);
+            pObj.put("appid", appid);
+            pObj.put("pagepath", pagepath);
+            pObj.put("thumb_media_id", thumb_media_id);
+            obj.put("miniprogrampage", pObj);
+
+            JSONObject rObj = HttpURLUtil(URL_SEND_KF_MSG + access_token, obj.toString());
+            if (rObj != null) {
+                if (rObj.optInt("errcode", -1) == 0) {
+                    result = "suc";
+                } else {
+                    result = rObj.optString("errmsg");
+                }
+            }
+            rObj = null;
+            obj = null;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return result;
+    }
 }

--
Gitblit v1.8.0