From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopUtil.java |  216 +++++++++++++++++++++++++++++++++--------------------
 1 files changed, 133 insertions(+), 83 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopUtil.java
index fa19f2b..9005fa6 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopUtil.java
@@ -1,83 +1,133 @@
-package com.yeshi.fanli.util.vipshop;
-
-import java.math.BigDecimal;
-
-import org.yeshi.utils.BigDecimalUtil;
-
-import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
-import com.yeshi.fanli.util.MoneyBigDecimalUtil;
-import com.yeshi.fanli.util.StringUtil;
-
-public class VipShopUtil {
-
-	private static String getBase64Str(String str) {
-		try {
-			return StringUtil.getBase64String(str);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-
-		return null;
-	}
-
-	/**
-	 * 鑾峰彇鍒嗕韩鐨勬笭閬撴爣璇�
-	 * @Title: getShareChanTag
-	 * @Description: 
-	 * @param uid
-	 * @return 
-	 * String 杩斿洖绫诲瀷
-	 * @throws
-	 */
-	public static String getShareChanTag(Long uid) {
-		return getBase64Str("share#" + uid);
-	}
-
-	/**
-	 * 鑾峰彇鑷喘鐨勬笭閬撴爣璇�
-	 * @Title: getBuyChanTag
-	 * @Description: 
-	 * @param uid
-	 * @return 
-	 * String 杩斿洖绫诲瀷
-	 * @throws
-	 */
-	public static String getBuyChanTag(Long uid) {
-		return getBase64Str("buy#" + uid);
-
-	}
-
-	public static String getUidFromChanTag(String tag) {
-		String decodeTag = StringUtil.getFromBase64(tag);
-		return decodeTag.split("#")[1];
-	}
-
-	public static String getTypeFromChanTag(String tag) {
-		String decodeTag = StringUtil.getFromBase64(tag);
-		return decodeTag.split("#")[0];
-	}
-
-	public static BigDecimal getGoodsFanLiMoney(VIPGoodsInfo goods, BigDecimal rate) {
-		BigDecimal money = null;
-		BigDecimal hundred = new BigDecimal(100);
-		rate = MoneyBigDecimalUtil.div(rate, hundred);
-		money = MoneyBigDecimalUtil.mul(new BigDecimal(goods.getCommission()), rate);
-		return BigDecimalUtil.getWithNoZera(money).setScale(2);
-	}
-
-	/**
-	 * 鑾峰彇璁㈠崟璇︽儏鐨勫敮涓�鏍囪瘑
-	 * @Title: getOrderDetailIdentifyCode
-	 * @Description: 
-	 * @param orderSn
-	 * @param goodsId
-	 * @param sizeId
-	 * @return 
-	 * String 杩斿洖绫诲瀷
-	 * @throws
-	 */
-	public static String getOrderDetailIdentifyCode(String orderSn, String goodsId, String sizeId) {
-
-		return StringUtil.Md5(orderSn + "#" + goodsId + "#" + sizeId);
-	}
-}
+package com.yeshi.fanli.util.vipshop;
+
+import java.math.BigDecimal;
+
+import org.yeshi.utils.BigDecimalUtil;
+import org.yeshi.utils.NumberUtil;
+
+import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
+import org.yeshi.utils.MoneyBigDecimalUtil;
+import com.yeshi.fanli.util.StringUtil;
+
+public class VipShopUtil {
+
+    private static String getBase64Str(String str) {
+        try {
+            return StringUtil.getBase64String(str);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return null;
+    }
+
+    /**
+     * 鑾峰彇鍒嗕韩鐨勬笭閬撴爣璇�
+     *
+     * @param uid
+     * @return String 杩斿洖绫诲瀷
+     * @throws
+     * @Title: getShareChanTag
+     * @Description:
+     */
+    public static String getShareChanTag(Long uid) {
+        return getBase64Str("share#" + uid);
+    }
+
+    /**
+     * 鑾峰彇鑷喘鐨勬笭閬撴爣璇�
+     *
+     * @param uid
+     * @return String 杩斿洖绫诲瀷
+     * @throws
+     * @Title: getBuyChanTag
+     * @Description:
+     */
+    public static String getBuyChanTag(Long uid) {
+        return getBase64Str("buy#" + uid);
+
+    }
+
+    public static String getCouponChanTag() {
+        return getBase64Str("coupon");
+
+    }
+
+    public static String getUidFromChanTag(String tag) {
+        String decodeTag = StringUtil.getFromBase64(tag);
+        return decodeTag.split("#")[1];
+    }
+
+    public static String getTypeFromChanTag(String tag) {
+        String decodeTag = StringUtil.getFromBase64(tag);
+        return decodeTag.split("#")[0];
+    }
+
+    public static BigDecimal getGoodsFanLiMoney(VIPGoodsInfo goods, BigDecimal rate) {
+        BigDecimal money = null;
+        BigDecimal hundred = new BigDecimal(100);
+        rate = MoneyBigDecimalUtil.div(rate, hundred);
+        money = MoneyBigDecimalUtil.mul(new BigDecimal(goods.getCommission()), rate);
+        return BigDecimalUtil.getWithNoZera(money).setScale(2);
+    }
+
+    public static BigDecimal getCouponPrice(VIPGoodsInfo goods) {
+        return new BigDecimal(goods.getVipPrice());
+    }
+
+    /**
+     * 鑾峰彇璁㈠崟璇︽儏鐨勫敮涓�鏍囪瘑
+     *
+     * @param orderSn
+     * @param goodsId
+     * @param sizeId
+     * @return String 杩斿洖绫诲瀷
+     * @throws
+     * @Title: getOrderDetailIdentifyCode
+     * @Description:
+     */
+    public static String getOrderDetailIdentifyCode(String orderSn, String goodsId, String sizeId) {
+
+        return StringUtil.Md5(orderSn + "#" + goodsId + "#" + sizeId);
+    }
+
+    public static boolean isVIPShopLink(String url) {
+        return url.contains(".vip.com/");
+    }
+
+    public static String parseGoodsIdByUrl(String url) {
+        try {
+            if (isVIPShopLink(url)) {
+                if (url.contains("detail-") || url.contains("product-")) {
+                    String preUrl = url.split("\\?")[0];
+                    String goodsId = preUrl.split("-")[preUrl.split("-").length - 1].replace(".html", "").replace(".htm",
+                            "");
+                    if (NumberUtil.isNumeric(goodsId))
+                        return goodsId;
+                } else {
+                    if (url.split("\\?").length > 1) {
+                        String param = url.split("\\?")[1];
+                        String[] params = param.split("&");
+                        for (String p : params) {
+                            String[] ps = p.split("=");
+                            if (ps.length > 1 && ps[0].trim().equalsIgnoreCase("goodsId")) {
+                                return ps[1].trim();
+                            }
+                        }
+                    }
+                }
+            // 閫氳繃璁㈠崟渚犳帴鍙hВ鏋�
+            return  DingDanXiaApiUtil.parseGoodsIdFromLink(url);
+            }
+        } catch (Exception e) {
+        }
+        return null;
+    }
+
+    public static void main(String[] args) {
+
+        System.out.print(parseGoodsIdByUrl("https://mst.vip.com/x6M88WQc9Abq5h0CHNg1uw.php?wapid=mst_100099181&_src=mst&extra_banner=115099181&nova=1&nova_platform=1&mst_page_type=guide&goodsId=6920553939593155215&brandId=1712199535&actType=normal&launchId=&nmsns=shop_android-9.10.2-link&nst=product&nsbc=&nct=link&ncid=9ab423d2-932f-3916-b913-4ddf57e809ed&nabtid=13&nuid=59508964&nchl_param=share:9ab423d2-932f-3916-b913-4ddf57e809ed:1697182347995&mars_cid_a=9ab423d2-932f-3916-b913-4ddf57e809ed&chl_type=share"));
+    }
+}
+
+

--
Gitblit v1.8.0