yujian
2019-10-29 9b55262bb45c81c997ab04e55e8de13e14b8ca7d
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
@@ -72,6 +72,7 @@
import com.yeshi.fanli.util.TaoBaoConstant;
import com.yeshi.fanli.util.TaoBaoHttpUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@@ -782,7 +783,41 @@
      // labels.add(new ClientTextStyleVO("标签内容", "#00FF00"));
      // tg.setLabels(labels);
      // }
      return tg;
      return loadYuShouInfo(tg, tb);
   }
   private static TaoBaoGoodsBriefExtra loadYuShouInfo(TaoBaoGoodsBriefExtra extra, TaoBaoGoodsBrief goods) {
      if (goods != null && extra != null) {
         if (isYUShou(goods)) {// 预售商品
//            extra.setZkPrice(new BigDecimal(goods.getPresaleDeposit()));
            // 预售
            if (extra.getLabels() == null)
               extra.setLabels(new ArrayList<>());
            extra.getLabels().add(new ClientTextStyleVO("预售", "#FF2B4E"));
         }
      }
      return extra;
   }
   /**
    * 是否为预售商品
    *
    * @param goods
    * @return
    */
   public static boolean isYUShou(TaoBaoGoodsBrief goods) {
      if (!StringUtil.isNullOrEmpty(goods.getPresaleDeposit())
            && !StringUtil.isNullOrEmpty(goods.getPresaleStartTime())
            && !StringUtil.isNullOrEmpty(goods.getPresaleEndTime())) {
         long startTime = Long.parseLong(goods.getPresaleStartTime());
         long endTime = Long.parseLong(goods.getPresaleEndTime());
         long now = System.currentTimeMillis();
         if (now >= startTime && now < endTime) {
            return true;
         }
      }
      return false;
   }
   /**
@@ -1371,7 +1406,7 @@
         return null;
      }
   }
   /**
    * 获取商品的用户分成比例
    * 
@@ -1398,7 +1433,6 @@
    */
   public static BigDecimal getGoodsHongBaoMoney(TaoBaoGoodsBrief goodsBrief, BigDecimal rate) {
      BigDecimal money = null;
      if (StringUtil.isNullOrEmpty(goodsBrief.getCouponInfo())
            || goodsBrief.getCouponInfo().trim().equalsIgnoreCase("无")) {
         money = MoneyBigDecimalUtil.mul(
@@ -1977,7 +2011,7 @@
               if (content.contains("var _DATA_Mdskip")) {
                  content = content.replace("<script>", "");
                  content = content.replace("</script>", "");
                  if (content.contains("videoDetail")) {
                     content += ";function getData(){ var json={title:_DATA_Mdskip.item.title,pictUrl:_DATA_Mdskip.item.videoDetail.videoThumbnailURL};   return JSON.stringify(json);}";
                  } else {
@@ -2007,22 +2041,24 @@
      }
      return taoBaoGoodsBrief;
   }
   /**
    * 抖音返利local 获取真实淘宝链接
    * @param url https://s.click.taobao.com/t?e=m%3D2%26s%3DT9DFpHQCT7Rw4vFB6t2Z2ueEDrYVVa64XoO8tOebS+dRAdhuF14FMR8
    *
    * @param url
    *            https://s.click.taobao.com/t?e=m%3D2%26s%
    *            3DT9DFpHQCT7Rw4vFB6t2Z2ueEDrYVVa64XoO8tOebS+dRAdhuF14FMR8
    * @return
    */
   public static String getRealUrl(String url) {
      if (StringUtil.isNullOrEmpty(url))
         return null;
      try {
         HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager());
         client.getHttpConnectionManager().getParams().setConnectionTimeout(10000);
         client.getParams().setParameter(HttpMethodParams.USER_AGENT,"Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)"); // 让服务器认为是IE
         client.getParams().setParameter(HttpMethodParams.USER_AGENT,
               "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)"); // 让服务器认为是IE
         GetMethod get = new GetMethod(url);
         get.setFollowRedirects(false); // 禁止自动重定向
         int iGetResultCode = client.executeMethod(get);
@@ -2037,7 +2073,6 @@
      }
      return null;
   }
   /**
    * 淘口令过滤
@@ -2048,10 +2083,10 @@
   public static String filterTaoToken(String token) {
      if (StringUtil.isNullOrEmpty(token))
         return token;
      if (token.contains("¥")||token.contains("€")) {
      if (token.contains("¥") || token.contains("€")) {
         String newToken = "";
         for (int i = 0; i < token.length(); i++) {
            if (token.charAt(i) == '¥'||token.charAt(i) == '€') {
            if (token.charAt(i) == '¥' || token.charAt(i) == '€') {
               if (!newToken.contains("("))
                  newToken += "(";
               else
@@ -2063,8 +2098,30 @@
      }
      return token;
   }
   /**
    * 提取自有格式的淘口令
    *
    * @param str
    * @return
    */
   public static String parseSystemTaoToken(String str) {
      String pattern = "(\\({1}[A-Za-z0-9]+\\){1})";
      Pattern r = Pattern.compile(pattern);
      Matcher m = r.matcher(str);
      while (m.find()) {
         String group = m.group(0);
         if (!StringUtil.isNullOrEmpty(group))
            return group;
      }
      return null;
   }
   public static boolean isSpecialGoods(Integer materialLibType) {
      if (materialLibType != null && materialLibType == 1)
         return true;
      else
         return false;
   }
}