| | |
| | | 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;
|
| | |
| | | cidMap.put(17L, "590");// 虚拟
|
| | | cidMap.put(18L, "3279");// 医药
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Cacheable(value = "pddCache", key = "'getDetailImageList'+#id")
|
| | | @Override
|
| | | public List<String> getDetailImageList(Long id) {
|
| | |
| | | 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(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);
|
| | |
| | | } else {
|
| | | return result.getGoodsList();
|
| | | }
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | // 单个分类
|
| | | if (!pddcid.contains(",")) {
|
| | | pddfilter.setPage(page);
|
| | |
| | | } else {
|
| | | return result.getGoodsList();
|
| | | }
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | // 多个分类id处理
|
| | | List<PDDGoodsDetail> list = new ArrayList<PDDGoodsDetail>();
|
| | | String[] arrayId = pddcid.split(",");
|
| | |
| | | }
|
| | | 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);
|
| | | }
|
| | | |
| | |
|
| | | }
|