yujian
2019-01-04 38fffe4319f408b5dc1da23d30512e90b0f4feac
fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java
@@ -161,8 +161,6 @@
   @Resource
   private SystemConfigService systemConfigService;
   @Resource
   private CollectionGoodsV2Service collectionGoodsV2Service;
@@ -306,7 +304,7 @@
   @RequestMapping(value = "getHonestList")
   public void getHonestList(AcceptData acceptData, PrintWriter out) {
      System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
      List<Honest> honestList =null;
      List<Honest> honestList = null;
      List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
      if ((Integer.parseInt(acceptData.getVersion()) >= 20 && "android".equalsIgnoreCase(acceptData.getPlatform()))
            || ("ios".equalsIgnoreCase(acceptData.getPlatform())
@@ -704,8 +702,18 @@
         data.put("tbPidInfo", clientTBPid);
         JSONObject taobaoJson = JSONObject.fromObject(gson.toJson(taoBaoGoodsBriefExtra));
         if (taoBaoGoodsBriefExtra.getImgList() != null)
            taoBaoGoodsBriefExtra.getImgList().add(0, taoBaoGoodsBriefExtra.getPictUrl());
         taobaoJson.put("imgList", taoBaoGoodsBriefExtra.getImgList());
         taobaoJson.put("saleCount", taoBaoGoodsBriefExtra.getSalesCount());// 销量(和salesCount一致,此处处理兼容)
         if (taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null)
            taobaoJson.put("coupon", true);
         else
            taobaoJson.put("coupon", false);
         // taoBaoGoodsBriefExtra.setAuctionUrl(null);
         data.put("taobao", gson.toJson(taoBaoGoodsBriefExtra));
         data.put("taobao", taobaoJson);
         String info = configService.get("detail_prompt");
         data.put("info", info);
         String onlyInfo = configService.get("only_info");
@@ -1355,16 +1363,18 @@
      /**
       * 防止请求频率过高
       *
       */
      String key = "linkParse-" + acceptData.getDevice() + "-" + id;
      if (Constant.IS_OUTNET) {
         String key = "linkParse-" + acceptData.getDevice() + "-" + id;
      String value = redisManager.getCommonString(key);
      if (!StringUtil.isNullOrEmpty(value)) {
         out.print(JsonUtil.loadFalseResult(11, "请求频率限制"));
         return;
         String value = redisManager.getCommonString(key);
         if (!StringUtil.isNullOrEmpty(value)) {
            out.print(JsonUtil.loadFalseResult(11, "请求频率限制"));
            return;
         }
         redisManager.cacheCommonString(key, "1", 5);// 5s间隔
      }
      redisManager.cacheCommonString(key, "1", 5);// 5s间隔
      TaoBaoGoodsBrief goods = null;
      try {
         goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(id));
@@ -1796,7 +1806,7 @@
                  // 商品下架
                  ThreadUtil.run(new Runnable() {
                     public void run() {
                        taoBaoGoodsUpdateService.deleteTaoBaoGoods(Long.parseLong(id));
                        taoBaoGoodsUpdateService.offlineTaoBaoGoods(Long.parseLong(id));
                     }
                  });
@@ -1823,7 +1833,11 @@
               } catch (NumberFormatException e) {
                  e.printStackTrace();
               } catch (TaobaoGoodsDownException e) {
                  e.printStackTrace();
                  ThreadUtil.run(new Runnable() {
                     public void run() {
                        taoBaoGoodsUpdateService.offlineTaoBaoGoods(Long.parseLong(id));
                     }
                  });
               }
            }
@@ -1864,7 +1878,7 @@
      List<String> finalImgList = new ArrayList<>();
      for (String img : tb.getImgList()) {
         finalImgList.add(img);
         finalImgList.add(TbImgUtil.getTBSizeImg(img, 600));
      }
      JSONObject goods = new JSONObject();
@@ -2072,62 +2086,9 @@
      }
      List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10);
      // 重新做推荐
      if (goodsList == null || goodsList.size() == 0) {
         goodsList = new ArrayList<>();
         TaoBaoGoodsBrief goods = null;
         try {
            goods = redisManager.getTaoBaoGoodsBrief(id);
         } catch (TaobaoGoodsDownException e) {
            e.printStackTrace();
         }
         if (goods == null) {
            // 从我们的商品库搜索
            CommonGoods cgoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(id,
                  CommonGoods.GOODS_TYPE_TB);
            // 商品有本地缓存
            if (cgoods != null) {
               // 按名字搜索商品
               SearchFilter sf = new SearchFilter();
               sf.setKey(cgoods.getTitle().substring(0, cgoods.getTitle().length() / 2));
               TaoBaoSearchResult result = TaoBaoUtil.search(sf);
               if (result != null && result.getTaoBaoGoodsBriefs() != null
                     && result.getTaoBaoGoodsBriefs().size() > 0) {
                  for (TaoBaoGoodsBrief gds : result.getTaoBaoGoodsBriefs()) {
                     if (goodsList.size() == 10) {
                        break;
                     }
                     goodsList.add(gds);
                  }
               }
            }
         }
         // 需要另做推荐
         if (goodsList.size() < 2) {
            try {
               List<RecommendSectionGoods> list = recommendSectionGoodsService.getSectionGoods(10);
               if (list != null) {
                  for (int i = 0; i < list.size(); i++) {
                     if (i == 10) {
                        break;
                     }
                     goodsList.add(list.get(i).getTaoBaoGoodsBrief());
                  }
               }
            } catch (Exception e2) {
               e2.printStackTrace();
            }
         }
      // 初始化
      if (goodsList == null) {
         goodsList = new ArrayList<TaoBaoGoodsBrief>();
      }
      BigDecimal proportion = manageService.getFanLiRate();