From c9cbad5f5d18c6b2ac5a063e41007933d7028329 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 07 七月 2020 15:24:17 +0800
Subject: [PATCH] 返利配置文件加入系统区分

---
 fanli/src/main/java/com/yeshi/fanli/util/aitaoker/AitaokerApiUtil.java | 1032 +++++++++++++++++++++++++++++----------------------------
 1 files changed, 528 insertions(+), 504 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 ca4f9b8..588ae45 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
@@ -10,6 +10,7 @@
 import java.util.List;
 import java.util.Map;
 
+import com.yeshi.fanli.log.LogHelper;
 import org.yeshi.utils.HttpUtil;
 
 import com.google.gson.Gson;
@@ -23,178 +24,191 @@
 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);
-		return HttpUtil.post(url, param);
-	}
-	
-	/**
-	 * 鎷兼帴鎵�鏈夌郴缁熷弬鏁板寘鎷瑂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"))) {
-			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);
-		
+    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" + 
@@ -220,32 +234,33 @@
 //				"    }\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);
-		
+        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" + 
@@ -271,311 +286,320 @@
 //				"    }\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;
-	}
-	
-	
+        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;
+    }
 
-	/**
-	 * 鍙慴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;
-	}
-	
-	
-	
+
+    /**
+     * 鍒犻櫎鏈哄櫒浜�
+     *
+     * @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