From 9a82179d24ec670ba1aefef6906b8acadf58da6e Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期六, 03 八月 2019 12:13:31 +0800 Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div --- fanli/src/main/java/com/yeshi/fanli/service/impl/pdd/PDDGoodsServiceImpl.java | 56 +++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 39 insertions(+), 17 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..6907d5c 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,14 @@ package com.yeshi.fanli.service.impl.pdd; +import java.io.IOException; import java.util.ArrayList; 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 +49,7 @@ cidMap.put(17L, "590");// 铏氭嫙 cidMap.put(18L, "3279");// 鍖昏嵂 } - - + @Cacheable(value = "pddCache", key = "'getDetailImageList'+#id") @Override public List<String> getDetailImageList(Long id) { @@ -57,10 +60,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 +105,24 @@ list.add(new GoodsClass(16L, "杩愬姩")); list.add(new GoodsClass(17L, "铏氭嫙")); list.add(new GoodsClass(18L, "鍖昏嵂")); - return list; + return list; } - - + @Override @Transactional @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 +133,8 @@ } else { return result.getGoodsList(); } - } - + } + // 鍗曚釜鍒嗙被 if (!pddcid.contains(",")) { pddfilter.setPage(page); @@ -124,8 +146,8 @@ } else { return result.getGoodsList(); } - } - + } + // 澶氫釜鍒嗙被id澶勭悊 List<PDDGoodsDetail> list = new ArrayList<PDDGoodsDetail>(); String[] arrayId = pddcid.split(","); @@ -146,18 +168,18 @@ } 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); } + @Override @Cacheable(value = "pddSpecialCache", key = "'getTodaySaleGoodsList-'") public PDDGoodsResult getTodaySaleGoodsList() { return PinDuoDuoUtil.getTodaySaleGoods(); - } + } } -- Gitblit v1.8.0