From 28cf328a098334b51a3e9d2d56f983fb8c862211 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期六, 23 五月 2020 09:54:38 +0800 Subject: [PATCH] 足迹、收藏订单兼容新需求 --- fanli/src/main/java/com/yeshi/fanli/service/impl/pdd/PDDGoodsServiceImpl.java | 71 +++++++++++++++++++++++++---------- 1 files changed, 51 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 6b55190..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; @@ -43,10 +48,9 @@ cidMap.put(15L, "2478");// 鏂囧叿 cidMap.put(16L, "1451");// 杩愬姩 cidMap.put(17L, "590");// 铏氭嫙 - cidMap.put(18L, "3297");// 鍖昏嵂 + 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,12 +169,20 @@ } 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() { + return PinDuoDuoUtil.getTodaySaleGoods(); + } } -- Gitblit v1.8.0