From 81da61b828e29b7745e1382dfbbaeb685dc083ef Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 23 一月 2024 17:17:55 +0800
Subject: [PATCH] 抖音转链修改

---
 fanli/src/main/java/com/yeshi/fanli/util/aitaoker/AitaokerApiUtil.java | 1210 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 605 insertions(+), 605 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/aitaoker/AitaokerApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/aitaoker/AitaokerApiUtil.java
index 588ae45..102f957 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/aitaoker/AitaokerApiUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/aitaoker/AitaokerApiUtil.java
@@ -1,605 +1,605 @@
-package com.yeshi.fanli.util.aitaoker;
-
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Type;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import com.yeshi.fanli.log.LogHelper;
-import org.yeshi.utils.HttpUtil;
-
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-import com.yeshi.fanli.dto.aitaoker.QrcodeLoginDTO;
-import com.yeshi.fanli.dto.aitaoker.RobotInfoDTO;
-import com.yeshi.fanli.dto.aitaoker.WeiXinGroupDTO;
-import com.yeshi.fanli.util.StringUtil;
-
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-
-public class AitaokerApiUtil {
-    public static String APP_KEY = "1077080250";
-    public static String SECRET_KEY = "7c6118bd-7aa5-65b8-c6d4-058728e9446f";
-    // 璇锋眰杩炴帴
-    private static String SERVER_URL = "http://router.itaoke.org/api";
-
-
-    private static String baseRequest(String method, Map<String, String> param) {
-        Map<String, String> baseMap = new HashMap<>();
-        baseMap.put("app_key", APP_KEY);
-        baseMap.put("v", "1.0");
-        baseMap.put("format", "json");
-        baseMap.put("sign_method", "md5");
-        baseMap.put("timestamp", System.currentTimeMillis() + "");
-        baseMap.put("method", method);
-        baseMap.put("domain", "hi.flqapp.com");
-        baseMap.put("client", "113.249.194.232");
-        baseMap.put("partner_id", "top-sdk-php-20190618");
-        String url = combinedUrl(baseMap);
-
-        if (param != null) {
-            Iterator<String> its = param.keySet().iterator();
-            while (its.hasNext()) {
-                String key = its.next();
-                baseMap.put(key, param.get(key));
-            }
-        }
-        url += "sign=" + getSign(baseMap);
-        String result = HttpUtil.post(url, param);
-        LogHelper.cloudInfo(method + ":" + result);
-        return result;
-    }
-
-    /**
-     * 鎷兼帴鎵�鏈夌郴缁熷弬鏁板寘鎷瑂ign鐨剈rl
-     *
-     * @param params
-     * @return
-     */
-    private static String combinedUrl(Map<String, String> params) {
-        String url = SERVER_URL + "?";
-        Iterator<String> its = params.keySet().iterator();
-        while (its.hasNext()) {
-            String key = its.next();
-            try {
-                url += String.format("%s=%s&", key, URLEncoder.encode(params.get(key), "UTF-8"));
-            } catch (UnsupportedEncodingException e) {
-                e.printStackTrace();
-            }
-        }
-        return url;
-    }
-
-    /**
-     * 鑾峰彇绛惧悕
-     *
-     * @param params
-     * @return
-     */
-    private static String getSign(Map<String, String> params) {
-        List<String> list = new ArrayList<>();
-        Iterator<String> its = params.keySet().iterator();
-        while (its.hasNext()) {
-            String key = its.next();
-            list.add(key + params.get(key));
-        }
-        Collections.sort(list);
-
-        String str = "";
-        for (String st : list) {
-            str += st;
-        }
-        return StringUtil.Md5(SECRET_KEY + str + SECRET_KEY).toUpperCase();
-    }
-
-    /**
-     * 鑾峰彇鐧诲綍浜岀淮鐮�
-     *
-     * @param robotId
-     * @return
-     */
-    public static QrcodeLoginDTO getQrcodeMaclogin(int robotId) {
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        String result = baseRequest("itaoke.robot.qrcode.maclogin", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        resultJson = resultJson.optJSONObject("data");
-        if (resultJson != null) {
-            Type type = new TypeToken<QrcodeLoginDTO>() {
-            }.getType();
-            return new Gson().fromJson(resultJson.toString(), type);
-        }
-        return null;
-    }
-
-
-    /**
-     * 妫�鏌ユ槸鍚︾櫥闄嗭紙鐪熸鐨勭櫥褰曟帴鍙o級
-     *
-     * @param robotId 鏈哄櫒浜篿d
-     * @param wId     鑾峰彇浜岀淮鐮佹帴鍙h繑鍥炵殑寰俊瀹炰緥id
-     * @return
-     */
-    public static QrcodeLoginDTO getQrcodeMacloginCheck(int robotId, String wId) {
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        map.put("uuid", wId);
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.async.mlogin", map);
-
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            resultJson = resultJson.optJSONObject("data");
-            if (resultJson != null) {
-                Type type = new TypeToken<QrcodeLoginDTO>() {
-                }.getType();
-                return new Gson().fromJson(resultJson.toString(), type);
-            }
-        }
-        return null;
-    }
-
-    /**
-     * 妫�鏌ユ槸鍚﹀湪绾�
-     *
-     * @param robotId 鏈哄櫒浜篿d
-     * @return
-     */
-    public static boolean onlineCheck(int robotId) {
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        String result = baseRequest("itaoke.robot.check.online", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            return true;
-//            resultJson = resultJson.optJSONObject("data");
-//            if (resultJson != null) {
-//                return resultJson.optBoolean("isOnline");
-//            }
-        }
-        return false;
-    }
-
-
-    /**
-     * 4.寮哄埗涓嬬嚎
-     *
-     * @param robotId 鏈哄櫒浜篿d
-     * @return
-     */
-    public static boolean macloginOffline(int robotId) {
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.force.offline", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            return true;
-        }
-        return false;
-    }
-
-
-    /**
-     * 鍒涘缓鏈哄櫒浜�
-     *
-     * @param month       鏈堟暟
-     * @param robotType   鏈哄櫒浜虹被鍨� 1 鍙戝崟鏈哄櫒浜� 2杞彂鏈哄櫒浜� 3 杩斿埄鏈哄櫒浜� 4鍏ㄨ兘鏈哄櫒浜� 5灏忓瀷鏈哄櫒浜� 6鍙戝湀鏈哄櫒浜�
-     * @param wechatrobot 寰俊鍙�
-     * @param agentUid    浠g悊id
-     * @return
-     */
-    public static RobotInfoDTO robotCreate(int month, int robotType, String wechatrobot, String agentUid) {
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("month", month + "");
-        map.put("robot_type", robotType + "");
-        map.put("wechatrobot", wechatrobot);
-        if (!StringUtil.isNullOrEmpty(agentUid))
-            map.put("agent_uid", agentUid);
-
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.create.get", map);
-
-//		String result = "{\r\n" + 
-//				"    \"status\":\"0000\",\r\n" + 
-//				"    \"msg\":\"浜�,娣诲姞鎴愬姛\",\r\n" + 
-//				"    \"data\":{\r\n" + 
-//				"        \"id\":11770,\r\n" + 
-//				"        \"uid\":1625,\r\n" + 
-//				"        \"wechatrobot\":\"wechatrobot\",\r\n" + 
-//				"        \"wx_id\":\"\",\r\n" + 
-//				"        \"amount_used\":0,\r\n" + 
-//				"        \"group_num\":20,\r\n" + 
-//				"        \"passwd\":\"\",\r\n" + 
-//				"        \"nickname\":\"\",\r\n" + 
-//				"        \"c_uid\":1625,\r\n" + 
-//				"        \"login_status\":0,\r\n" + 
-//				"        \"end_time\":1594785534,\r\n" + 
-//				"        \"remark\":null,\r\n" + 
-//				"        \"wc_id\":\"\",\r\n" + 
-//				"        \"agent_uid\":null,\r\n" + 
-//				"        \"is_enabled\":0,\r\n" + 
-//				"        \"robot_type\":4,\r\n" + 
-//				"        \"ip\":\"http://49.234.36.129:10002/\",\r\n" + 
-//				"        \"is_new\":1\r\n" + 
-//				"    }\r\n" + 
-//				"}\r\n" + 
-//				"";
-        JSONObject resultJson = JSONObject.fromObject(result);
-
-        if ("0000".equals(resultJson.optString("status"))) {
-            resultJson = resultJson.optJSONObject("data");
-            Type type = new TypeToken<RobotInfoDTO>() {
-            }.getType();
-            return new Gson().fromJson(resultJson.toString(), type);
-        }
-        return null;
-    }
-
-
-    /**
-     * 鏈哄櫒浜虹画璐�
-     *
-     * @param robotId 鏈哄櫒浜篿d
-     * @param wxid    寰俊鍙�
-     * @return
-     */
-    public static RobotInfoDTO robotRenewals(int robotId, int month) {
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        map.put("month", month + "");
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.change.get", map);
-
-//		String result = "{\r\n" + 
-//				"    \"status\":\"0000\",\r\n" + 
-//				"    \"msg\":\"\\u4eb2,\\u6dfb\\u52a0\\u6210\\u529f\",\r\n" + 
-//				"    \"data\":{\r\n" + 
-//				"        \"id\":11770,\r\n" + 
-//				"        \"uid\":1625,\r\n" + 
-//				"        \"wechatrobot\":\"fxdaka\",\r\n" + 
-//				"        \"wx_id\":\"wxid_vm6eb5i0in0622\",\r\n" + 
-//				"        \"amount_used\":0,\r\n" + 
-//				"        \"group_num\":20,\r\n" + 
-//				"        \"passwd\":\"\",\r\n" + 
-//				"        \"nickname\":\"\\u5206\\u4eab\\u5927\\u5496??\",\r\n" + 
-//				"        \"c_uid\":1625,\r\n" + 
-//				"        \"login_status\":1,\r\n" + 
-//				"        \"end_time\":1597377534,\r\n" + 
-//				"        \"remark\":null,\r\n" + 
-//				"        \"wc_id\":\"246124e9-9a8c-4da6-a77e-7f7f88049731\",\r\n" + 
-//				"        \"agent_uid\":null,\r\n" + 
-//				"        \"is_enabled\":0,\r\n" + 
-//				"        \"robot_type\":4,\r\n" + 
-//				"        \"ip\":\"http:\\/\\/49.234.36.129:10002\\/\",\r\n" + 
-//				"        \"is_new\":1\r\n" + 
-//				"    }\r\n" + 
-//				"}";
-//		
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            resultJson = resultJson.optJSONObject("data");
-            Type type = new TypeToken<RobotInfoDTO>() {
-            }.getType();
-            return new Gson().fromJson(resultJson.toString(), type);
-        }
-        return null;
-    }
-
-
-    /**
-     * 鍒犻櫎鏈哄櫒浜�
-     *
-     * @param robotId
-     * @return
-     */
-    public static boolean robotDelete(int robotId) {
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.delete.get", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            return true;
-        }
-        return false;
-    }
-
-
-    /**
-     * 鑾峰彇缇ゅ垪琛�
-     *
-     * @param robotId
-     * @return
-     */
-    public static List<String> getContract(int robotId) {
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.room.list", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            JSONArray groupArray = resultJson.optJSONArray("data");
-            if (groupArray != null && groupArray.size() > 0) {
-                Type type = new TypeToken<ArrayList<String>>() {
-                }.getType();
-                List<String> list = new Gson().fromJson(groupArray.toString(), type);
-                return list;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * 鑾峰彇缇ゅ垪琛�
-     *
-     * @param robotId
-     * @param roomId
-     * @return
-     */
-    public static WeiXinGroupDTO getGroupDetail(int robotId, String roomId) {
-        if (StringUtil.isNullOrEmpty(roomId)) {
-            return null;
-        }
-
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        map.put("room_id", roomId + ""); //  缇ょ殑id ,澶氫釜鐢ㄩ�楀彿闅斿紑
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.room.detail", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            JSONArray groupArray = resultJson.optJSONArray("data");
-            if (groupArray != null && groupArray.size() > 0) {
-                Type type = new TypeToken<ArrayList<WeiXinGroupDTO>>() {
-                }.getType();
-                List<WeiXinGroupDTO> goodsList = new Gson().fromJson(groupArray.toString(), type);
-                if (goodsList == null || goodsList.size() == 0) {
-                    return null;
-                } else {
-                    return goodsList.get(0);
-                }
-            }
-        }
-        return null;
-    }
-
-
-    /**
-     * 鑾峰彇缇ゅ垪琛�
-     *
-     * @param robotId
-     * @param roomId
-     * @return
-     */
-    public static List<WeiXinGroupDTO> getGroupDetail(int robotId, List<String> listRoomId) {
-        if (listRoomId == null || listRoomId.size() == 0) {
-            return null;
-        }
-
-        String roomIds = "";
-        for (String roomID : listRoomId) {
-            roomIds += roomID + ",";
-        }
-        if (roomIds.endsWith(","))
-            roomIds = roomIds.substring(0, roomIds.length() - 1);
-
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        map.put("room_id", roomIds); //  缇ょ殑id ,澶氫釜鐢ㄩ�楀彿闅斿紑
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.room.detail", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            JSONArray groupArray = resultJson.optJSONArray("data");
-            if (groupArray != null && groupArray.size() > 0) {
-                Type type = new TypeToken<ArrayList<WeiXinGroupDTO>>() {
-                }.getType();
-                List<WeiXinGroupDTO> goodsList = new Gson().fromJson(groupArray.toString(), type);
-                return goodsList;
-            }
-        }
-        return null;
-    }
-
-
-    /**
-     * 鍙戞湅鍙嬪湀
-     *
-     * @param robotId
-     * @param content
-     * @param picUrl  鍥剧墖url锛屽涓鐢�;鍒嗛殧
-     * @return
-     */
-    public static String macsendCircle(int robotId, String content, String picUrl) {
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        map.put("pic_url", picUrl);
-        map.put("content", content);
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.circle.send", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            resultJson = resultJson.optJSONObject("data");
-            if (resultJson != null) {
-                resultJson = resultJson.optJSONObject("object");
-                if (resultJson != null) {
-                    return resultJson.optString("id");
-                }
-            }
-        }
-        return null;
-    }
-
-    /**
-     * 鍙戞湅鍙嬪湀
-     *
-     * @param robotId
-     * @param content
-     * @param picUrl  鍥剧墖url锛屽涓鐢�;鍒嗛殧
-     * @return
-     */
-    public static String macsendUpload(int robotId, String picUrl) {
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        map.put("pic_url", picUrl);
-        map.put("type", "2");
-        String result = baseRequest("itaoke.robot.circle.upload", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            return resultJson.optString("data");
-        }
-        return null;
-    }
-
-
-    /**
-     * 鏈嬪弸鍦堝彂閫佽棰�
-     *
-     * @param robotId
-     * @param videoPath 瑙嗛鍦板潃
-     * @param thumbPath 灏侀潰url
-     * @return
-     */
-    public static String macsendCircleVideo(int robotId, String videoPath, String thumbPath) {
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        map.put("video_path", videoPath);
-        map.put("thumb_path", thumbPath);
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.macsend.videocircle", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            resultJson = resultJson.optJSONObject("data");
-            if (resultJson != null) {
-                resultJson = resultJson.optJSONObject("object");
-                if (resultJson != null) {
-                    return resultJson.optString("id");
-                }
-            }
-        }
-        return null;
-    }
-
-
-    /**
-     * 鏈嬪弸鍦堝彂閫佽棰�
-     *
-     * @param robotId
-     * @param videoPath 瑙嗛鍦板潃
-     * @param thumbPath 灏侀潰url
-     * @return
-     */
-    public static boolean macsendCircleComment(int robotId, String wxId, String msgId, String content) {
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        map.put("wx_id", wxId);
-        map.put("msg_id", msgId);
-        map.put("content", content);
-        map.put("comment_id", "0");
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.macsend.circlecomment", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            return true;
-        }
-        return false;
-    }
-
-
-    /**
-     * 鍙戞枃鏈秷鎭�
-     *
-     * @param robotId
-     * @param wxId    寰俊缇D
-     * @param content 鍐呭
-     * @return
-     */
-    public static boolean macsendText(int robotId, String toWxId, String content) {
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        map.put("toWxId", toWxId);
-        map.put("content", content);
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.macsend.text", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            return true;
-        }
-        return false;
-    }
-
-
-    /**
-     * 鍙慴ase64鍥�
-     *
-     * @param robotId
-     * @param wxId
-     * @param imgBase64
-     * @return
-     */
-    public static boolean macsendImgBase64(int robotId, String toWxId, String imgBase64) {
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        map.put("toWxId", toWxId);
-        map.put("base64_data", imgBase64);
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.macsend.base64", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * 鍙戦摼鎺ユ秷鎭�
-     *
-     * @param robotId
-     * @param wxId        寰俊缇D
-     * @param title       鏍囬
-     * @param url         閾炬帴
-     * @param description 鎻忚堪
-     * @param thumbUrl    鍥剧墖
-     * @return
-     */
-    public static boolean macsendCard(int robotId, String wxId, String title, String url,
-                                      String description, String thumbUrl) {
-        // 璇锋眰鍙傛暟
-        Map<String, String> map = new HashMap<>();
-        map.put("robot_id", robotId + "");
-        map.put("wx_id", wxId);
-        map.put("title", title);
-        map.put("url", url);
-        map.put("description", description);
-        map.put("thumbUrl", thumbUrl);
-        // 璇锋眰缁撴灉
-        String result = baseRequest("itaoke.robot.macsend.card", map);
-        JSONObject resultJson = JSONObject.fromObject(result);
-        if ("0000".equals(resultJson.optString("status"))) {
-            return true;
-        }
-        return false;
-    }
-
-
-}
+package com.yeshi.fanli.util.aitaoker;
+
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Type;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import com.yeshi.fanli.log.LogHelper;
+import org.yeshi.utils.HttpUtil;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import com.yeshi.fanli.dto.aitaoker.QrcodeLoginDTO;
+import com.yeshi.fanli.dto.aitaoker.RobotInfoDTO;
+import com.yeshi.fanli.dto.aitaoker.WeiXinGroupDTO;
+import com.yeshi.fanli.util.StringUtil;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+public class AitaokerApiUtil {
+    public static String APP_KEY = "1077080250";
+    public static String SECRET_KEY = "7c6118bd-7aa5-65b8-c6d4-058728e9446f";
+    // 璇锋眰杩炴帴
+    private static String SERVER_URL = "http://router.itaoke.org/api";
+
+
+    private static String baseRequest(String method, Map<String, String> param) {
+        Map<String, String> baseMap = new HashMap<>();
+        baseMap.put("app_key", APP_KEY);
+        baseMap.put("v", "1.0");
+        baseMap.put("format", "json");
+        baseMap.put("sign_method", "md5");
+        baseMap.put("timestamp", System.currentTimeMillis() + "");
+        baseMap.put("method", method);
+        baseMap.put("domain", "hi.flqapp.com");
+        baseMap.put("client", "113.249.194.232");
+        baseMap.put("partner_id", "top-sdk-php-20190618");
+        String url = combinedUrl(baseMap);
+
+        if (param != null) {
+            Iterator<String> its = param.keySet().iterator();
+            while (its.hasNext()) {
+                String key = its.next();
+                baseMap.put(key, param.get(key));
+            }
+        }
+        url += "sign=" + getSign(baseMap);
+        String result = HttpUtil.post(url, param);
+        LogHelper.cloudInfo(method + ":" + result);
+        return result;
+    }
+
+    /**
+     * 鎷兼帴鎵�鏈夌郴缁熷弬鏁板寘鎷瑂ign鐨剈rl
+     *
+     * @param params
+     * @return
+     */
+    private static String combinedUrl(Map<String, String> params) {
+        String url = SERVER_URL + "?";
+        Iterator<String> its = params.keySet().iterator();
+        while (its.hasNext()) {
+            String key = its.next();
+            try {
+                url += String.format("%s=%s&", key, URLEncoder.encode(params.get(key), "UTF-8"));
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+        }
+        return url;
+    }
+
+    /**
+     * 鑾峰彇绛惧悕
+     *
+     * @param params
+     * @return
+     */
+    private static String getSign(Map<String, String> params) {
+        List<String> list = new ArrayList<>();
+        Iterator<String> its = params.keySet().iterator();
+        while (its.hasNext()) {
+            String key = its.next();
+            list.add(key + params.get(key));
+        }
+        Collections.sort(list);
+
+        String str = "";
+        for (String st : list) {
+            str += st;
+        }
+        return StringUtil.Md5(SECRET_KEY + str + SECRET_KEY).toUpperCase();
+    }
+
+    /**
+     * 鑾峰彇鐧诲綍浜岀淮鐮�
+     *
+     * @param robotId
+     * @return
+     */
+    public static QrcodeLoginDTO getQrcodeMaclogin(int robotId) {
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        String result = baseRequest("itaoke.robot.qrcode.maclogin", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        resultJson = resultJson.optJSONObject("data");
+        if (resultJson != null) {
+            Type type = new TypeToken<QrcodeLoginDTO>() {
+            }.getType();
+            return new Gson().fromJson(resultJson.toString(), type);
+        }
+        return null;
+    }
+
+
+    /**
+     * 妫�鏌ユ槸鍚︾櫥闄嗭紙鐪熸鐨勭櫥褰曟帴鍙o級
+     *
+     * @param robotId 鏈哄櫒浜篿d
+     * @param wId     鑾峰彇浜岀淮鐮佹帴鍙h繑鍥炵殑寰俊瀹炰緥id
+     * @return
+     */
+    public static QrcodeLoginDTO getQrcodeMacloginCheck(int robotId, String wId) {
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        map.put("uuid", wId);
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.async.mlogin", map);
+
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            resultJson = resultJson.optJSONObject("data");
+            if (resultJson != null) {
+                Type type = new TypeToken<QrcodeLoginDTO>() {
+                }.getType();
+                return new Gson().fromJson(resultJson.toString(), type);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 妫�鏌ユ槸鍚﹀湪绾�
+     *
+     * @param robotId 鏈哄櫒浜篿d
+     * @return
+     */
+    public static boolean onlineCheck(int robotId) {
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        String result = baseRequest("itaoke.robot.check.online", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            return true;
+//            resultJson = resultJson.optJSONObject("data");
+//            if (resultJson != null) {
+//                return resultJson.optBoolean("isOnline");
+//            }
+        }
+        return false;
+    }
+
+
+    /**
+     * 4.寮哄埗涓嬬嚎
+     *
+     * @param robotId 鏈哄櫒浜篿d
+     * @return
+     */
+    public static boolean macloginOffline(int robotId) {
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.force.offline", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            return true;
+        }
+        return false;
+    }
+
+
+    /**
+     * 鍒涘缓鏈哄櫒浜�
+     *
+     * @param month       鏈堟暟
+     * @param robotType   鏈哄櫒浜虹被鍨� 1 鍙戝崟鏈哄櫒浜� 2杞彂鏈哄櫒浜� 3 杩斿埄鏈哄櫒浜� 4鍏ㄨ兘鏈哄櫒浜� 5灏忓瀷鏈哄櫒浜� 6鍙戝湀鏈哄櫒浜�
+     * @param wechatrobot 寰俊鍙�
+     * @param agentUid    浠g悊id
+     * @return
+     */
+    public static RobotInfoDTO robotCreate(int month, int robotType, String wechatrobot, String agentUid) {
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("month", month + "");
+        map.put("robot_type", robotType + "");
+        map.put("wechatrobot", wechatrobot);
+        if (!StringUtil.isNullOrEmpty(agentUid))
+            map.put("agent_uid", agentUid);
+
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.create.get", map);
+
+//		String result = "{\r\n" + 
+//				"    \"status\":\"0000\",\r\n" + 
+//				"    \"msg\":\"浜�,娣诲姞鎴愬姛\",\r\n" + 
+//				"    \"data\":{\r\n" + 
+//				"        \"id\":11770,\r\n" + 
+//				"        \"uid\":1625,\r\n" + 
+//				"        \"wechatrobot\":\"wechatrobot\",\r\n" + 
+//				"        \"wx_id\":\"\",\r\n" + 
+//				"        \"amount_used\":0,\r\n" + 
+//				"        \"group_num\":20,\r\n" + 
+//				"        \"passwd\":\"\",\r\n" + 
+//				"        \"nickname\":\"\",\r\n" + 
+//				"        \"c_uid\":1625,\r\n" + 
+//				"        \"login_status\":0,\r\n" + 
+//				"        \"end_time\":1594785534,\r\n" + 
+//				"        \"remark\":null,\r\n" + 
+//				"        \"wc_id\":\"\",\r\n" + 
+//				"        \"agent_uid\":null,\r\n" + 
+//				"        \"is_enabled\":0,\r\n" + 
+//				"        \"robot_type\":4,\r\n" + 
+//				"        \"ip\":\"http://49.234.36.129:10002/\",\r\n" + 
+//				"        \"is_new\":1\r\n" + 
+//				"    }\r\n" + 
+//				"}\r\n" + 
+//				"";
+        JSONObject resultJson = JSONObject.fromObject(result);
+
+        if ("0000".equals(resultJson.optString("status"))) {
+            resultJson = resultJson.optJSONObject("data");
+            Type type = new TypeToken<RobotInfoDTO>() {
+            }.getType();
+            return new Gson().fromJson(resultJson.toString(), type);
+        }
+        return null;
+    }
+
+
+    /**
+     * 鏈哄櫒浜虹画璐�
+     *
+     * @param robotId 鏈哄櫒浜篿d
+     * @param wxid    寰俊鍙�
+     * @return
+     */
+    public static RobotInfoDTO robotRenewals(int robotId, int month) {
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        map.put("month", month + "");
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.change.get", map);
+
+//		String result = "{\r\n" + 
+//				"    \"status\":\"0000\",\r\n" + 
+//				"    \"msg\":\"\\u4eb2,\\u6dfb\\u52a0\\u6210\\u529f\",\r\n" + 
+//				"    \"data\":{\r\n" + 
+//				"        \"id\":11770,\r\n" + 
+//				"        \"uid\":1625,\r\n" + 
+//				"        \"wechatrobot\":\"fxdaka\",\r\n" + 
+//				"        \"wx_id\":\"wxid_vm6eb5i0in0622\",\r\n" + 
+//				"        \"amount_used\":0,\r\n" + 
+//				"        \"group_num\":20,\r\n" + 
+//				"        \"passwd\":\"\",\r\n" + 
+//				"        \"nickname\":\"\\u5206\\u4eab\\u5927\\u5496??\",\r\n" + 
+//				"        \"c_uid\":1625,\r\n" + 
+//				"        \"login_status\":1,\r\n" + 
+//				"        \"end_time\":1597377534,\r\n" + 
+//				"        \"remark\":null,\r\n" + 
+//				"        \"wc_id\":\"246124e9-9a8c-4da6-a77e-7f7f88049731\",\r\n" + 
+//				"        \"agent_uid\":null,\r\n" + 
+//				"        \"is_enabled\":0,\r\n" + 
+//				"        \"robot_type\":4,\r\n" + 
+//				"        \"ip\":\"http:\\/\\/49.234.36.129:10002\\/\",\r\n" + 
+//				"        \"is_new\":1\r\n" + 
+//				"    }\r\n" + 
+//				"}";
+//		
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            resultJson = resultJson.optJSONObject("data");
+            Type type = new TypeToken<RobotInfoDTO>() {
+            }.getType();
+            return new Gson().fromJson(resultJson.toString(), type);
+        }
+        return null;
+    }
+
+
+    /**
+     * 鍒犻櫎鏈哄櫒浜�
+     *
+     * @param robotId
+     * @return
+     */
+    public static boolean robotDelete(int robotId) {
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.delete.get", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            return true;
+        }
+        return false;
+    }
+
+
+    /**
+     * 鑾峰彇缇ゅ垪琛�
+     *
+     * @param robotId
+     * @return
+     */
+    public static List<String> getContract(int robotId) {
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.room.list", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            JSONArray groupArray = resultJson.optJSONArray("data");
+            if (groupArray != null && groupArray.size() > 0) {
+                Type type = new TypeToken<ArrayList<String>>() {
+                }.getType();
+                List<String> list = new Gson().fromJson(groupArray.toString(), type);
+                return list;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 鑾峰彇缇ゅ垪琛�
+     *
+     * @param robotId
+     * @param roomId
+     * @return
+     */
+    public static WeiXinGroupDTO getGroupDetail(int robotId, String roomId) {
+        if (StringUtil.isNullOrEmpty(roomId)) {
+            return null;
+        }
+
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        map.put("room_id", roomId + ""); //  缇ょ殑id ,澶氫釜鐢ㄩ�楀彿闅斿紑
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.room.detail", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            JSONArray groupArray = resultJson.optJSONArray("data");
+            if (groupArray != null && groupArray.size() > 0) {
+                Type type = new TypeToken<ArrayList<WeiXinGroupDTO>>() {
+                }.getType();
+                List<WeiXinGroupDTO> goodsList = new Gson().fromJson(groupArray.toString(), type);
+                if (goodsList == null || goodsList.size() == 0) {
+                    return null;
+                } else {
+                    return goodsList.get(0);
+                }
+            }
+        }
+        return null;
+    }
+
+
+    /**
+     * 鑾峰彇缇ゅ垪琛�
+     *
+     * @param robotId
+     * @param roomId
+     * @return
+     */
+    public static List<WeiXinGroupDTO> getGroupDetail(int robotId, List<String> listRoomId) {
+        if (listRoomId == null || listRoomId.size() == 0) {
+            return null;
+        }
+
+        String roomIds = "";
+        for (String roomID : listRoomId) {
+            roomIds += roomID + ",";
+        }
+        if (roomIds.endsWith(","))
+            roomIds = roomIds.substring(0, roomIds.length() - 1);
+
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        map.put("room_id", roomIds); //  缇ょ殑id ,澶氫釜鐢ㄩ�楀彿闅斿紑
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.room.detail", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            JSONArray groupArray = resultJson.optJSONArray("data");
+            if (groupArray != null && groupArray.size() > 0) {
+                Type type = new TypeToken<ArrayList<WeiXinGroupDTO>>() {
+                }.getType();
+                List<WeiXinGroupDTO> goodsList = new Gson().fromJson(groupArray.toString(), type);
+                return goodsList;
+            }
+        }
+        return null;
+    }
+
+
+    /**
+     * 鍙戞湅鍙嬪湀
+     *
+     * @param robotId
+     * @param content
+     * @param picUrl  鍥剧墖url锛屽涓鐢�;鍒嗛殧
+     * @return
+     */
+    public static String macsendCircle(int robotId, String content, String picUrl) {
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        map.put("pic_url", picUrl);
+        map.put("content", content);
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.circle.send", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            resultJson = resultJson.optJSONObject("data");
+            if (resultJson != null) {
+                resultJson = resultJson.optJSONObject("object");
+                if (resultJson != null) {
+                    return resultJson.optString("id");
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 鍙戞湅鍙嬪湀
+     *
+     * @param robotId
+     * @param content
+     * @param picUrl  鍥剧墖url锛屽涓鐢�;鍒嗛殧
+     * @return
+     */
+    public static String macsendUpload(int robotId, String picUrl) {
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        map.put("pic_url", picUrl);
+        map.put("type", "2");
+        String result = baseRequest("itaoke.robot.circle.upload", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            return resultJson.optString("data");
+        }
+        return null;
+    }
+
+
+    /**
+     * 鏈嬪弸鍦堝彂閫佽棰�
+     *
+     * @param robotId
+     * @param videoPath 瑙嗛鍦板潃
+     * @param thumbPath 灏侀潰url
+     * @return
+     */
+    public static String macsendCircleVideo(int robotId, String videoPath, String thumbPath) {
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        map.put("video_path", videoPath);
+        map.put("thumb_path", thumbPath);
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.macsend.videocircle", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            resultJson = resultJson.optJSONObject("data");
+            if (resultJson != null) {
+                resultJson = resultJson.optJSONObject("object");
+                if (resultJson != null) {
+                    return resultJson.optString("id");
+                }
+            }
+        }
+        return null;
+    }
+
+
+    /**
+     * 鏈嬪弸鍦堝彂閫佽棰�
+     *
+     * @param robotId
+     * @param videoPath 瑙嗛鍦板潃
+     * @param thumbPath 灏侀潰url
+     * @return
+     */
+    public static boolean macsendCircleComment(int robotId, String wxId, String msgId, String content) {
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        map.put("wx_id", wxId);
+        map.put("msg_id", msgId);
+        map.put("content", content);
+        map.put("comment_id", "0");
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.macsend.circlecomment", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            return true;
+        }
+        return false;
+    }
+
+
+    /**
+     * 鍙戞枃鏈秷鎭�
+     *
+     * @param robotId
+     * @param wxId    寰俊缇D
+     * @param content 鍐呭
+     * @return
+     */
+    public static boolean macsendText(int robotId, String toWxId, String content) {
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        map.put("toWxId", toWxId);
+        map.put("content", content);
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.macsend.text", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            return true;
+        }
+        return false;
+    }
+
+
+    /**
+     * 鍙慴ase64鍥�
+     *
+     * @param robotId
+     * @param wxId
+     * @param imgBase64
+     * @return
+     */
+    public static boolean macsendImgBase64(int robotId, String toWxId, String imgBase64) {
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        map.put("toWxId", toWxId);
+        map.put("base64_data", imgBase64);
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.macsend.base64", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 鍙戦摼鎺ユ秷鎭�
+     *
+     * @param robotId
+     * @param wxId        寰俊缇D
+     * @param title       鏍囬
+     * @param url         閾炬帴
+     * @param description 鎻忚堪
+     * @param thumbUrl    鍥剧墖
+     * @return
+     */
+    public static boolean macsendCard(int robotId, String wxId, String title, String url,
+                                      String description, String thumbUrl) {
+        // 璇锋眰鍙傛暟
+        Map<String, String> map = new HashMap<>();
+        map.put("robot_id", robotId + "");
+        map.put("wx_id", wxId);
+        map.put("title", title);
+        map.put("url", url);
+        map.put("description", description);
+        map.put("thumbUrl", thumbUrl);
+        // 璇锋眰缁撴灉
+        String result = baseRequest("itaoke.robot.macsend.card", map);
+        JSONObject resultJson = JSONObject.fromObject(result);
+        if ("0000".equals(resultJson.optString("status"))) {
+            return true;
+        }
+        return false;
+    }
+
+
+}

--
Gitblit v1.8.0