yujian
2019-05-21 a520bc5faff1d6ee9a1d2da62da461700997f418
fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java
@@ -99,30 +99,29 @@
         "🌟",// 发光的星星
   };
   static final String[] timeEmojis = new String[] {
         "🕛",// 十二点
         "🕧",// 十二点半
         "🕐",// 一点钟
         "🕜",// 一点半
         "🕑",// 两点
         "🕝",// 两点半
         "🕒",// 三点钟
         "🕞",// 三点半
         "🕓",// 四点钟
         "🕟",// 四点半
         "🕔",// 五时
         "🕠",// 五点半
         "🕕",// 六点
         "🕡",// 六点半
         "🕖",// 七点
         "🕢",// 七点半
         "🕗",// 八点
         "🕣",// 八点半
         "🕘",// 九点钟
         "🕤",// 九点半
         "🕙",// 的十点
         "🕥",// 十点半
         "🕚",// 十一点
   static final String[] timeEmojis = new String[] { "🕛", // 十二点
         "🕧", // 十二点半
         "🕐", // 一点钟
         "🕜", // 一点半
         "🕑", // 两点
         "🕝", // 两点半
         "🕒", // 三点钟
         "🕞", // 三点半
         "🕓", // 四点钟
         "🕟", // 四点半
         "🕔", // 五时
         "🕠", // 五点半
         "🕕", // 六点
         "🕡", // 六点半
         "🕖", // 七点
         "🕢", // 七点半
         "🕗", // 八点
         "🕣", // 八点半
         "🕘", // 九点钟
         "🕤", // 九点半
         "🕙", // 的十点
         "🕥", // 十点半
         "🕚", // 十一点
         "🕦",// 十一点半
   };
@@ -456,8 +455,8 @@
   }
   private static List<DaTaoKeDetail> parseCurrent(String url) {
      List<DaTaoKeDetail> list=new ArrayList<>();
      List<DaTaoKeDetail> list = new ArrayList<>();
      try {
         Document doc = Jsoup.connect(url)
               .userAgent(
@@ -471,7 +470,7 @@
                  .getElementsByTag("b").get(0).text();
            System.out.println(id + "-" + currentSale);
            DaTaoKeDetail detail=new DaTaoKeDetail();
            DaTaoKeDetail detail = new DaTaoKeDetail();
            detail.setId(id);
            detail.setSalesNum(Integer.parseInt(currentSale));
            list.add(detail);
@@ -528,16 +527,47 @@
      return parseCurrent(url);
   }
   private static String getRandomCommonEmoji() {
      return commonEmojis[(int) (Math.random() * commonEmojis.length)];
   }
   public static String getDesc(DaTaoKeDetail detail) {
      // 标题+券后价+包邮+描述
      String desc = "😛" + detail.getdTitle() + "😛";
      String desc = detail.getdTitle();
      desc += "\n";
      desc += "😛" + String.format("券后💰【%s元】包邮秒杀 ", MoneyBigDecimalUtil.getWithNoZera(detail.getPrice()).toString())
            + "😛";
      desc += String.format("券后价%s【%s元】包邮秒杀 ",Math.random()>0.5?"💰":"", MoneyBigDecimalUtil.getWithNoZera(detail.getPrice()).toString())
            + (Math.random()>0.5?getRandomCommonEmoji():"");
      desc += "\n";
      desc += detail.getIntroduce();
//      desc += detail.getIntroduce();
      String introduce = detail.getIntroduce().replace(",", ",").replace("。", ",").replace("!", ",")
            .replace(",", ",");
      introduce=introduce.replace(",,,", ",").replace(",,", ",");
      String[] sts = introduce.split(",");
      introduce = "";
      for (int i = 0; i < sts.length; i++) {
         if (i % 2 == 1) {// 需要换行
            introduce += sts[i] + (Math.random()>0.5?getRandomCommonEmoji():i==sts.length-1?"":",") + "\n";
         } else
            introduce += sts[i] + (Math.random()>0.5?getRandomCommonEmoji():i==sts.length-1?"":",");
      }
      desc+=introduce;
      return desc;
   }
   public static TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods, DaTaoKeDetail detail) {
      if (detail != null) {
         // 重新设置标题与券价格
         goods.setTitle(detail.getdTitle());
         goods.setCouponAmount(detail.getQuanPrice());
         if (new BigDecimal(detail.getQuanCondition()).compareTo(new BigDecimal(0)) > 0)
            goods.setCouponInfo(String.format("满%s元减%s元", detail.getQuanCondition(),
                  MoneyBigDecimalUtil.getWithNoZera(detail.getQuanPrice()).toString()));
         else
            goods.setCouponInfo(String.format("%s元无条件券", detail.getQuanPrice()));
      }
      return goods;
   }
}