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/service/impl/pdd/PDDGoodsServiceImpl.java |  393 +++++++++++++++++++++++++++++--------------------------
 1 files changed, 205 insertions(+), 188 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/pdd/PDDGoodsServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/pdd/PDDGoodsServiceImpl.java
index fc54e7b..ef92912 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/pdd/PDDGoodsServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/pdd/PDDGoodsServiceImpl.java
@@ -1,188 +1,205 @@
-package com.yeshi.fanli.service.impl.pdd;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.select.Elements;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
-import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
-import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
-import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
-import com.yeshi.fanli.exception.pdd.PDDOrderException;
-import com.yeshi.fanli.service.inter.pdd.PDDGoodsService;
-import com.yeshi.fanli.util.Constant;
-import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
-import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
-
-@Service
-public class PDDGoodsServiceImpl implements PDDGoodsService {
-
-	private static final Map<Long, String> cidMap = new HashMap<Long, String>();
-
-	static {
-		cidMap.put(1L, "0");// 绮鹃��
-		cidMap.put(2L, "-11");// 娓呬粨
-		cidMap.put(3L, "15");// 鐧捐揣
-		cidMap.put(4L, "4");// 姣嶅┐
-		cidMap.put(5L, "1");// 椋熷搧
-		cidMap.put(6L, "14");// 濂宠
-		cidMap.put(7L, "18");// 鐢靛櫒
-		cidMap.put(8L, "1281");// 闉嬪寘
-		cidMap.put(9L, "1282");// 鍐呰。
-		cidMap.put(10L, "16");// 缇庡
-		cidMap.put(11L, "743");// 鐢疯
-		cidMap.put(12L, "2048");// 姹借溅
-		cidMap.put(13L, "13");// 姘存灉
-		cidMap.put(14L, "818,1917,2974");// 瀹跺眳锛氬绾恒�佸瑁� 瀹跺叿
-		cidMap.put(15L, "2478");// 鏂囧叿
-		cidMap.put(16L, "1451");// 杩愬姩
-		cidMap.put(17L, "590");// 铏氭嫙
-		cidMap.put(18L, "3279");// 鍖昏嵂
-	}
-
-	@Cacheable(value = "pddCache", key = "'getDetailImageList'+#id")
-	@Override
-	public List<String> getDetailImageList(Long id) {
-		List<String> list = null;
-		int count = 0;
-		// 閲嶈瘯3娆�
-		while ((list == null || list.size() == 0) && count < 3) {
-			list = PinDuoDuoUtil.getDetailImages(id);
-			count++;
-		}
-		if (list == null || list.size() == 0) {
-			try {
-				Document doc = Jsoup
-						.connect("https://dk.gaoyong666.com/gylm/h5details/v1/details?classtype=1&goodsId=" + id)
-						.userAgent(
-								"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36")
-						.get();
-				Elements els = doc.getElementsByTag("img");
-				for (int i = 0; i < els.size(); i++) {
-					String src = els.get(i).attr("src");
-					if (src.contains("yangkeduo")) {
-						list.add(src);
-					}
-				}
-
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-
-		}
-
-		return list;
-	}
-
-	@Override
-	public List<GoodsClass> getSpecialClass() {
-		List<GoodsClass> list = new ArrayList<GoodsClass>();
-		list.add(new GoodsClass(1L, "绮鹃��"));
-		list.add(new GoodsClass(2L, "娓呬粨"));
-		list.add(new GoodsClass(3L, "鐧捐揣"));
-		list.add(new GoodsClass(4L, "姣嶅┐"));
-		list.add(new GoodsClass(5L, "椋熷搧"));
-		list.add(new GoodsClass(6L, "濂宠"));
-		list.add(new GoodsClass(7L, "鐢靛櫒"));
-		list.add(new GoodsClass(8L, "闉嬪寘"));
-		list.add(new GoodsClass(9L, "鍐呰。"));
-		list.add(new GoodsClass(10L, "缇庡"));
-		list.add(new GoodsClass(11L, "鐢疯"));
-		list.add(new GoodsClass(12L, "姹借溅"));
-		list.add(new GoodsClass(13L, "姘存灉"));
-		list.add(new GoodsClass(14L, "瀹跺眳"));
-		list.add(new GoodsClass(15L, "鏂囧叿"));
-		list.add(new GoodsClass(16L, "杩愬姩"));
-		list.add(new GoodsClass(17L, "铏氭嫙"));
-		list.add(new GoodsClass(18L, "鍖昏嵂"));
-		return list;
-	}
-
-	@Override
-	@Transactional(rollbackFor=Exception.class)
-	@Cacheable(value = "pddSpecialCache", key = "'specialSearch-'+#page+'-'+#cid")
-	public List<PDDGoodsDetail> specialSearch(Integer page, Long cid) throws PDDOrderException {
-		if (cid == null) {
-			throw new PDDOrderException(1, "鍒嗙被id涓虹┖");
-		}
-
-		String pddcid = cidMap.get(cid);
-		if (StringUtil.isNullOrEmpty(pddcid)) {
-			throw new PDDOrderException(1, "鍒嗙被id涓嶅瓨鍦�");
-		}
-
-		PDDSearchFilter pddfilter = new PDDSearchFilter();
-
-		// 绮鹃��
-		if (cid == 1) {
-			pddfilter.setPage(page);
-			pddfilter.setPageSize(Constant.PAGE_SIZE);
-			PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
-			if (result == null) {
-				return null;
-			} else {
-				return result.getGoodsList();
-			}
-		}
-
-		// 鍗曚釜鍒嗙被
-		if (!pddcid.contains(",")) {
-			pddfilter.setPage(page);
-			pddfilter.setPageSize(Constant.PAGE_SIZE);
-			pddfilter.setOptId(Long.parseLong(pddcid));
-			PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
-			if (result == null) {
-				return null;
-			} else {
-				return result.getGoodsList();
-			}
-		}
-
-		// 澶氫釜鍒嗙被id澶勭悊
-		List<PDDGoodsDetail> list = new ArrayList<PDDGoodsDetail>();
-		String[] arrayId = pddcid.split(",");
-		for (int i = 0; i < arrayId.length; i++) {
-			if (i >= 3) {
-				break;
-			}
-			pddfilter.setPage(page);
-			pddfilter.setPageSize(10);
-			pddfilter.setOptId(Long.parseLong(arrayId[i]));
-			PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
-			if (result != null) {
-				List<PDDGoodsDetail> listGoods = result.getGoodsList();
-				if (listGoods != null && listGoods.size() > 0) {
-					list.addAll(listGoods);
-				}
-			}
-		}
-		return list;
-	}
-
-	@Override
-	@Cacheable(value = "pddSpecialCache", key = "'getTopGoodsList-' + #page + '-' + #sortType")
-	public PDDGoodsResult getTopGoodsList(int page, Integer sortType) {
-		PDDGoodsResult pddResult = PinDuoDuoApiUtil.getTopList(PinDuoDuoApiUtil.PID_FANLI, page, Constant.PAGE_SIZE,
-				sortType);
-		if (pddResult != null && pddResult.getGoodsList() != null)
-			Collections.shuffle(pddResult.getGoodsList());
-		return pddResult;
-	}
-
-	@Override
-	@Cacheable(value = "pddSpecialCache", key = "'getTodaySaleGoodsList-'")
-	public PDDGoodsResult getTodaySaleGoodsList() {
-		return PinDuoDuoUtil.getTodaySaleGoods();
-	}
-}
+package com.yeshi.fanli.service.impl.pdd;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.yeshi.fanli.exception.pdd.PDDApiException;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.select.Elements;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
+import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
+import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
+import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
+import com.yeshi.fanli.exception.pdd.PDDOrderException;
+import com.yeshi.fanli.service.inter.pdd.PDDGoodsService;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
+import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
+
+@Service
+public class PDDGoodsServiceImpl implements PDDGoodsService {
+
+	private static final Map<Long, String> cidMap = new HashMap<Long, String>();
+
+	static {
+		cidMap.put(1L, "0");// 绮鹃��
+		cidMap.put(2L, "-11");// 娓呬粨
+		cidMap.put(3L, "15");// 鐧捐揣
+		cidMap.put(4L, "4");// 姣嶅┐
+		cidMap.put(5L, "1");// 椋熷搧
+		cidMap.put(6L, "14");// 濂宠
+		cidMap.put(7L, "18");// 鐢靛櫒
+		cidMap.put(8L, "1281");// 闉嬪寘
+		cidMap.put(9L, "1282");// 鍐呰。
+		cidMap.put(10L, "16");// 缇庡
+		cidMap.put(11L, "743");// 鐢疯
+		cidMap.put(12L, "2048");// 姹借溅
+		cidMap.put(13L, "13");// 姘存灉
+		cidMap.put(14L, "818,1917,2974");// 瀹跺眳锛氬绾恒�佸瑁� 瀹跺叿
+		cidMap.put(15L, "2478");// 鏂囧叿
+		cidMap.put(16L, "1451");// 杩愬姩
+		cidMap.put(17L, "590");// 铏氭嫙
+		cidMap.put(18L, "3279");// 鍖昏嵂
+	}
+
+	@Cacheable(value = "pddCache", key = "'getDetailImageList'+#id")
+	@Override
+	public List<String> getDetailImageList(Long id) {
+		List<String> list = null;
+		int count = 0;
+		// 閲嶈瘯3娆�
+		while ((list == null || list.size() == 0) && count < 3) {
+			list = PinDuoDuoUtil.getDetailImages(id);
+			count++;
+		}
+		if (list == null || list.size() == 0) {
+			try {
+				Document doc = Jsoup
+						.connect("https://dk.gaoyong666.com/gylm/h5details/v1/details?classtype=1&goodsId=" + id)
+						.userAgent(
+								"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36")
+						.get();
+				Elements els = doc.getElementsByTag("img");
+				for (int i = 0; i < els.size(); i++) {
+					String src = els.get(i).attr("src");
+					if (src.contains("yangkeduo")) {
+						list.add(src);
+					}
+				}
+
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+
+		}
+
+		return list;
+	}
+
+	@Override
+	public List<GoodsClass> getSpecialClass() {
+		List<GoodsClass> list = new ArrayList<GoodsClass>();
+		list.add(new GoodsClass(1L, "绮鹃��"));
+		list.add(new GoodsClass(2L, "娓呬粨"));
+		list.add(new GoodsClass(3L, "鐧捐揣"));
+		list.add(new GoodsClass(4L, "姣嶅┐"));
+		list.add(new GoodsClass(5L, "椋熷搧"));
+		list.add(new GoodsClass(6L, "濂宠"));
+		list.add(new GoodsClass(7L, "鐢靛櫒"));
+		list.add(new GoodsClass(8L, "闉嬪寘"));
+		list.add(new GoodsClass(9L, "鍐呰。"));
+		list.add(new GoodsClass(10L, "缇庡"));
+		list.add(new GoodsClass(11L, "鐢疯"));
+		list.add(new GoodsClass(12L, "姹借溅"));
+		list.add(new GoodsClass(13L, "姘存灉"));
+		list.add(new GoodsClass(14L, "瀹跺眳"));
+		list.add(new GoodsClass(15L, "鏂囧叿"));
+		list.add(new GoodsClass(16L, "杩愬姩"));
+		list.add(new GoodsClass(17L, "铏氭嫙"));
+		list.add(new GoodsClass(18L, "鍖昏嵂"));
+		return list;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@Cacheable(value = "pddSpecialCache", key = "'specialSearch-'+#page+'-'+#cid")
+	public List<PDDGoodsDetail> specialSearch(Integer page, Long cid) throws PDDOrderException {
+		if (cid == null) {
+			throw new PDDOrderException(1, "鍒嗙被id涓虹┖");
+		}
+
+		String pddcid = cidMap.get(cid);
+		if (StringUtil.isNullOrEmpty(pddcid)) {
+			throw new PDDOrderException(1, "鍒嗙被id涓嶅瓨鍦�");
+		}
+
+		PDDSearchFilter pddfilter = new PDDSearchFilter();
+
+		// 绮鹃��
+		if (cid == 1) {
+			pddfilter.setPage(page);
+			pddfilter.setPageSize(Constant.PAGE_SIZE);
+			PDDGoodsResult result = null;
+			try {
+				result = PinDuoDuoApiUtil.searchGoods(pddfilter, Constant.PDD_SEARCH_CUSTOMER_PARAMS);
+			} catch (PDDApiException e) {
+				e.printStackTrace();
+			}
+			if (result == null) {
+				return null;
+			} else {
+				return result.getGoodsList();
+			}
+		}
+
+		// 鍗曚釜鍒嗙被
+		if (!pddcid.contains(",")) {
+			pddfilter.setPage(page);
+			pddfilter.setPageSize(Constant.PAGE_SIZE);
+			pddfilter.setOptId(Long.parseLong(pddcid));
+			PDDGoodsResult result = null;
+			try {
+				result = PinDuoDuoApiUtil.searchGoods(pddfilter, Constant.PDD_SEARCH_CUSTOMER_PARAMS);
+			} catch (PDDApiException e) {
+				e.printStackTrace();
+			}
+			if (result == null) {
+				return null;
+			} else {
+				return result.getGoodsList();
+			}
+		}
+
+		// 澶氫釜鍒嗙被id澶勭悊
+		List<PDDGoodsDetail> list = new ArrayList<PDDGoodsDetail>();
+		String[] arrayId = pddcid.split(",");
+		for (int i = 0; i < arrayId.length; i++) {
+			if (i >= 3) {
+				break;
+			}
+			pddfilter.setPage(page);
+			pddfilter.setPageSize(10);
+			pddfilter.setOptId(Long.parseLong(arrayId[i]));
+			PDDGoodsResult result = null;
+			try {
+				result = PinDuoDuoApiUtil.searchGoods(pddfilter, Constant.PDD_SEARCH_CUSTOMER_PARAMS);
+			} catch (PDDApiException e) {
+				e.printStackTrace();
+			}
+			if (result != null) {
+				List<PDDGoodsDetail> listGoods = result.getGoodsList();
+				if (listGoods != null && listGoods.size() > 0) {
+					list.addAll(listGoods);
+				}
+			}
+		}
+		return list;
+	}
+
+	@Override
+	@Cacheable(value = "pddSpecialCache", key = "'getTopGoodsList-' + #page + '-' + #sortType")
+	public PDDGoodsResult getTopGoodsList(int page, Integer sortType) {
+		//[4,7]锛�4-绉掓潃锛�7-鐧句嚎琛ヨ创锛�31-鍝佺墝榛戞爣锛�10564-绮鹃�夌垎鍝�-瀹樻柟鐩存帹鐖嗘锛�10584-绮鹃�夌垎鍝�-鍥㈤暱鎺ㄨ崘锛�24-鍝佺墝楂樹剑锛�20-琛屼笟绮鹃�夛紝21-閲戠墝鍟嗗锛�10044-娼滃姏鐖嗗搧锛�10475-鐖嗗搧涓婃柊
+		PDDGoodsResult pddResult = PinDuoDuoApiUtil.searchByChannelType( page, Constant.PAGE_SIZE,
+				null,new Integer[]{4,7,10564});
+		if (pddResult != null && pddResult.getGoodsList() != null)
+			Collections.shuffle(pddResult.getGoodsList());
+		return pddResult;
+	}
+
+	@Override
+	@Cacheable(value = "pddSpecialCache", key = "'getTodaySaleGoodsList-'")
+	public PDDGoodsResult getTodaySaleGoodsList() {
+		return PinDuoDuoUtil.getTodaySaleGoods();
+	}
+}

--
Gitblit v1.8.0