From e7920b14a9baab97035a1a529da85d124a2bcacd Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期二, 16 六月 2020 10:54:29 +0800
Subject: [PATCH] 云发单对测试用户显示
---
fanli/src/main/java/com/yeshi/fanli/service/impl/pdd/PDDGoodsServiceImpl.java | 65 ++++++++++++++++++++++----------
1 files changed, 45 insertions(+), 20 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 609feb4..d5e29b5 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,10 +1,15 @@
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;
@@ -45,8 +50,7 @@
cidMap.put(17L, "590");// 铏氭嫙
cidMap.put(18L, "3279");// 鍖昏嵂
}
-
-
+
@Cacheable(value = "pddCache", key = "'getDetailImageList'+#id")
@Override
public List<String> getDetailImageList(Long id) {
@@ -57,10 +61,30 @@
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>();
@@ -82,25 +106,24 @@
list.add(new GoodsClass(16L, "杩愬姩"));
list.add(new GoodsClass(17L, "铏氭嫙"));
list.add(new GoodsClass(18L, "鍖昏嵂"));
- return list;
+ return list;
}
-
-
+
@Override
- @Transactional
+ @Transactional(rollbackFor = Exception.class)
@Cacheable(value = "pddSpecialCache", key = "'specialSearch-'+#page+'-'+#cid")
- public List<PDDGoodsDetail> specialSearch(Integer page, Long cid) throws PDDOrderException{
+ 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);
@@ -111,8 +134,8 @@
} else {
return result.getGoodsList();
}
- }
-
+ }
+
// 鍗曚釜鍒嗙被
if (!pddcid.contains(",")) {
pddfilter.setPage(page);
@@ -124,8 +147,8 @@
} else {
return result.getGoodsList();
}
- }
-
+ }
+
// 澶氫釜鍒嗙被id澶勭悊
List<PDDGoodsDetail> list = new ArrayList<PDDGoodsDetail>();
String[] arrayId = pddcid.split(",");
@@ -146,15 +169,17 @@
}
return list;
}
-
-
+
@Override
@Cacheable(value = "pddSpecialCache", key = "'getTopGoodsList-' + #page + '-' + #sortType")
public PDDGoodsResult getTopGoodsList(int page, Integer sortType) {
- return PinDuoDuoApiUtil.getTopList(PinDuoDuoApiUtil.PID_FANLI, page, Constant.PAGE_SIZE, 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() {
--
Gitblit v1.8.0