admin
2025-02-25 30d8e227e8d823b6c38c3b9c90ac2df03b63befe
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java
@@ -11,7 +11,15 @@
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.SystemFunction;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.util.SystemInfoUtil;
import com.yeshi.fanli.util.factory.CommonGoodsFactory;
import com.yeshi.goods.facade.dto.taobao.haodanku.HaoDanKuJDGoodsInfo;
import com.yeshi.goods.facade.dto.taobao.haodanku.HaoDanKuListResult;
import com.yeshi.goods.facade.dto.taobao.haodanku.HaoDanKuPDDGoodsInfo;
import com.yeshi.goods.facade.entity.taobao.haodanku.HDKGoodsDetail;
import com.yeshi.goods.facade.utils.taobao.HaoDanKuApiUtil;
import com.yeshi.goods.facade.utils.taobao.HaoDankuUtil;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@@ -88,7 +96,7 @@
    }
    @Override
    public List<CommonContentNav> getNavList(CommonContentTypeEnum type,SystemEnum system) {
    public List<CommonContentNav> getNavList(CommonContentTypeEnum type, SystemEnum system) {
        List<CommonContentNav> navList = new ArrayList<>();
        if (type == CommonContentTypeEnum._9k9) {
            navList.add(new CommonContentNav("-1", "综合"));
@@ -141,6 +149,24 @@
            navList = getCommonNav(system);
        } else if (type == CommonContentTypeEnum.mianDan) {
            navList = new ArrayList<>();
        } else if (type == CommonContentTypeEnum.pddHotGoodsRank) {
            //好单库数据
            navList.add(new CommonContentNav("0", "全部"));
            for (HaoDankuUtil.Category category : HaoDankuUtil.CATEGORYS) {
                navList.add(new CommonContentNav(category.getId() + "", category.getName()));
            }
        } else if (type == CommonContentTypeEnum.jdHotGoodsRank) {
            //好单库数据
            navList.add(new CommonContentNav("0", "全部"));
            for (HaoDankuUtil.Category category : HaoDankuUtil.CATEGORYS) {
                navList.add(new CommonContentNav(category.getId() + "", category.getName()));
            }
        } else if (type == CommonContentTypeEnum.tbHotGoodsRank) {
            //好单库数据
            navList.add(new CommonContentNav("0", "全部"));
            for (HaoDankuUtil.Category category : HaoDankuUtil.CATEGORYS) {
                navList.add(new CommonContentNav(category.getId() + "", category.getName()));
            }
        }
        return navList;
@@ -180,11 +206,17 @@
            result = getHaoQuanContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.mianDan) {
            result = getMianDanContent(page, pageSize);
        } else if (type == CommonContentTypeEnum.pddHotGoodsRank) {
            result = getPDDHotGoodsRankContent(cid, page);
        } else if (type == CommonContentTypeEnum.jdHotGoodsRank) {
            result = getJDHotGoodsRankContent(cid, page);
        } else if (type == CommonContentTypeEnum.tbHotGoodsRank) {
            result = getTBHotGoodsRankContent(cid, page);
        }
        if (result != null) {// 商品信息过滤
            List<TaoBaoGoodsBrief> goodsList = taoBaoGoodsUpdateService
                    .filterImportantTaoBaoGoods(result.getGoodsList());
            List<CommonGoods> goodsList = taoBaoGoodsUpdateService
                    .filterImportantTaoBaoGoodsWithCommonGoods(result.getGoodsList());
            result.setGoodsList(goodsList);
        }
@@ -247,7 +279,7 @@
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
    }
    /**
@@ -308,7 +340,7 @@
                }
                goodsList.add(taoBaoGoodsBrief);
            }
        return new CommonContentResult(goodsList, count);
        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
    }
    /**
@@ -374,7 +406,7 @@
            }
            goodsList.add(taoBaoGoodsBrief);
        }
        return new CommonContentResult(goodsList, count);
        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
    }
    /**
@@ -399,7 +431,7 @@
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
    }
    /**
@@ -424,7 +456,7 @@
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
    }
    /**
@@ -448,7 +480,7 @@
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
    }
    /**
@@ -475,7 +507,7 @@
                    for (DaTaoKeDetailV2 detail : result.getGoodsList())
                        goodsList.add(TaoBaoUtil.convert(detail));
            }
            return new CommonContentResult(goodsList, count);
            return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
        } else {//
            List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache("母婴_" + cid,
@@ -494,7 +526,7 @@
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return new CommonContentResult(listBrands, 1000);
                return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(listBrands), 1000);
            }
            return new CommonContentResult(new ArrayList<>(), 0);
        }
@@ -524,7 +556,7 @@
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
    }
    /**
@@ -549,7 +581,7 @@
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
    }
    /**
@@ -578,7 +610,7 @@
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
    }
    /**
@@ -602,7 +634,7 @@
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
    }
    /**
@@ -630,7 +662,7 @@
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
    }
    /**
@@ -658,7 +690,7 @@
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
    }
    /**
@@ -689,7 +721,7 @@
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
    }
    /**
@@ -702,7 +734,7 @@
        List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
        long count = qualityGoodsService.countFreeGoods();
        result.setCount(count);
        List<Long> listGid = new ArrayList<Long>();
        List<String> listGid = new ArrayList<>();
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        for (QualityFactory qualityFactory : listQuery) {
            TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
@@ -723,7 +755,7 @@
        } catch (Exception e) {
            e.printStackTrace();
        }
        Map<Long, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
        Map<String, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
        if (listTaoKeGoods != null)
            for (TaoBaoGoodsBrief goods : listTaoKeGoods)
                goodsMap.put(goods.getAuctionId(), goods);
@@ -737,11 +769,74 @@
        for (int i = 0; i < goodsList.size(); i++) {
            TaoBaoGoodsBrief goods = goodsList.get(i);
            BigDecimal price = TaoBaoUtil.getAfterUseCouplePrice(goods);
            BigDecimal price = TaoBaoUtil.getCouponPrice(goods);
            if (price.compareTo(new BigDecimal(10)) >= 0) {
                goodsList.remove(i--);
            }
        }
        result.setGoodsList(CommonGoodsFactory.createTaoBaoList(goodsList));
        return result;
    }
    /**
     * 拼多多热销
     *
     * @return
     */
    private CommonContentResult getPDDHotGoodsRankContent(String cid, int page) {
        cid = cid == null ? 0 + "" : cid;
        CommonContentResult result = new CommonContentResult();
        HaoDanKuListResult pddResult = HaoDanKuApiUtil.getInstance().getPDDHotGoods(Integer.parseInt(cid), page == 1 ? null : page); //qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
        result.setCount(1000);
        List<CommonGoods> goodsList = new ArrayList<>();
        if (pddResult != null) {
            List<HaoDanKuPDDGoodsInfo> list = pddResult.getResultList();
            for (HaoDanKuPDDGoodsInfo goodsInfo : list) {
                goodsList.add(CommonGoodsFactory.create(goodsInfo));
            }
        }
        result.setGoodsList(goodsList);
        return result;
    }
    /**
     * 京东热销
     *
     * @return
     */
    private CommonContentResult getJDHotGoodsRankContent(String cid, int page) {
        CommonContentResult result = new CommonContentResult();
        HaoDanKuListResult pddResult = HaoDanKuApiUtil.getInstance().getJDHotGoods(Integer.parseInt(cid), page == 1 ? null : page); //qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
        result.setCount(1000);
        List<CommonGoods> goodsList = new ArrayList<>();
        if (pddResult != null) {
            List<HaoDanKuJDGoodsInfo> list = pddResult.getResultList();
            for (HaoDanKuJDGoodsInfo goodsInfo : list) {
                goodsList.add(CommonGoodsFactory.create(goodsInfo));
            }
        }
        result.setGoodsList(goodsList);
        return result;
    }
    /**
     * 淘宝热销
     *
     * @return
     */
    private CommonContentResult getTBHotGoodsRankContent(String cid, int page) {
        CommonContentResult result = new CommonContentResult();
        HaoDanKuListResult pddResult = HaoDanKuApiUtil.getInstance().getTBHotGoods(Integer.parseInt(cid), page == 1 ? null : page); //qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
        result.setCount(1000);
        List<CommonGoods> goodsList = new ArrayList<>();
        if (pddResult != null) {
            List<HDKGoodsDetail> list = pddResult.getResultList();
            for (HDKGoodsDetail goodsInfo : list) {
                goodsList.add(CommonGoodsFactory.create(goodsInfo));
            }
        }
        result.setGoodsList(goodsList);
        return result;
    }