admin
2025-02-25 30d8e227e8d823b6c38c3b9c90ac2df03b63befe
fanli/src/main/java/com/yeshi/fanli/util/jd/JDUtil.java
@@ -222,7 +222,7 @@
    /**
     * 搜索网页
     *
     * @param searchFilter
     * @param skuId
     * @return
     */
    @SuppressWarnings("deprecation")
@@ -450,10 +450,10 @@
    /**
     * 计算商品券后价,没有券则返回原价
     *
     * @param goodsBrief
     * @param jdGoods
     * @return
     */
    public static BigDecimal getQuanPrice(JDGoods jdGoods) {
    public static BigDecimal getCouponPrice(JDGoods jdGoods) {
        BigDecimal price = null;
        JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo();
        if (pinGouInfo == null) {
@@ -528,6 +528,11 @@
        } catch (Exception e) {
        }
        return list;
    }
    public static boolean isJDLink(String url) {
        return url.startsWith("https://item.m.jd.com/product/") || url.startsWith("http://item.m.jd.com/product/")
                || url.startsWith("https://item.jd.com/") || url.startsWith("http://item.jd.com/")||url.startsWith("https://u.jd.com/")||url.startsWith("https://3.cn/");
    }
    /**
@@ -668,6 +673,23 @@
     * @return
     */
    public static String getJDGoodsIdByUJD(String url) {
        if(url.startsWith("https://3.cn/")){
            try {
                Document doc = Jsoup.connect(url).get();
                String location = doc.location();
                if (location.startsWith("https://cfe.m.jd.com/privatedomain/")) {
                    Map<String, String> params = HttpUtil.getPramsFromUrl(location);
                    String returnurl = params.get("returnurl");
                    returnurl = URLDecoder.decode(returnurl, "UTF-8");
                  return parseJDSkuIdByUrl(returnurl);
                } else {
                    return parseJDSkuIdByUrl(location);
                }
            }catch(Exception e){
            }
        }
        try {
            String body = HttpUtil.get(url);
            Document doc = Jsoup.parse(body);
@@ -750,7 +772,7 @@
    /**
     * 查询天猫商品图片、标题
     *
     * @param auctionId
     * @param goodsId
     * @return
     */
    public static JDGoods getSimpleGoodsInfo(String goodsId) {
@@ -948,4 +970,17 @@
        return urlList;
    }
    public static String getMaterialId(String id){
        if(NumberUtil.isNumeric(id)){
            return String.format("https://item.jd.com/%s.html", id);
        }else{
            return String.format("https://jingfen.jd.com/detail/%s.html", id);
        }
    }
    public static void main(String[] args) throws IOException {
        System.out.printf(getJDGoodsIdByUJD("https://3.cn/297ndx-c"));
    }
}