From 91ddd96c12ec25aaf6d0cb38d54288d863ab2b58 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 10 七月 2021 18:10:38 +0800
Subject: [PATCH] 礼金红包兼容

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java |  131 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 113 insertions(+), 18 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java
index 8f70d89..8d1a242 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java
+++ b/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);
     }
 
     /**
@@ -742,6 +774,69 @@
                 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;
     }

--
Gitblit v1.8.0