admin
2019-05-16 4114e871bcb3dce771b6aed64a1027d0bbb95ca6
fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java
@@ -21,6 +21,7 @@
import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
@@ -34,6 +35,96 @@
 *
 */
public class DaTaoKeUtil {
   static final String[] commonEmojis = new String[] { "😀", // 笑嘻嘻
         "😁", // 笑嘻嘻的脸,含笑的眼睛
         "😃", // 开口笑脸
         "😄", // 开口笑脸和微笑的眼睛
         "😆", // 开口笑紧闭的眼睛
         "😉", // 眨眼表情
         "😊", // 面带微笑的眼睛
         "😋", // 品尝美味食物表情
         "😎", // 太阳镜笑脸
         "😍", // 面带心形眼睛
         "😘", // 飞吻表情
         "😗", // 亲吻表情
         "😙", // 含笑亲吻表情
         "😚", // 闭眼亲吻表情
         "☺", // 笑脸
         "😇", // 光环笑脸
         "😐", // 中性面
         "😏", // 傻笑
         "😮", // 张着嘴
         "😛", // 吐舌头
         "😜", // 吐舌头,眨眼眼
         "😝", // 闭眼吐舌头
         "👅", // 舌头
         "👄", // 口
         "👀", // 眼睛
         "❤", // 心
         "💓", // 跳动的心
         "💕", // 两颗心
         "💗", // 成长的心
         "💝", // 扎丝带的心形礼盒
         "💞", // 旋转心
         "💐", // 花束
         "🌸", // 樱花
         "🌹", // 玫瑰
         "🌺", // 槿
         "🌻", // 向日葵
         "🌼", // 开花
         "🌷", // 郁金香
         "🍇", // 葡萄
         "🍈", // 瓜
         "🍉", // 西瓜
         "🍊", // 柑橘
         "🍋", // 柠檬
         "🍌", // 香蕉
         "🍍", // 菠萝
         "🍎", // 红苹果
         "🍏", // 青苹果
         "🍐", // 梨
         "🍑", // 桃子
         "🍒", // 樱桃
         "🍓", // 草莓
         "🌿", // 枝叶
         "🍀", // 四叶草
         "🍁", // 枫叶
         "🍂", // 落叶
         "🍃", // 叶子在风中飘落
         "☘", // 三叶草(酢浆草)
         "☀", // 太阳光芒四射
         "🌞", // 太阳人脸
         "⭐", // 星星,五角星
         "🌟",// 发光的星星
   };
   static final String[] timeEmojis = new String[] {
         "🕛",// 十二点
         "🕧",// 十二点半
         "🕐",// 一点钟
         "🕜",// 一点半
         "🕑",// 两点
         "🕝",// 两点半
         "🕒",// 三点钟
         "🕞",// 三点半
         "🕓",// 四点钟
         "🕟",// 四点半
         "🕔",// 五时
         "🕠",// 五点半
         "🕕",// 六点
         "🕡",// 六点半
         "🕖",// 七点
         "🕢",// 七点半
         "🕗",// 八点
         "🕣",// 八点半
         "🕘",// 九点钟
         "🕤",// 九点半
         "🕙",// 的十点
         "🕥",// 十点半
         "🕚",// 十一点
         "🕦",// 十一点半
   };
   public static List<GoodsClass> goodsClasses;
   static {
@@ -365,6 +456,8 @@
   }
   private static List<DaTaoKeDetail> parseCurrent(String url) {
      List<DaTaoKeDetail> list=new ArrayList<>();
      try {
         Document doc = Jsoup.connect(url)
               .userAgent(
@@ -378,6 +471,10 @@
                  .getElementsByTag("b").get(0).text();
            System.out.println(id + "-" + currentSale);
            DaTaoKeDetail detail=new DaTaoKeDetail();
            detail.setId(id);
            detail.setSalesNum(Integer.parseInt(currentSale));
            list.add(detail);
         }
@@ -386,7 +483,7 @@
      }
      // TODO 需要返回值
      return null;
      return list;
   }
   // 获取实时榜单
@@ -396,7 +493,7 @@
    * @param cid
    * @return
    */
   public static List<DaTaoKeDetail> getCurrentSalesRank(Long cid) {
   public static List<DaTaoKeDetail> getCurrentSalesRank(Integer cid) {
      String url = null;
      if (cid == null)
         url = "http://www.dataoke.com/top_sell";
@@ -411,7 +508,7 @@
    * @param cid
    * @return
    */
   public static List<DaTaoKeDetail> getCurrentDaySalesRank(Long cid) {
   public static List<DaTaoKeDetail> getCurrentDaySalesRank(Integer cid) {
      String url = null;
      if (cid == null)
         url = "http://www.dataoke.com/top_all";
@@ -431,4 +528,31 @@
      return parseCurrent(url);
   }
   public static String getDesc(DaTaoKeDetail detail) {
      // 标题+券后价+包邮+描述
      String desc = "😛" + detail.getdTitle() + "😛";
      desc += "\n";
      desc += "😛" + String.format("券后💰【%s元】包邮秒杀 ", MoneyBigDecimalUtil.getWithNoZera(detail.getPrice()).toString())
            + "😛";
      desc += "\n";
      desc += detail.getIntroduce();
      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;
   }
}