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/suning/SuningUtil.java |  231 +++++++++++++++++++++++++++++++--------------------------
 1 files changed, 126 insertions(+), 105 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/suning/SuningUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/suning/SuningUtil.java
index 2cd2165..d051ad5 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/suning/SuningUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/suning/SuningUtil.java
@@ -1,105 +1,126 @@
-package com.yeshi.fanli.util.suning;
-
-import java.math.BigDecimal;
-
-import org.yeshi.utils.BigDecimalUtil;
-import org.yeshi.utils.NumberUtil;
-
-import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
-import com.yeshi.fanli.util.MoneyBigDecimalUtil;
-import com.yeshi.fanli.util.StringUtil;
-
-public class SuningUtil {
-	public static BigDecimal getGoodsFanLiMoney(SuningGoodsInfo goods, BigDecimal rate) {
-
-		BigDecimal hundred = new BigDecimal(100);
-		rate = MoneyBigDecimalUtil.div(rate, hundred);
-		
-		String commodityPrice = goods.getCommodityInfo().getCommodityPrice();
-		if (StringUtil.isNullOrEmpty(commodityPrice)) {
-			commodityPrice = goods.getCommodityInfo().getSnPrice();
-		}
-
-		BigDecimal afterUseCouponPrice = new BigDecimal(commodityPrice);
-		if (goods.getCouponInfo() != null && !StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) {
-			// 鏈夊埜
-			BigDecimal startPrice = new BigDecimal(goods.getCouponInfo().getBounsLimit());
-			if (afterUseCouponPrice.compareTo(startPrice) >= 0) {
-				afterUseCouponPrice = afterUseCouponPrice.subtract(startPrice);
-			}
-		}
-
-		BigDecimal money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.div(
-				afterUseCouponPrice.multiply(new BigDecimal(goods.getCommodityInfo().getRate())), new BigDecimal(100)),
-				rate);
-		return BigDecimalUtil.getWithNoZera(money).setScale(2);
-	}
-
-	/**
-	 * 鑾峰彇鎷兼帴鐨勫晢鍝両D
-	 * @Title: getConcatGoodsIId
-	 * @Description: 
-	 * @param supplierCode
-	 * @param goodsId
-	 * @return 
-	 * String 杩斿洖绫诲瀷
-	 * @throws
-	 */
-	public static String getConcatGoodsIId(String supplierCode, String goodsId) {
-
-		return supplierCode + "-" + goodsId;
-	}
-
-	public static String getFullSupplierCode(String supplierCode) {
-		for (int i = 0; i < 10; i++) {
-			if (supplierCode.length() < 10)
-				supplierCode = "0" + supplierCode;
-		}
-
-		return supplierCode;
-	}
-
-	/**
-	 * 閫氳繃鎷兼帴鐨勫晢鍝両D瑙f瀽鍑烘潵姝g‘鐨勫晢鍝両D
-	 * @Title: getGoodsIdDetail
-	 * @Description: 
-	 * @param concatGoodsId
-	 * @return 
-	 * String[] 杩斿洖绫诲瀷
-	 * @throws
-	 */
-	public static String[] getGoodsIdDetail(String concatGoodsId) {
-		String[] sts = concatGoodsId.split("-");
-		String supplierCode = sts[0];
-		for (int i = 0; i < 10; i++) {
-			if (supplierCode.length() < 10)
-				supplierCode = "0" + supplierCode;
-		}
-		return new String[] { supplierCode, sts[1] };
-	}
-
-	public static String getProductUrl(String supplierCode, String goodsId) {
-
-		return String.format("https://product.suning.com/%s/%s.html", supplierCode, goodsId);
-	}
-
-	public static String parseGoodsIdByUrl(String url) {
-		try {
-			if (url.contains(".suning.com/")
-					&& (url.contains(".suning.com/product/") || url.contains("product.suning.com/"))) {
-				String preUrl = url.split("\\?")[0];
-				String[] sts = preUrl.split("/");
-				if (sts.length > 2) {
-					String goodsId = sts[sts.length - 1].replace(".html", "").replace(".htm", "");
-					String supplierCode = sts[sts.length - 2];
-					if (NumberUtil.isNumeric(goodsId) && NumberUtil.isNumeric(supplierCode)) {
-						return supplierCode + "-" + goodsId;
-					}
-				}
-			}
-		} catch (Exception e) {
-		}
-		return null;
-	}
-
-}
+package com.yeshi.fanli.util.suning;
+
+import java.math.BigDecimal;
+
+import org.yeshi.utils.BigDecimalUtil;
+import org.yeshi.utils.NumberUtil;
+
+import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
+import org.yeshi.utils.MoneyBigDecimalUtil;
+import com.yeshi.fanli.util.StringUtil;
+
+public class SuningUtil {
+    public static BigDecimal getGoodsFanLiMoney(SuningGoodsInfo goods, BigDecimal rate) {
+
+        BigDecimal hundred = new BigDecimal(100);
+        rate = MoneyBigDecimalUtil.div(rate, hundred);
+
+        BigDecimal afterUseCouponPrice = getCouponPrice(goods);
+
+        BigDecimal commission = MoneyBigDecimalUtil.mul(afterUseCouponPrice, MoneyBigDecimalUtil.div(new BigDecimal(goods.getCommodityInfo().getRate()), new BigDecimal(100), 5));
+
+        BigDecimal money = MoneyBigDecimalUtil.mul(commission,
+                rate);
+        return BigDecimalUtil.getWithNoZera(money).setScale(2);
+    }
+
+    /**
+     * 鑾峰彇鍒稿悗浠�
+     *
+     * @param goods
+     * @return
+     */
+
+    public static BigDecimal getCouponPrice(SuningGoodsInfo goods) {
+        String commodityPrice = goods.getCommodityInfo().getCommodityPrice();
+        if (StringUtil.isNullOrEmpty(commodityPrice)) {
+            commodityPrice = goods.getCommodityInfo().getSnPrice();
+        }
+
+        BigDecimal afterUseCouponPrice = new BigDecimal(commodityPrice);
+        if (goods.getCouponInfo() != null && !StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) {
+            // 鏈夊埜
+            BigDecimal startPrice = null;
+            if (StringUtil.isNullOrEmpty(goods.getCouponInfo().getBounsLimit())) {
+                startPrice = new BigDecimal(goods.getCouponInfo().getCouponValue());
+            } else
+                startPrice = new BigDecimal(goods.getCouponInfo().getBounsLimit());
+            if (afterUseCouponPrice.compareTo(startPrice) >= 0) {
+                afterUseCouponPrice = afterUseCouponPrice.subtract(new BigDecimal(goods.getCouponInfo().getCouponValue()));
+            }
+        }
+        return afterUseCouponPrice;
+    }
+
+    /**
+     * 鑾峰彇鎷兼帴鐨勫晢鍝両D
+     *
+     * @param supplierCode
+     * @param goodsId
+     * @return String 杩斿洖绫诲瀷
+     * @throws
+     * @Title: getConcatGoodsIId
+     * @Description:
+     */
+    public static String getConcatGoodsIId(String supplierCode, String goodsId) {
+
+        return supplierCode + "-" + goodsId;
+    }
+
+    public static String getFullSupplierCode(String supplierCode) {
+        for (int i = 0; i < 10; i++) {
+            if (supplierCode.length() < 10)
+                supplierCode = "0" + supplierCode;
+        }
+
+        return supplierCode;
+    }
+
+    /**
+     * 閫氳繃鎷兼帴鐨勫晢鍝両D瑙f瀽鍑烘潵姝g‘鐨勫晢鍝両D
+     *
+     * @param concatGoodsId
+     * @return String[] 杩斿洖绫诲瀷
+     * @throws
+     * @Title: getGoodsIdDetail
+     * @Description:
+     */
+    public static String[] getGoodsIdDetail(String concatGoodsId) {
+        String[] sts = concatGoodsId.split("-");
+        String supplierCode = sts[0];
+        for (int i = 0; i < 10; i++) {
+            if (supplierCode.length() < 10)
+                supplierCode = "0" + supplierCode;
+        }
+        return new String[]{supplierCode, sts[1]};
+    }
+
+    public static String getProductUrl(String supplierCode, String goodsId) {
+
+        return String.format("https://product.suning.com/%s/%s.html", supplierCode, goodsId);
+    }
+
+    public static boolean isSuningLink(String url) {
+        return (url.contains(".suning.com/")
+                && (url.contains(".suning.com/product/") || url.contains("product.suning.com/")));
+    }
+
+    public static String parseGoodsIdByUrl(String url) {
+        try {
+            if (isSuningLink(url)) {
+                String preUrl = url.split("\\?")[0];
+                String[] sts = preUrl.split("/");
+                if (sts.length > 2) {
+                    String goodsId = sts[sts.length - 1].replace(".html", "").replace(".htm", "");
+                    String supplierCode = sts[sts.length - 2];
+                    if (NumberUtil.isNumeric(goodsId) && NumberUtil.isNumeric(supplierCode)) {
+                        return supplierCode + "-" + goodsId;
+                    }
+                }
+            }
+        } catch (Exception e) {
+        }
+        return null;
+    }
+
+}

--
Gitblit v1.8.0