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/taobao/TaoBaoCouponUtil.java |  378 +++++++++++++++++++++++++++---------------------------
 1 files changed, 189 insertions(+), 189 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoCouponUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoCouponUtil.java
index 6de83c8..ad4f639 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoCouponUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoCouponUtil.java
@@ -1,189 +1,189 @@
-package com.yeshi.fanli.util.taobao;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import jxl.Sheet;
-import jxl.Workbook;
-import jxl.read.biff.BiffException;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.params.HttpClientParams;
-
-import com.yeshi.fanli.entity.taobao.TaoBaoCoupon;
-import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
-import com.yeshi.fanli.util.MoneyBigDecimalUtil;
-import com.yeshi.fanli.util.StringUtil;
-
-public class TaoBaoCouponUtil {
-
-	private final static String CAT = "澶╃尗";
-	private final static String TAOBAO = "娣樺疂";
-
-	public static Set<TaoBaoCoupon> getTaoBaoCouponList(TaoBaoUnionConfig config) {
-		String cookie = TaoBaoOrderUtil.getTaoBaoCookie(config.getAccount());
-		if (com.yeshi.fanli.util.StringUtil.isNullOrEmpty(cookie)) {
-			return null;
-		}
-		HttpClient client = new HttpClient();
-
-		String siteId = config.getDefaultPid().split("_")[2];
-		String adzoneId = config.getDefaultPid().split("_")[3];
-
-		String url = "http://pub.alimama.com/coupon/qq/export.json?adzoneId=" + adzoneId + "&siteId=" + siteId;
-		GetMethod method = new GetMethod(url);
-		method.setRequestHeader("Cookie", cookie);
-		method.setRequestHeader("User-Agent",
-				"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36");
-		method.setRequestHeader("Referer", "http://pub.alimama.com/myunion.htm");
-		client.setParams(new HttpClientParams());
-		InputStream inputStream = null;
-		try {
-			client.executeMethod(method);
-			if (method.getStatusCode() == 200) {
-				System.out.println(method.getResponseHeader("Content-Type").getValue());
-				if (!method.getResponseHeader("Content-Type").getValue().contains("excel")) {
-					TaoBaoOrderUtil.reportCookieInvalid(config.getAccount());
-					return null;
-				}
-
-				inputStream = method.getResponseBodyAsStream();
-				return parseTaoBaoCoupon(inputStream);
-			}
-		} catch (HttpException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		} finally {
-			if (inputStream != null) {
-				try {
-					inputStream.close();
-				} catch (IOException e) {
-					e.printStackTrace();
-				}
-			}
-		}
-		return null;
-	}
-
-	private static Set<TaoBaoCoupon> parseTaoBaoCoupon(InputStream inputStream) {
-		jxl.Workbook rwb = null;
-		try {
-			rwb = Workbook.getWorkbook(inputStream);
-		} catch (BiffException e) {
-			return null;
-		} catch (IOException e) {
-			return null;
-		}
-		Sheet sheet = rwb.getSheet(0);
-		Set<TaoBaoCoupon> set = new HashSet<TaoBaoCoupon>();
-		TaoBaoCoupon taoBaoCoupon = null;
-		int rows = sheet.getRows();
-		for (int r = 1; r < rows; r++) {
-			taoBaoCoupon = new TaoBaoCoupon();
-			taoBaoCoupon.setAuctionId(sheet.getCell(0, r).getContents().trim());
-			taoBaoCoupon.setTitle(sheet.getCell(1, r).getContents().trim());
-			taoBaoCoupon.setPictUrl(sheet.getCell(2, r).getContents().trim());
-			taoBaoCoupon.setAuctionUrl(sheet.getCell(3, r).getContents().trim());
-			taoBaoCoupon.setClassNames(sheet.getCell(4, r).getContents().trim());
-			// taoBaoCoupon.setTaobaokeUrl(sheet.getCell(5,
-			// r).getContents().trim());
-			String zkStr = sheet.getCell(6, r).getContents().trim();
-			String bizStr = sheet.getCell(7, r).getContents().trim();
-			taoBaoCoupon.setShopWangWang(sheet.getCell(10, r).getContents().trim());
-			taoBaoCoupon.setShopTitle(sheet.getCell(12, r).getContents().trim());
-			String typeStr = sheet.getCell(13, r).getContents().trim();
-			int type = 0;
-			if (TAOBAO.equals(typeStr)) {
-				type = 1;
-			} else if (CAT.equals(typeStr)) {
-				type = 2;
-			}
-			taoBaoCoupon.setShopType(type);
-			taoBaoCoupon.setCouponId(sheet.getCell(14, r).getContents().trim());
-
-			String info = sheet.getCell(17, r).getContents().trim();
-			List<BigDecimal> arr = getCouponInfo(info);
-			taoBaoCoupon.setCouponinfo(info);
-			taoBaoCoupon.setCouponStartFee(arr.get(0));
-			taoBaoCoupon.setCouponAmount(arr.get(1));
-
-			taoBaoCoupon.setCouponBegin(sheet.getCell(18, r).getContents().trim());
-			taoBaoCoupon.setCouponEnd(sheet.getCell(19, r).getContents().trim());
-			taoBaoCoupon.setCouponLink(sheet.getCell(20, r).getContents().trim());
-			// taoBaoCoupon.setGeneralizeUrl(sheet.getCell(21,
-			// r).getContents().trim());
-			taoBaoCoupon.setCreatetime(System.currentTimeMillis());
-
-			try {
-				taoBaoCoupon.setZkPrice(new BigDecimal(zkStr));
-				taoBaoCoupon.setBiz30day(Integer.parseInt(bizStr));
-				taoBaoCoupon.setTkRate(Double.parseDouble(sheet.getCell(8, r).getContents().trim()));
-				taoBaoCoupon.setBrokerage(new BigDecimal(sheet.getCell(9, r).getContents().trim()));
-				taoBaoCoupon.setSellerId(Long.parseLong(sheet.getCell(11, r).getContents().trim()));
-				taoBaoCoupon.setCouponSum(Integer.parseInt(sheet.getCell(15, r).getContents().trim()));
-				taoBaoCoupon.setCouponCount(Integer.parseInt(sheet.getCell(16, r).getContents().trim()));
-			} catch (NumberFormatException e) {
-				e.printStackTrace();
-				continue;
-			}
-			if (MoneyBigDecimalUtil.sub(taoBaoCoupon.getZkPrice(), taoBaoCoupon.getCouponStartFee())
-					.doubleValue() >= 0) {
-				taoBaoCoupon.setQuanPrice(
-						MoneyBigDecimalUtil.sub(taoBaoCoupon.getZkPrice(), taoBaoCoupon.getCouponAmount()));
-				taoBaoCoupon.setShowType(3);
-			} else {
-				taoBaoCoupon.setQuanPrice(taoBaoCoupon.getZkPrice());
-				taoBaoCoupon.setShowType(2);
-			}
-			taoBaoCoupon.setOrderby(10000);
-			set.add(taoBaoCoupon);
-		}
-		return set;
-	}
-
-	public static List<BigDecimal> getCouponInfo(String info) {
-		Pattern p = Pattern.compile("婊\d+(\\.\\d+)?鍏冨噺\\d+(\\.\\d+)?鍏�");
-		Matcher matcher = p.matcher(info);
-		Pattern p2 = Pattern.compile("\\d+鍏冩棤鏉′欢鍒�");
-		Matcher matcher2 = p2.matcher(info);
-		List<BigDecimal> list = new ArrayList<BigDecimal>();
-		if (matcher.matches()) {
-			String[] sts = info.split("鍏冨噺");
-			list.add(new BigDecimal(sts[0].replace("婊�", "").trim()));
-			list.add(new BigDecimal(sts[1].replace("鍏�", "").trim()));
-		} else if (matcher2.matches()) {
-			String[] split = info.split("鍏冩棤鏉′欢鍒�");
-			list.add(new BigDecimal(0));
-			list.add(new BigDecimal(split[0]));
-		} else {
-			list.add(new BigDecimal(0));
-			list.add(new BigDecimal(0));
-		}
-		return list;
-	}
-
-	/**
-	 * 鑾峰彇棰嗗埜閾炬帴
-	 * 
-	 * @return
-	 */
-	public static String getCoupleUrl(String activityId, String pid, String auctionId) {
-		if (!StringUtil.isNullOrEmpty(pid))
-			return String.format("https://uland.taobao.com/coupon/edetail?activityId=%s&pid=%s&itemId=%s", activityId,
-					pid, auctionId);
-		else
-			return String.format("https://uland.taobao.com/coupon/edetail?activityId=%s&itemId=%s", activityId,
-					auctionId);
-	}
-
-}
+package com.yeshi.fanli.util.taobao;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import jxl.Sheet;
+import jxl.Workbook;
+import jxl.read.biff.BiffException;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.params.HttpClientParams;
+
+import com.yeshi.fanli.entity.taobao.TaoBaoCoupon;
+import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
+import org.yeshi.utils.MoneyBigDecimalUtil;
+import com.yeshi.fanli.util.StringUtil;
+
+public class TaoBaoCouponUtil {
+
+	private final static String CAT = "澶╃尗";
+	private final static String TAOBAO = "娣樺疂";
+
+	public static Set<TaoBaoCoupon> getTaoBaoCouponList(TaoBaoUnionConfig config) {
+		String cookie = TaoBaoOrderUtil.getTaoBaoCookie(config.getAccount());
+		if (com.yeshi.fanli.util.StringUtil.isNullOrEmpty(cookie)) {
+			return null;
+		}
+		HttpClient client = new HttpClient();
+
+		String siteId = config.getDefaultPid().split("_")[2];
+		String adzoneId = config.getDefaultPid().split("_")[3];
+
+		String url = "http://pub.alimama.com/coupon/qq/export.json?adzoneId=" + adzoneId + "&siteId=" + siteId;
+		GetMethod method = new GetMethod(url);
+		method.setRequestHeader("Cookie", cookie);
+		method.setRequestHeader("User-Agent",
+				"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36");
+		method.setRequestHeader("Referer", "http://pub.alimama.com/myunion.htm");
+		client.setParams(new HttpClientParams());
+		InputStream inputStream = null;
+		try {
+			client.executeMethod(method);
+			if (method.getStatusCode() == 200) {
+				System.out.println(method.getResponseHeader("Content-Type").getValue());
+				if (!method.getResponseHeader("Content-Type").getValue().contains("excel")) {
+					TaoBaoOrderUtil.reportCookieInvalid(config.getAccount());
+					return null;
+				}
+
+				inputStream = method.getResponseBodyAsStream();
+				return parseTaoBaoCoupon(inputStream);
+			}
+		} catch (HttpException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} finally {
+			if (inputStream != null) {
+				try {
+					inputStream.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+		return null;
+	}
+
+	private static Set<TaoBaoCoupon> parseTaoBaoCoupon(InputStream inputStream) {
+		jxl.Workbook rwb = null;
+		try {
+			rwb = Workbook.getWorkbook(inputStream);
+		} catch (BiffException e) {
+			return null;
+		} catch (IOException e) {
+			return null;
+		}
+		Sheet sheet = rwb.getSheet(0);
+		Set<TaoBaoCoupon> set = new HashSet<TaoBaoCoupon>();
+		TaoBaoCoupon taoBaoCoupon = null;
+		int rows = sheet.getRows();
+		for (int r = 1; r < rows; r++) {
+			taoBaoCoupon = new TaoBaoCoupon();
+			taoBaoCoupon.setAuctionId(sheet.getCell(0, r).getContents().trim());
+			taoBaoCoupon.setTitle(sheet.getCell(1, r).getContents().trim());
+			taoBaoCoupon.setPictUrl(sheet.getCell(2, r).getContents().trim());
+			taoBaoCoupon.setAuctionUrl(sheet.getCell(3, r).getContents().trim());
+			taoBaoCoupon.setClassNames(sheet.getCell(4, r).getContents().trim());
+			// taoBaoCoupon.setTaobaokeUrl(sheet.getCell(5,
+			// r).getContents().trim());
+			String zkStr = sheet.getCell(6, r).getContents().trim();
+			String bizStr = sheet.getCell(7, r).getContents().trim();
+			taoBaoCoupon.setShopWangWang(sheet.getCell(10, r).getContents().trim());
+			taoBaoCoupon.setShopTitle(sheet.getCell(12, r).getContents().trim());
+			String typeStr = sheet.getCell(13, r).getContents().trim();
+			int type = 0;
+			if (TAOBAO.equals(typeStr)) {
+				type = 1;
+			} else if (CAT.equals(typeStr)) {
+				type = 2;
+			}
+			taoBaoCoupon.setShopType(type);
+			taoBaoCoupon.setCouponId(sheet.getCell(14, r).getContents().trim());
+
+			String info = sheet.getCell(17, r).getContents().trim();
+			List<BigDecimal> arr = getCouponInfo(info);
+			taoBaoCoupon.setCouponinfo(info);
+			taoBaoCoupon.setCouponStartFee(arr.get(0));
+			taoBaoCoupon.setCouponAmount(arr.get(1));
+
+			taoBaoCoupon.setCouponBegin(sheet.getCell(18, r).getContents().trim());
+			taoBaoCoupon.setCouponEnd(sheet.getCell(19, r).getContents().trim());
+			taoBaoCoupon.setCouponLink(sheet.getCell(20, r).getContents().trim());
+			// taoBaoCoupon.setGeneralizeUrl(sheet.getCell(21,
+			// r).getContents().trim());
+			taoBaoCoupon.setCreatetime(System.currentTimeMillis());
+
+			try {
+				taoBaoCoupon.setZkPrice(new BigDecimal(zkStr));
+				taoBaoCoupon.setBiz30day(Integer.parseInt(bizStr));
+				taoBaoCoupon.setTkRate(Double.parseDouble(sheet.getCell(8, r).getContents().trim()));
+				taoBaoCoupon.setBrokerage(new BigDecimal(sheet.getCell(9, r).getContents().trim()));
+				taoBaoCoupon.setSellerId(Long.parseLong(sheet.getCell(11, r).getContents().trim()));
+				taoBaoCoupon.setCouponSum(Integer.parseInt(sheet.getCell(15, r).getContents().trim()));
+				taoBaoCoupon.setCouponCount(Integer.parseInt(sheet.getCell(16, r).getContents().trim()));
+			} catch (NumberFormatException e) {
+				e.printStackTrace();
+				continue;
+			}
+			if (MoneyBigDecimalUtil.sub(taoBaoCoupon.getZkPrice(), taoBaoCoupon.getCouponStartFee())
+					.doubleValue() >= 0) {
+				taoBaoCoupon.setQuanPrice(
+						MoneyBigDecimalUtil.sub(taoBaoCoupon.getZkPrice(), taoBaoCoupon.getCouponAmount()));
+				taoBaoCoupon.setShowType(3);
+			} else {
+				taoBaoCoupon.setQuanPrice(taoBaoCoupon.getZkPrice());
+				taoBaoCoupon.setShowType(2);
+			}
+			taoBaoCoupon.setOrderby(10000);
+			set.add(taoBaoCoupon);
+		}
+		return set;
+	}
+
+	public static List<BigDecimal> getCouponInfo(String info) {
+		Pattern p = Pattern.compile("婊\d+(\\.\\d+)?鍏冨噺\\d+(\\.\\d+)?鍏�");
+		Matcher matcher = p.matcher(info);
+		Pattern p2 = Pattern.compile("\\d+鍏冩棤鏉′欢鍒�");
+		Matcher matcher2 = p2.matcher(info);
+		List<BigDecimal> list = new ArrayList<BigDecimal>();
+		if (matcher.matches()) {
+			String[] sts = info.split("鍏冨噺");
+			list.add(new BigDecimal(sts[0].replace("婊�", "").trim()));
+			list.add(new BigDecimal(sts[1].replace("鍏�", "").trim()));
+		} else if (matcher2.matches()) {
+			String[] split = info.split("鍏冩棤鏉′欢鍒�");
+			list.add(new BigDecimal(0));
+			list.add(new BigDecimal(split[0]));
+		} else {
+			list.add(new BigDecimal(0));
+			list.add(new BigDecimal(0));
+		}
+		return list;
+	}
+
+	/**
+	 * 鑾峰彇棰嗗埜閾炬帴
+	 * 
+	 * @return
+	 */
+	public static String getCoupleUrl(String activityId, String pid, String auctionId) {
+		if (!StringUtil.isNullOrEmpty(pid))
+			return String.format("https://uland.taobao.com/coupon/edetail?activityId=%s&pid=%s&itemId=%s", activityId,
+					pid, auctionId);
+		else
+			return String.format("https://uland.taobao.com/coupon/edetail?activityId=%s&itemId=%s", activityId,
+					auctionId);
+	}
+
+}

--
Gitblit v1.8.0