yujian
2019-07-19 8222e8b237c5dfb0affcdc03335bfadc06403bf8
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
@@ -705,6 +705,8 @@
      tg.setReservePrice(tb.getReservePrice());
      tg.setUserType(tb.getUserType());
      tg.setShopTitle(tb.getShopTitle());
      tg.setTkRate(tb.getTkRate());
      tg.setSellerId(tb.getSellerId());
      tg.setState(tb.getState()); // 状态:2018-12-03
      if (tb.getCouponAmount().compareTo(BigDecimal.valueOf(0)) > 0) {
@@ -767,12 +769,13 @@
      tg.setSalesType(1);
      // 测试使用
      // tg.setSalesType(Math.random() > 0.5 ? tg.getSalesType() : 3);
      if (Constant.IS_TEST) {
         List<ClientTextStyleVO> labels = new ArrayList<>();
         labels.add(new ClientTextStyleVO("标签内容", "#F14242"));
         labels.add(new ClientTextStyleVO("标签内容", "#00FF00"));
         tg.setLabels(labels);
      }
      // if(Constant.IS_TEST)
      // {
      // List<ClientTextStyleVO> labels = new ArrayList<>();
      // labels.add(new ClientTextStyleVO("标签内容", "#F14242"));
      // labels.add(new ClientTextStyleVO("标签内容", "#00FF00"));
      // tg.setLabels(labels);
      // }
      return tg;
   }
@@ -1819,38 +1822,68 @@
         e.printStackTrace();
      }
      String result = HttpUtil.get(url);
      JSONObject resultJson = JSONObject.fromObject(result);
      JSONObject dataJson = resultJson.optJSONObject("data");
      JSONObject sellerJson = dataJson.optJSONObject("seller");
      TaoBaoShop shop = new TaoBaoShop();
      shop.setGoodRatePercentage(new BigDecimal(sellerJson.optString("goodRatePercentage").replace("%", "")));
      shop.setId(sellerJson.optLong("userId"));
      JSONArray array = sellerJson.optJSONArray("evaluates");
      for (int i = 0; i < array.size(); i++) {
         JSONObject item = array.optJSONObject(i);
         if ("宝贝描述".equalsIgnoreCase(item.optString("title").trim())) {
            shop.setScoreGoods(new BigDecimal(item.optString("score").trim()));
            shop.setScoreGoodsD(new BigDecimal(item.optString("level").trim()));
         } else if ("卖家服务".equalsIgnoreCase(item.optString("title").trim())) {
            shop.setScoreSeller(new BigDecimal(item.optString("score").trim()));
            shop.setScoreSellerD(new BigDecimal(item.optString("level").trim()));
         } else if ("物流服务".equalsIgnoreCase(item.optString("title").trim())) {
            shop.setScoreLogistics(new BigDecimal(item.optString("score").trim()));
            shop.setScoreLogisticsD(new BigDecimal(item.optString("level").trim()));
      try {
         JSONObject resultJson = JSONObject.fromObject(result);
         JSONObject dataJson = resultJson.optJSONObject("data");
         JSONObject sellerJson = dataJson.optJSONObject("seller");
         shop.setGoodRatePercentage(new BigDecimal(sellerJson.optString("goodRatePercentage").replace("%", "")));
         LogHelper.test("卖家信息:" + result);
         shop.setId(sellerJson.optLong("userId"));
         JSONArray array = sellerJson.optJSONArray("evaluates");
         for (int i = 0; i < array.size(); i++) {
            JSONObject item = array.optJSONObject(i);
            if ("宝贝描述".equalsIgnoreCase(item.optString("title").trim())) {
               shop.setScoreGoods(new BigDecimal(item.optString("score").trim()));
               shop.setScoreGoodsD(new BigDecimal(item.optString("level").trim()));
            } else if ("卖家服务".equalsIgnoreCase(item.optString("title").trim())) {
               shop.setScoreSeller(new BigDecimal(item.optString("score").trim()));
               shop.setScoreSellerD(new BigDecimal(item.optString("level").trim()));
            } else if ("物流服务".equalsIgnoreCase(item.optString("title").trim())) {
               shop.setScoreLogistics(new BigDecimal(item.optString("score").trim()));
               shop.setScoreLogisticsD(new BigDecimal(item.optString("level").trim()));
            }
         }
         shop.setSellerNick(sellerJson.optString("sellerNick"));
         shop.setShopIcon("https:" + sellerJson.optString("shopIcon"));
         shop.setShopId(sellerJson.optLong("shopId"));
         shop.setShopName(sellerJson.optString("shopName"));
         if ("B".equalsIgnoreCase(sellerJson.optString("sellerType")))
            shop.setUserType(1);
         else
            shop.setUserType(0);
         shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
      } catch (Exception e) {
         // if (1 > 0)
         // return null;
         try {
            TaoBaoGoodsBrief goods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
            shop.setId(goods.getSellerId());
            shop.setShopName(goods.getShopTitle());
            shop.setUserType(goods.getUserType());
         } catch (Exception e1) {
            shop.setId(1L);
            shop.setShopName("");
            shop.setUserType(0);
         }
         shop.setGoodRatePercentage(new BigDecimal(100));
         shop.setScoreGoods(new BigDecimal("4.9"));
         shop.setScoreGoodsD(new BigDecimal("0"));
         shop.setScoreSeller(new BigDecimal("4.9"));
         shop.setScoreSellerD(new BigDecimal("0"));
         shop.setScoreLogistics(new BigDecimal("4.9"));
         shop.setScoreLogisticsD(new BigDecimal("0"));
         shop.setSellerNick("");
         shop.setShopIcon("https:");
         shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
      }
      shop.setSellerNick(sellerJson.optString("sellerNick"));
      shop.setShopIcon("https:" + sellerJson.optString("shopIcon"));
      shop.setShopId(sellerJson.optLong("shopId"));
      shop.setShopName(sellerJson.optString("shopName"));
      if ("B".equalsIgnoreCase(sellerJson.optString("sellerType")))
         shop.setUserType(1);
      else
         shop.setUserType(0);
      shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
      return shop;
   }