From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/util/ShamHongBaoUtil.java |  290 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 145 insertions(+), 145 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/ShamHongBaoUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/ShamHongBaoUtil.java
index 944a13a..72d46d7 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/ShamHongBaoUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/ShamHongBaoUtil.java
@@ -1,145 +1,145 @@
-package com.yeshi.fanli.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import javax.annotation.Resource;
-
-import com.yeshi.fanli.entity.SystemEnum;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.springframework.stereotype.Component;
-
-import com.yeshi.fanli.entity.bus.user.ShamUser;
-import com.yeshi.fanli.entity.bus.user.UserInfo;
-import com.yeshi.fanli.service.inter.user.ShamUserService;
-import com.yeshi.fanli.service.inter.user.UserInfoService;
-
-import jxl.Cell;
-import jxl.Sheet;
-import jxl.Workbook;
-import jxl.read.biff.BiffException;
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-
-@Component
-public class ShamHongBaoUtil {
-
-	@Resource
-	private ShamUserService shamUserService;
-
-	@Resource
-	private UserInfoService userInfoService;
-
-	public void addShamUserInfo() {
-		List<ShamUser> list = shamUserService.getAll();
-		for (ShamUser shamUser : list) {
-			UserInfo form = new UserInfo();
-			form.setNickName(shamUser.getName());
-			form.setPortrait(shamUser.getPicUrl());
-			form.setLoginType(-1);
-			form.setOpenid(UUID.randomUUID().toString().replaceAll("-", "") + "-1");
-			userInfoService.addUser(form, SystemEnum.blks);
-		}
-	}
-
-	public void deleteShamUser(String path) {
-		try {
-			Workbook workbook = Workbook.getWorkbook(new File(path));
-			Sheet sheet = workbook.getSheet(0);
-			for (int ii = 0; ii < sheet.getRows(); ii++) {
-				Cell cell = sheet.getCell(0, ii);
-				if (cell.getContents() == null || "".equals(cell.getContents().trim())) {
-					continue;
-				}
-				shamUserService.deleteByPrimaryKey(Long.parseLong(cell.getContents()));
-			}
-		} catch (BiffException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-
-	}
-
-	public void addShamUser(String pid) throws Exception {
-		HttpClient client = new HttpClient();
-		HttpMethod method = getPostMethod(pid);
-		client.executeMethod(method);
-		java.lang.System.out.println(method.getStatusLine()); // 鎵撳嵃缁撴灉椤甸潰
-		String response = new String(method.getResponseBodyAsString().getBytes("UTF-8"));
-		// 鎵撳嵃杩斿洖鐨勪俊鎭�
-		method.releaseConnection();
-		List<ShamUser> list = parseQQresult(response);
-		for (ShamUser shamUser : list) {
-			shamUserService.addShamUser(shamUser);
-		}
-	}
-
-	private static List<ShamUser> parseQQresult(String response) throws Exception {
-		JSONObject json = JSONObject.fromObject(response);
-		List<ShamUser> list = new ArrayList<ShamUser>();
-		String code = String.valueOf(json.opt("retcode"));
-		if ("0".equals(code)) {
-			JSONArray jsonArray = json.optJSONObject("result").optJSONObject("buddy").optJSONArray("info_list");
-			ShamUser user = null;
-			String patterns = "[^\u4e00-\u9fa5\\w\\s]+";
-			if (jsonArray == null) {
-				return list;
-			}
-			for (Object object : jsonArray) {
-				JSONObject data = (JSONObject) object;
-				String name = (String) data.opt("nick");
-				name = name.replaceAll(patterns, "").replaceAll(" ", "");
-				if (name.length() < 2) {
-					continue;
-				}
-				String picUrl = (String) data.opt("url");
-				user = new ShamUser();
-				user.setName(new String(name.getBytes(), "utf-8"));
-				if (picUrl.contains("pub.idqqimg.com")) {
-					picUrl = "https://gw.alicdn.com/tps/i3/TB1yeWeIFXXXXX5XFXXuAZJYXXX-210-210.png_160x160.jpg";
-				}
-				user.setPicUrl(picUrl);
-				list.add(user);
-			}
-		}
-		return list;
-	}
-
-	private static HttpMethod getPostMethod(String pid) {
-		PostMethod post = new PostMethod("http://cgi.find.qq.com/qqfind/buddy/search_v3"); // recommendDetails
-																							// voteGoods
-																							// recommendReplys
-																							// makePublic
-																							// replys
-		NameValuePair num = new NameValuePair("num", "100");
-		NameValuePair page = new NameValuePair("page", "0");
-		NameValuePair sessionid = new NameValuePair("sessionid", "0");
-		NameValuePair agerg = new NameValuePair("agerg", "13");
-		NameValuePair sex = new NameValuePair("sex", "0");
-		NameValuePair firston = new NameValuePair("firston", "0");
-		NameValuePair video = new NameValuePair("video", "0");
-		NameValuePair country = new NameValuePair("country", "1");
-		NameValuePair province = new NameValuePair("province", pid);
-		NameValuePair city = new NameValuePair("city", "0");
-		NameValuePair district = new NameValuePair("district", "0");
-		NameValuePair hcountry = new NameValuePair("hcountry", "1");
-		NameValuePair hprovince = new NameValuePair("hprovince", "0");
-		NameValuePair hcity = new NameValuePair("hcity", "0");
-		NameValuePair hdistrict = new NameValuePair("hdistrict", "0");
-		NameValuePair online = new NameValuePair("online", "0");
-		NameValuePair ldw = new NameValuePair("ldw", "814539287");
-		post.setRequestHeader("Cookie",
-				"RK=7dVSTqdaSf; pt2gguin=o0424539852; ptisp=ctc; ptcz=555762bb1a6cef860451fe47677c82eaf80a1388eee045b8cf2d546ed1c96534; _qpsvr_localtk=tk70; pgv_info=ssid=s852802188; pgv_pvid=9584824304; uin=o424539852; skey=Z9PWyiIOuI; itkn=2002088896");
-		post.setRequestBody(new NameValuePair[] { num, page, sessionid, agerg, sex, firston, video, country, province,
-				city, district, hcountry, hprovince, hcity, hdistrict, online, ldw });
-		return post;
-	}
-
-}
+package com.yeshi.fanli.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import javax.annotation.Resource;
+
+import com.yeshi.fanli.entity.SystemEnum;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.springframework.stereotype.Component;
+
+import com.yeshi.fanli.entity.bus.user.ShamUser;
+import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.service.inter.user.ShamUserService;
+import com.yeshi.fanli.service.inter.user.UserInfoService;
+
+import jxl.Cell;
+import jxl.Sheet;
+import jxl.Workbook;
+import jxl.read.biff.BiffException;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+@Component
+public class ShamHongBaoUtil {
+
+	@Resource
+	private ShamUserService shamUserService;
+
+	@Resource
+	private UserInfoService userInfoService;
+
+	public void addShamUserInfo() {
+		List<ShamUser> list = shamUserService.getAll();
+		for (ShamUser shamUser : list) {
+			UserInfo form = new UserInfo();
+			form.setNickName(shamUser.getName());
+			form.setPortrait(shamUser.getPicUrl());
+			form.setLoginType(-1);
+			form.setOpenid(UUID.randomUUID().toString().replaceAll("-", "") + "-1");
+			userInfoService.addUser(form, SystemEnum.blks);
+		}
+	}
+
+	public void deleteShamUser(String path) {
+		try {
+			Workbook workbook = Workbook.getWorkbook(new File(path));
+			Sheet sheet = workbook.getSheet(0);
+			for (int ii = 0; ii < sheet.getRows(); ii++) {
+				Cell cell = sheet.getCell(0, ii);
+				if (cell.getContents() == null || "".equals(cell.getContents().trim())) {
+					continue;
+				}
+				shamUserService.deleteByPrimaryKey(Long.parseLong(cell.getContents()));
+			}
+		} catch (BiffException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+	}
+
+	public void addShamUser(String pid) throws Exception {
+		HttpClient client = new HttpClient();
+		HttpMethod method = getPostMethod(pid);
+		client.executeMethod(method);
+		java.lang.System.out.println(method.getStatusLine()); // 鎵撳嵃缁撴灉椤甸潰
+		String response = new String(method.getResponseBodyAsString().getBytes("UTF-8"));
+		// 鎵撳嵃杩斿洖鐨勪俊鎭�
+		method.releaseConnection();
+		List<ShamUser> list = parseQQresult(response);
+		for (ShamUser shamUser : list) {
+			shamUserService.addShamUser(shamUser);
+		}
+	}
+
+	private static List<ShamUser> parseQQresult(String response) throws Exception {
+		JSONObject json = JSONObject.fromObject(response);
+		List<ShamUser> list = new ArrayList<ShamUser>();
+		String code = String.valueOf(json.opt("retcode"));
+		if ("0".equals(code)) {
+			JSONArray jsonArray = json.optJSONObject("result").optJSONObject("buddy").optJSONArray("info_list");
+			ShamUser user = null;
+			String patterns = "[^\u4e00-\u9fa5\\w\\s]+";
+			if (jsonArray == null) {
+				return list;
+			}
+			for (Object object : jsonArray) {
+				JSONObject data = (JSONObject) object;
+				String name = (String) data.opt("nick");
+				name = name.replaceAll(patterns, "").replaceAll(" ", "");
+				if (name.length() < 2) {
+					continue;
+				}
+				String picUrl = (String) data.opt("url");
+				user = new ShamUser();
+				user.setName(new String(name.getBytes(), "utf-8"));
+				if (picUrl.contains("pub.idqqimg.com")) {
+					picUrl = "https://gw.alicdn.com/tps/i3/TB1yeWeIFXXXXX5XFXXuAZJYXXX-210-210.png_160x160.jpg";
+				}
+				user.setPicUrl(picUrl);
+				list.add(user);
+			}
+		}
+		return list;
+	}
+
+	private static HttpMethod getPostMethod(String pid) {
+		PostMethod post = new PostMethod("http://cgi.find.qq.com/qqfind/buddy/search_v3"); // recommendDetails
+																							// voteGoods
+																							// recommendReplys
+																							// makePublic
+																							// replys
+		NameValuePair num = new NameValuePair("num", "100");
+		NameValuePair page = new NameValuePair("page", "0");
+		NameValuePair sessionid = new NameValuePair("sessionid", "0");
+		NameValuePair agerg = new NameValuePair("agerg", "13");
+		NameValuePair sex = new NameValuePair("sex", "0");
+		NameValuePair firston = new NameValuePair("firston", "0");
+		NameValuePair video = new NameValuePair("video", "0");
+		NameValuePair country = new NameValuePair("country", "1");
+		NameValuePair province = new NameValuePair("province", pid);
+		NameValuePair city = new NameValuePair("city", "0");
+		NameValuePair district = new NameValuePair("district", "0");
+		NameValuePair hcountry = new NameValuePair("hcountry", "1");
+		NameValuePair hprovince = new NameValuePair("hprovince", "0");
+		NameValuePair hcity = new NameValuePair("hcity", "0");
+		NameValuePair hdistrict = new NameValuePair("hdistrict", "0");
+		NameValuePair online = new NameValuePair("online", "0");
+		NameValuePair ldw = new NameValuePair("ldw", "814539287");
+		post.setRequestHeader("Cookie",
+				"RK=7dVSTqdaSf; pt2gguin=o0424539852; ptisp=ctc; ptcz=555762bb1a6cef860451fe47677c82eaf80a1388eee045b8cf2d546ed1c96534; _qpsvr_localtk=tk70; pgv_info=ssid=s852802188; pgv_pvid=9584824304; uin=o424539852; skey=Z9PWyiIOuI; itkn=2002088896");
+		post.setRequestBody(new NameValuePair[] { num, page, sessionid, agerg, sex, firston, video, country, province,
+				city, district, hcountry, hprovince, hcity, hdistrict, online, ldw });
+		return post;
+	}
+
+}

--
Gitblit v1.8.0