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/factory/CommonGoodsFactory.java |  844 +++++++++++++++++++++++++++++++++----------------------
 1 files changed, 507 insertions(+), 337 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/factory/CommonGoodsFactory.java b/fanli/src/main/java/com/yeshi/fanli/util/factory/CommonGoodsFactory.java
index 3588346..3efe64b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/factory/CommonGoodsFactory.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/factory/CommonGoodsFactory.java
@@ -1,337 +1,507 @@
-package com.yeshi.fanli.util.factory;
-
-import java.math.BigDecimal;
-
-import com.alibaba.fastjson.JSONObject;
-import com.yeshi.fanli.dto.common.CategoryInfoDTO;
-import com.yeshi.fanli.dto.common.GoodsOtherInfoDTO;
-import com.yeshi.fanli.dto.jd.JDCategoryInfo;
-import com.yeshi.fanli.dto.jd.JDCommissionInfo;
-import com.yeshi.fanli.dto.jd.JDCouponInfo;
-import com.yeshi.fanli.dto.jd.JDShopInfo;
-import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
-import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
-import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
-import com.yeshi.fanli.entity.goods.CommonGoods;
-import com.yeshi.fanli.entity.jd.JDGoods;
-import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
-import com.yeshi.fanli.util.MoneyBigDecimalUtil;
-import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.jd.JDUtil;
-
-public class CommonGoodsFactory {
-
-	/**
-	 * 娣樺疂鍟嗗搧鏋勯��
-	 * 
-	 * @param goods
-	 * @return
-	 */
-	public static CommonGoods create(TaoBaoGoodsBrief goods) {
-		if (goods == null)
-			return null;
-
-		CommonGoods cg = new CommonGoods();
-		cg.setCouponAmount(goods.getCouponAmount());
-		cg.setCouponInfo(goods.getCouponInfo());
-		cg.setCouponLeftCount(goods.getCouponLeftCount());
-		cg.setCouponStartPrice(goods.getCouponStartFee());
-		cg.setCouponTotalCount(goods.getCouponTotalCount());
-		cg.setGoodsId(goods.getAuctionId());
-		cg.setGoodsType(CommonGoods.GOODS_TYPE_TB);
-		cg.setPicture(goods.getPictUrl());
-		cg.setPictureWhite(goods.getPictUrlWhite());
-		cg.setPrice(goods.getZkPrice());
-		cg.setSales(goods.getBiz30day());
-		cg.setRate(goods.getTkRate());
-		cg.setSellerId(goods.getSellerId());
-		cg.setSellerName(goods.getShopTitle());
-		if (goods.getUserType() == 0)
-			cg.setShopType(CommonGoods.SHOP_TYPE_TB);
-		else
-			cg.setShopType(CommonGoods.SHOP_TYPE_TM);
-		cg.setState(CommonGoods.STATE_NORMAL);
-		cg.setTitle(goods.getTitle());
-		// 淇濈暀瀛楁
-		cg.setVideoCover(null);
-		cg.setVideoUrl(null);
-		cg.setState(goods.getState());
-		cg.setMaterialLibType(goods.getMaterialLibType());
-
-		// 鍒嗙被淇℃伅
-		CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
-		Integer rootCatId = goods.getRootCatId();
-		if (rootCatId != null) {
-			categoryInfo.setCid1(Long.parseLong(rootCatId.toString()));
-		}
-		categoryInfo.setCid1Name(goods.getRootCategoryName());
-
-		Integer leafCatId = goods.getLeafCatId();
-		if (leafCatId != null) {
-			categoryInfo.setCid2(Long.parseLong(leafCatId.toString()));
-		}
-		categoryInfo.setCid2Name(goods.getLeafName());
-		cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString());
-
-		return cg;
-	}
-
-	/**
-	 * 娣樺疂鍟嗗搧鏋勯��
-	 * 
-	 * @param goods
-	 * @return
-	 */
-	public static CommonGoods create(JDGoods goods) {
-		if (goods == null)
-			return null;
-
-		CommonGoods cg = new CommonGoods();
-		JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods);
-		if (couponInfo != null) {
-			cg.setCouponStartPrice(couponInfo.getQuota());
-			BigDecimal discount = couponInfo.getDiscount();
-			if (discount != null && discount.compareTo(new BigDecimal(0)) > 0) {
-				cg.setCouponAmount(discount);
-				if (cg.getCouponStartPrice().compareTo(new BigDecimal(0)) > 0)
-					cg.setCouponInfo(String.format("婊�%s鍏冨噺%s鍏�", couponInfo.getQuota() + "", cg.getCouponAmount() + ""));
-				else
-					cg.setCouponInfo(String.format("%s鍏冩棤鏉′欢鍒�", cg.getCouponAmount() + ""));
-			} else {
-				cg.setCouponAmount(new BigDecimal(0));
-			}
-			cg.setCouponLeftCount(1);
-			cg.setCouponTotalCount(1);
-		}
-
-		JDCommissionInfo commissionInfo = goods.getCommissionInfo();
-		if (commissionInfo != null) {
-			cg.setRate(commissionInfo.getCommissionShare());
-		} else {
-			cg.setRate(new BigDecimal(0));
-		}
-
-		JDShopInfo shopInfo = goods.getShopInfo();
-		if (shopInfo != null) {
-			cg.setSellerId(Long.parseLong(shopInfo.getShopId().toString()));
-			cg.setSellerName(shopInfo.getShopName() == null ? "" : shopInfo.getShopName());
-		}
-
-		cg.setGoodsId(goods.getSkuId());
-		cg.setTitle(goods.getSkuName());
-		cg.setGoodsType(CommonGoods.GOODS_TYPE_JD);
-		cg.setPicture(goods.getPicUrl());
-		cg.setPrice(goods.getPrice());
-		cg.setSales(Integer.parseInt(goods.getInOrderCount30Days().toString()));
-
-		String owner = goods.getOwner();
-		if (StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) {
-			cg.setShopType(CommonGoods.SHOP_TYPE_JD_SELF); // 浜笢鑷惀
-		} else {
-			cg.setShopType(CommonGoods.SHOP_TYPE_JD); // 浜笢
-		}
-
-		cg.setState(CommonGoods.STATE_NORMAL);
-
-		// 鍏朵粬淇℃伅
-		GoodsOtherInfoDTO other = new GoodsOtherInfoDTO();
-		other.setOwner(owner); // 鏄惁鑷惀
-		other.setPinGouInfo(goods.getPinGouInfo()); // 鎷艰喘淇℃伅
-		other.setIsFreeShipping(goods.getIsFreeShipping()); // 鏄惁鍖呴偖
-		cg.setOtherInfo(JSONObject.toJSON(other).toString());
-
-		// 鍒嗙被淇℃伅
-		JDCategoryInfo categoryJD = goods.getCategoryInfo();
-		if (categoryJD != null) {
-			CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
-			categoryInfo.setCid1(categoryJD.getCid1());
-			categoryInfo.setCid1Name(categoryJD.getCid1Name());
-			categoryInfo.setCid2(categoryJD.getCid2());
-			categoryInfo.setCid2Name(categoryJD.getCid2Name());
-			categoryInfo.setCid3(categoryJD.getCid3());
-			categoryInfo.setCid3Name(categoryJD.getCid3Name());
-			cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString());
-		}
-
-		// 淇濈暀瀛楁
-		cg.setVideoCover(null);
-		cg.setVideoUrl(null);
-		return cg;
-	}
-
-	public static CommonGoods create(PDDGoodsDetail goods) {
-		if (goods == null)
-			return null;
-
-		CommonGoods cg = new CommonGoods();
-
-		if (goods.getCouponRemainQuantity() != null)
-			cg.setCouponLeftCount(Integer.parseInt(goods.getCouponRemainQuantity() + ""));
-		else
-			cg.setCouponLeftCount(0);
-		if (goods.getCouponMinOrderAmount() != null)
-			cg.setCouponStartPrice(
-					MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponMinOrderAmount()), new BigDecimal(100)));
-		else
-			cg.setCouponStartPrice(new BigDecimal(0));
-
-		if (goods.getCouponDiscount() != null && goods.getCouponDiscount() > 0) {
-			cg.setCouponAmount(MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), new BigDecimal(100)));
-			if (cg.getCouponStartPrice().compareTo(new BigDecimal(0)) > 0)
-				cg.setCouponInfo(String.format("婊�%s鍏冨噺%s鍏�", cg.getCouponStartPrice() + "", cg.getCouponAmount() + ""));
-			else
-				cg.setCouponInfo(String.format("%s鍏冩棤鏉′欢鍒�", cg.getCouponAmount() + ""));
-		} else {
-			cg.setCouponAmount(new BigDecimal(0));
-		}
-
-		cg.setCouponTotalCount(Integer.parseInt(goods.getCouponTotalQuantity() + ""));
-		cg.setGoodsId(goods.getGoodsId());
-		cg.setGoodsType(CommonGoods.GOODS_TYPE_PDD);
-		cg.setPicture(goods.getGoodsThumbnailUrl());
-		cg.setPictureWhite(null);
-		cg.setPrice(MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)));
-
-		String salesTip = goods.getSalesTip();
-		if (StringUtil.isNullOrEmpty(salesTip)) {
-			salesTip = "0";
-		} else {
-			int indexOf = salesTip.indexOf("+");
-			if (indexOf > 0) {
-				salesTip = salesTip.substring(0, indexOf);
-			}
-		}
-
-		int totalSales = 0;
-		if (salesTip.contains("涓�")) {
-			salesTip = salesTip.substring(0, salesTip.indexOf("涓�"));
-			totalSales = (int) (Float.parseFloat(salesTip) * 10000);
-		} else {
-			totalSales = Integer.parseInt(salesTip);
-		}
-		cg.setSales(totalSales);
-		cg.setRate(MoneyBigDecimalUtil.div(new BigDecimal(goods.getPromotionRate()), new BigDecimal(10)));
-		cg.setSellerId(goods.getMallId());
-		cg.setSellerName(goods.getMallName());
-		cg.setShopType(CommonGoods.SHOP_TYPE_PDD);
-		cg.setState(CommonGoods.STATE_NORMAL);
-		cg.setTitle(goods.getGoodsName());
-		// 淇濈暀瀛楁
-		cg.setVideoCover(null);
-		cg.setVideoUrl(null);
-		cg.setState(goods.getState());
-		cg.setMaterialLibType(1);
-
-		// 鍒嗙被淇℃伅
-		CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
-		categoryInfo.setCid1(goods.getCategoryId());
-		categoryInfo.setCid1Name(goods.getCategoryName());
-		cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString());
-
-		return cg;
-	}
-
-	public static CommonGoods create(VIPGoodsInfo goods) {
-		if (goods == null)
-			return null;
-
-		CommonGoods cg = new CommonGoods();
-
-		// 鎶樻墸淇℃伅
-		cg.setCouponInfo(new BigDecimal(goods.getDiscount()) + "");
-		cg.setCouponLeftCount(0);
-		cg.setCouponStartPrice(new BigDecimal(0));
-		cg.setCouponAmount(new BigDecimal(0));
-
-		cg.setCouponTotalCount(0);
-		cg.setGoodsId(Long.parseLong(goods.getGoodsId()));
-		cg.setGoodsType(CommonGoods.GOODS_TYPE_VIP);
-		cg.setPicture(goods.getGoodsThumbUrl());
-		cg.setPictureWhite(null);
-		cg.setPrice(new BigDecimal(goods.getMarketPrice()));
-
-		int totalSales = 0;
-		cg.setSales(totalSales);
-		cg.setRate(new BigDecimal(goods.getCommissionRate()));
-		cg.setSellerId(goods.getBrandId());
-		cg.setSellerName(goods.getBrandName());
-		cg.setShopType(CommonGoods.SHOP_TYPE_VIP);
-		cg.setState(CommonGoods.STATE_NORMAL);
-		cg.setTitle(goods.getGoodsName());
-		// 淇濈暀瀛楁
-		cg.setVideoCover(null);
-		cg.setVideoUrl(null);
-		cg.setState(goods.getStatus() == 1 ? CommonGoods.STATE_NORMAL : CommonGoods.STATE_OFFLINE);
-		cg.setMaterialLibType(1);
-
-		// 鍒嗙被淇℃伅
-		CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
-		categoryInfo.setCid1(goods.getCategoryId());
-		categoryInfo.setCid1Name(goods.getCategoryName());
-		cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString());
-		//瀛樻斁鎶樻墸浠�
-		cg.setCouponStartPrice(new BigDecimal(goods.getVipPrice()));
-		cg.setCouponInfo(MoneyBigDecimalUtil.getWithNoZera(MoneyBigDecimalUtil.mul(new BigDecimal(goods.getDiscount()), new BigDecimal(10))) + "鎶�");
-		return cg;
-	}
-
-	public static CommonGoods create(SuningGoodsInfo goods) {
-		if (goods == null)
-			return null;
-
-		CommonGoods cg = new CommonGoods();
-
-		if (goods.getCouponInfo() != null && !StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) {// 鏈夊埜
-			cg.setCouponInfo(String.format("婊�%s鍏冨噺%s鍏�", goods.getCouponInfo().getBounsLimit(),
-					goods.getCouponInfo().getCouponValue()));
-			cg.setCouponAmount(new BigDecimal(goods.getCouponInfo().getCouponValue()));
-			
-			if (goods.getCouponInfo().getCouponCount() == null) {
-				cg.setCouponLeftCount(500000);
-				cg.setCouponTotalCount(500000);
-			} else {
-				cg.setCouponLeftCount(Integer.parseInt(goods.getCouponInfo().getCouponCount()));
-				cg.setCouponTotalCount(Integer.parseInt(goods.getCouponInfo().getCouponCount()));
-			}
-			
-			cg.setCouponStartPrice(new BigDecimal(goods.getCouponInfo().getBounsLimit()));
-		} else {
-			cg.setCouponLeftCount(0);
-			cg.setCouponTotalCount(0);
-			cg.setCouponAmount(new BigDecimal(0));
-		}
-
-		cg.setGoodsId(Long.parseLong(goods.getCommodityInfo().getCommodityCode()));
-		cg.setGoodsType(CommonGoods.GOODS_TYPE_SUNING);
-		if (goods.getCommodityInfo().getPictureUrl() != null && goods.getCommodityInfo().getPictureUrl().size() > 0)
-			cg.setPicture(goods.getCommodityInfo().getPictureUrl().get(0).getPicUrl());
-		cg.setPictureWhite(null);
-		cg.setPrice(new BigDecimal(goods.getCommodityInfo().getSnPrice()));
-
-		cg.setSales(Integer.parseInt(goods.getCommodityInfo().getMonthSales()));
-		cg.setRate(new BigDecimal(goods.getCommodityInfo().getRate()));
-		cg.setSellerId(Long.parseLong(goods.getCommodityInfo().getSupplierCode()));
-		cg.setSellerName(goods.getCommodityInfo().getSupplierName());
-		cg.setShopType(CommonGoods.SHOP_TYPE_SUNING);
-		cg.setState(CommonGoods.STATE_NORMAL);
-		cg.setTitle(goods.getCommodityInfo().getCommodityName());
-		// 淇濈暀瀛楁
-		cg.setVideoCover(null);
-		cg.setVideoUrl(null);
-		cg.setState(0);
-		cg.setMaterialLibType(1);
-
-		// 鍒嗙被淇℃伅
-		CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
-		categoryInfo.setCid1(Long.parseLong(goods.getCategoryInfo().getFirstSaleCategoryId()));
-		categoryInfo.setCid1Name(goods.getCategoryInfo().getFirstSaleCategoryName());
-
-		categoryInfo.setCid2(Long.parseLong(goods.getCategoryInfo().getSecondSaleCategoryId()));
-		categoryInfo.setCid2Name(goods.getCategoryInfo().getSecondSaleCategoryName());
-
-		cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString());
-
-		return cg;
-	}
-
-}
+package com.yeshi.fanli.util.factory;
+
+import com.alibaba.fastjson.JSONObject;
+import com.yeshi.fanli.dto.common.CategoryInfoDTO;
+import com.yeshi.fanli.dto.common.GoodsOtherInfoDTO;
+import com.yeshi.fanli.dto.jd.JDCategoryInfo;
+import com.yeshi.fanli.dto.jd.JDCommissionInfo;
+import com.yeshi.fanli.dto.jd.JDCouponInfo;
+import com.yeshi.fanli.dto.jd.JDShopInfo;
+import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
+import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
+import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
+import com.yeshi.fanli.entity.goods.CommonGoods;
+import com.yeshi.fanli.entity.jd.JDGoods;
+import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.factory.goods.TaoBaoGoodsFactory;
+import com.yeshi.fanli.util.goods.douyin.DYUtil;
+import com.yeshi.fanli.util.goods.douyin.vo.DYGoods;
+import com.yeshi.fanli.util.goods.douyin.vo.DYGoodsDetail;
+import com.yeshi.fanli.util.jd.JDUtil;
+import com.yeshi.fanli.util.taobao.TaoBaoUtil;
+import com.yeshi.goods.facade.dto.taobao.haodanku.HaoDanKuJDGoodsInfo;
+import com.yeshi.goods.facade.dto.taobao.haodanku.HaoDanKuPDDGoodsInfo;
+import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
+import com.yeshi.goods.facade.entity.taobao.haodanku.HDKGoodsDetail;
+import org.yeshi.utils.MoneyBigDecimalUtil;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+public class CommonGoodsFactory {
+
+    /**
+     * 娣樺疂鍟嗗搧鏋勯��
+     *
+     * @param goods
+     * @return
+     */
+    public static CommonGoods create(TaoBaoGoodsBrief goods) {
+        if (goods == null)
+            return null;
+
+        CommonGoods cg = new CommonGoods();
+        cg.setCouponAmount(goods.getCouponAmount());
+        cg.setCouponInfo(goods.getCouponInfo());
+        cg.setCouponLeftCount(goods.getCouponLeftCount());
+        cg.setCouponStartPrice(goods.getCouponStartFee());
+        cg.setCouponTotalCount(goods.getCouponTotalCount());
+        cg.setGoodsId(TaoBaoUtil.getAuctionId(goods.getAuctionId()));
+        if(TaoBaoUtil.isNewAuctionId(goods.getAuctionId())){
+            cg.setGoodsSign(goods.getAuctionId());
+        }
+        cg.setGoodsType(CommonGoods.GOODS_TYPE_TB);
+        cg.setPicture(goods.getPictUrl());
+        cg.setPictureWhite(goods.getPictUrlWhite());
+        cg.setPrice(goods.getZkPrice());
+        cg.setSales(goods.getBiz30day());
+        cg.setRate(goods.getTkRate());
+        cg.setSellerId(goods.getSellerId());
+        cg.setSellerName(goods.getShopTitle());
+        if (goods.getUserType() == 0)
+            cg.setShopType(CommonGoods.SHOP_TYPE_TB);
+        else
+            cg.setShopType(CommonGoods.SHOP_TYPE_TM);
+        cg.setState(CommonGoods.STATE_NORMAL);
+        cg.setTitle(goods.getTitle());
+        // 淇濈暀瀛楁
+        cg.setVideoCover(null);
+        cg.setVideoUrl(null);
+        cg.setState(goods.getState());
+        cg.setMaterialLibType(goods.getMaterialLibType());
+
+        // 鍒嗙被淇℃伅
+        CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
+        Integer rootCatId = goods.getRootCatId();
+        if (rootCatId != null) {
+            categoryInfo.setCid1(Long.parseLong(rootCatId.toString()));
+        }
+        categoryInfo.setCid1Name(goods.getRootCategoryName());
+
+        Integer leafCatId = goods.getLeafCatId();
+        if (leafCatId != null) {
+            categoryInfo.setCid2(Long.parseLong(leafCatId.toString()));
+        }
+        categoryInfo.setCid2Name(goods.getLeafName());
+        cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString());
+
+        return cg;
+    }
+
+    public static List<CommonGoods> createTaoBaoList(List<TaoBaoGoodsBrief> goodsList) {
+        if (goodsList == null)
+            return null;
+        List<CommonGoods> commonGoodsList = new ArrayList<>();
+        for (TaoBaoGoodsBrief goodsBrief : goodsList) {
+            commonGoodsList.add(create(goodsBrief));
+        }
+        return commonGoodsList;
+    }
+
+    /**
+     * 娣樺疂鍟嗗搧鏋勯��
+     *
+     * @param goods
+     * @return
+     */
+    public static CommonGoods create(JDGoods goods) {
+        if (goods == null)
+            return null;
+
+        CommonGoods cg = new CommonGoods();
+        JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods);
+        if (couponInfo != null) {
+            cg.setCouponStartPrice(couponInfo.getQuota());
+            BigDecimal discount = couponInfo.getDiscount();
+            if (discount != null && discount.compareTo(new BigDecimal(0)) > 0) {
+                cg.setCouponAmount(discount);
+                if (cg.getCouponStartPrice().compareTo(new BigDecimal(0)) > 0)
+                    cg.setCouponInfo(String.format("婊�%s鍏冨噺%s鍏�", couponInfo.getQuota() + "", cg.getCouponAmount() + ""));
+                else
+                    cg.setCouponInfo(String.format("%s鍏冩棤鏉′欢鍒�", cg.getCouponAmount() + ""));
+            } else {
+                cg.setCouponAmount(new BigDecimal(0));
+            }
+            cg.setCouponLeftCount(1);
+            cg.setCouponTotalCount(1);
+        }
+
+        JDCommissionInfo commissionInfo = goods.getCommissionInfo();
+        if (commissionInfo != null) {
+            cg.setRate(commissionInfo.getCommissionShare());
+        } else {
+            cg.setRate(new BigDecimal(0));
+        }
+
+        JDShopInfo shopInfo = goods.getShopInfo();
+        if (shopInfo != null) {
+            cg.setSellerId(Long.parseLong(shopInfo.getShopId().toString()));
+            cg.setSellerName(shopInfo.getShopName() == null ? "" : shopInfo.getShopName());
+        }
+
+        cg.setGoodsId(goods.getItemId()+"");
+        cg.setTitle(goods.getSkuName());
+        cg.setGoodsType(CommonGoods.GOODS_TYPE_JD);
+        cg.setPicture(goods.getPicUrl());
+        cg.setPrice(goods.getPrice());
+        cg.setSales(Integer.parseInt(goods.getInOrderCount30Days().toString()));
+
+        String owner = goods.getOwner();
+        if (StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) {
+            cg.setShopType(CommonGoods.SHOP_TYPE_JD_SELF); // 浜笢鑷惀
+        } else {
+            cg.setShopType(CommonGoods.SHOP_TYPE_JD); // 浜笢
+        }
+
+        cg.setState(CommonGoods.STATE_NORMAL);
+
+        // 鍏朵粬淇℃伅
+        GoodsOtherInfoDTO other = new GoodsOtherInfoDTO();
+        other.setOwner(owner); // 鏄惁鑷惀
+        other.setPinGouInfo(goods.getPinGouInfo()); // 鎷艰喘淇℃伅
+        other.setIsFreeShipping(goods.getIsFreeShipping()); // 鏄惁鍖呴偖
+        cg.setOtherInfo(JSONObject.toJSON(other).toString());
+
+        // 鍒嗙被淇℃伅
+        JDCategoryInfo categoryJD = goods.getCategoryInfo();
+        if (categoryJD != null) {
+            CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
+            categoryInfo.setCid1(categoryJD.getCid1());
+            categoryInfo.setCid1Name(categoryJD.getCid1Name());
+            categoryInfo.setCid2(categoryJD.getCid2());
+            categoryInfo.setCid2Name(categoryJD.getCid2Name());
+            categoryInfo.setCid3(categoryJD.getCid3());
+            categoryInfo.setCid3Name(categoryJD.getCid3Name());
+            cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString());
+        }
+
+        // 淇濈暀瀛楁
+        cg.setVideoCover(null);
+        cg.setVideoUrl(null);
+        return cg;
+    }
+
+    public static CommonGoods create(PDDGoodsDetail goods) {
+        if (goods == null)
+            return null;
+
+        CommonGoods cg = new CommonGoods();
+
+        if (goods.getCouponRemainQuantity() != null)
+            cg.setCouponLeftCount(Integer.parseInt(goods.getCouponRemainQuantity() + ""));
+        else
+            cg.setCouponLeftCount(0);
+        if (goods.getCouponMinOrderAmount() != null)
+            cg.setCouponStartPrice(
+                    MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponMinOrderAmount()), new BigDecimal(100)));
+        else
+            cg.setCouponStartPrice(new BigDecimal(0));
+
+        if (goods.getCouponDiscount() != null && goods.getCouponDiscount() > 0) {
+            cg.setCouponAmount(MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), new BigDecimal(100)));
+            if (cg.getCouponStartPrice().compareTo(new BigDecimal(0)) > 0)
+                cg.setCouponInfo(String.format("婊�%s鍏冨噺%s鍏�", cg.getCouponStartPrice() + "", cg.getCouponAmount() + ""));
+            else
+                cg.setCouponInfo(String.format("%s鍏冩棤鏉′欢鍒�", cg.getCouponAmount() + ""));
+        } else {
+            cg.setCouponAmount(new BigDecimal(0));
+        }
+
+        cg.setCouponTotalCount(Integer.parseInt(goods.getCouponTotalQuantity() + ""));
+        cg.setGoodsId(goods.getGoodsId()+"");
+        cg.setGoodsType(CommonGoods.GOODS_TYPE_PDD);
+        cg.setPicture(goods.getGoodsThumbnailUrl());
+        cg.setPictureWhite(null);
+        cg.setPrice(MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)));
+
+        String salesTip = goods.getSalesTip();
+        if (StringUtil.isNullOrEmpty(salesTip)) {
+            salesTip = "0";
+        } else {
+            int indexOf = salesTip.indexOf("+");
+            if (indexOf > 0) {
+                salesTip = salesTip.substring(0, indexOf);
+            }
+        }
+
+        int totalSales = 0;
+        if (salesTip.contains("涓�")) {
+            salesTip = salesTip.substring(0, salesTip.indexOf("涓�"));
+            totalSales = (int) (Float.parseFloat(salesTip) * 10000);
+        } else {
+            totalSales = Integer.parseInt(salesTip);
+        }
+        cg.setSales(totalSales);
+        cg.setRate(MoneyBigDecimalUtil.div(new BigDecimal(goods.getPromotionRate()), new BigDecimal(10)));
+        cg.setSellerId(goods.getMallId());
+        cg.setSellerName(goods.getMallName());
+        cg.setShopType(CommonGoods.SHOP_TYPE_PDD);
+        cg.setState(CommonGoods.STATE_NORMAL);
+        cg.setTitle(goods.getGoodsName());
+        // 淇濈暀瀛楁
+        cg.setVideoCover(null);
+        cg.setVideoUrl(null);
+        cg.setState(goods.getState());
+        cg.setMaterialLibType(1);
+
+        // 鍒嗙被淇℃伅
+        CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
+        categoryInfo.setCid1(goods.getCategoryId());
+        categoryInfo.setCid1Name(goods.getCategoryName());
+        cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString());
+
+        return cg;
+    }
+
+    public static CommonGoods create(VIPGoodsInfo goods) {
+        if (goods == null)
+            return null;
+
+        CommonGoods cg = new CommonGoods();
+
+        // 鎶樻墸淇℃伅
+        cg.setCouponInfo(new BigDecimal(goods.getDiscount()) + "");
+        cg.setCouponLeftCount(0);
+        cg.setCouponStartPrice(new BigDecimal(0));
+        cg.setCouponAmount(new BigDecimal(0));
+
+        cg.setCouponTotalCount(0);
+        cg.setGoodsId(Long.parseLong(goods.getGoodsId())+"");
+        cg.setGoodsType(CommonGoods.GOODS_TYPE_VIP);
+        cg.setPicture(goods.getGoodsThumbUrl());
+        cg.setPictureWhite(null);
+        cg.setPrice(new BigDecimal(goods.getMarketPrice()));
+
+        int totalSales = 0;
+        cg.setSales(totalSales);
+        cg.setRate(new BigDecimal(goods.getCommissionRate()));
+        cg.setSellerId(goods.getBrandId());
+        cg.setSellerName(goods.getBrandName());
+        cg.setShopType(CommonGoods.SHOP_TYPE_VIP);
+        cg.setState(CommonGoods.STATE_NORMAL);
+        cg.setTitle(goods.getGoodsName());
+        // 淇濈暀瀛楁
+        cg.setVideoCover(null);
+        cg.setVideoUrl(null);
+        cg.setState(goods.getStatus() == 1 ? CommonGoods.STATE_NORMAL : CommonGoods.STATE_OFFLINE);
+        cg.setMaterialLibType(1);
+
+        // 鍒嗙被淇℃伅
+        CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
+        categoryInfo.setCid1(goods.getCategoryId());
+        categoryInfo.setCid1Name(goods.getCategoryName());
+        cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString());
+        //瀛樻斁鎶樻墸浠�
+        cg.setCouponStartPrice(new BigDecimal(goods.getVipPrice()));
+        cg.setCouponInfo(MoneyBigDecimalUtil.getWithNoZera(MoneyBigDecimalUtil.mul(new BigDecimal(goods.getDiscount()), new BigDecimal(10))) + "鎶�");
+        return cg;
+    }
+
+
+    public static CommonGoods create(DYGoodsDetail goods) {
+        if (goods == null)
+            return null;
+
+        CommonGoods cg = new CommonGoods();
+
+        // 鎶樻墸淇℃伅
+        cg.setCouponLeftCount(0);
+        cg.setCouponTotalCount(0);
+        cg.setCouponAmount(new BigDecimal(0));
+
+        cg.setCouponTotalCount(0);
+        cg.setGoodsId(goods.getProduct_id()+"");
+        cg.setGoodsType(CommonGoods.GOODS_TYPE_DY);
+        cg.setPicture(goods.getCover());
+        cg.setPictureWhite(null);
+        cg.setPrice(MoneyBigDecimalUtil.div(new BigDecimal(goods.getPrice()),new BigDecimal(100),2));
+
+        cg.setSales(goods.getSales());
+        cg.setRate(DYUtil.getCosRatio(goods).multiply(new BigDecimal(100)));
+        cg.setSellerId((long)goods.getShop_id());
+        cg.setSellerName(goods.getShop_name());
+        cg.setShopType(CommonGoods.SHOP_TYPE_DY);
+        cg.setState(CommonGoods.STATE_NORMAL);
+        cg.setTitle(goods.getTitle());
+        // 淇濈暀瀛楁
+        cg.setVideoCover(null);
+        cg.setVideoUrl(null);
+        cg.setMaterialLibType(1);
+
+        // 鍒嗙被淇℃伅
+        CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
+        categoryInfo.setCid1((long)goods.getFirst_cid());
+        categoryInfo.setCid1Name("");
+        cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString());
+        return cg;
+    }
+
+
+    public static CommonGoods create(DYGoods goods) {
+        if (goods == null)
+            return null;
+
+        CommonGoods cg = new CommonGoods();
+
+        // 鎶樻墸淇℃伅
+        cg.setCouponLeftCount(0);
+        cg.setCouponTotalCount(0);
+        cg.setCouponAmount(new BigDecimal(0));
+
+        cg.setCouponTotalCount(0);
+        cg.setGoodsId(goods.getProduct_id()+"");
+        cg.setGoodsType(CommonGoods.GOODS_TYPE_DY);
+        cg.setPicture(goods.getCover());
+        cg.setPictureWhite(null);
+        cg.setPrice(MoneyBigDecimalUtil.div(new BigDecimal(goods.getPrice()),new BigDecimal(100),2));
+
+        int totalSales = 0;
+        cg.setSales(totalSales);
+        cg.setRate(DYUtil.getCosRatio(goods));
+        cg.setSellerId((long)goods.getShop_id());
+        cg.setSellerName(goods.getShop_name());
+        cg.setShopType(CommonGoods.SHOP_TYPE_DY);
+        cg.setState(CommonGoods.STATE_NORMAL);
+        cg.setTitle(goods.getTitle());
+        // 淇濈暀瀛楁
+        cg.setVideoCover(null);
+        cg.setVideoUrl(null);
+        cg.setMaterialLibType(1);
+
+        // 鍒嗙被淇℃伅
+        CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
+        categoryInfo.setCid1((long)goods.getFirst_cid());
+        categoryInfo.setCid1Name("");
+        cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString());
+        return cg;
+    }
+
+    public static CommonGoods create(SuningGoodsInfo goods) {
+        if (goods == null)
+            return null;
+
+        CommonGoods cg = new CommonGoods();
+
+        if (goods.getCouponInfo() != null && !StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) {// 鏈夊埜
+            cg.setCouponInfo(String.format("婊�%s鍏冨噺%s鍏�", goods.getCouponInfo().getBounsLimit(),
+                    goods.getCouponInfo().getCouponValue()));
+            cg.setCouponAmount(new BigDecimal(goods.getCouponInfo().getCouponValue()));
+
+            if (goods.getCouponInfo().getCouponCount() == null) {
+                cg.setCouponLeftCount(500000);
+                cg.setCouponTotalCount(500000);
+            } else {
+                cg.setCouponLeftCount(Integer.parseInt(goods.getCouponInfo().getCouponCount()));
+                cg.setCouponTotalCount(Integer.parseInt(goods.getCouponInfo().getCouponCount()));
+            }
+
+            cg.setCouponStartPrice(new BigDecimal(goods.getCouponInfo().getBounsLimit()));
+        } else {
+            cg.setCouponLeftCount(0);
+            cg.setCouponTotalCount(0);
+            cg.setCouponAmount(new BigDecimal(0));
+        }
+
+        cg.setGoodsId(Long.parseLong(goods.getCommodityInfo().getCommodityCode())+"");
+        cg.setGoodsType(CommonGoods.GOODS_TYPE_SUNING);
+        if (goods.getCommodityInfo().getPictureUrl() != null && goods.getCommodityInfo().getPictureUrl().size() > 0)
+            cg.setPicture(goods.getCommodityInfo().getPictureUrl().get(0).getPicUrl());
+        cg.setPictureWhite(null);
+        cg.setPrice(new BigDecimal(goods.getCommodityInfo().getSnPrice()));
+
+        cg.setSales(Integer.parseInt(goods.getCommodityInfo().getMonthSales()));
+        cg.setRate(new BigDecimal(goods.getCommodityInfo().getRate()));
+        cg.setSellerId(Long.parseLong(goods.getCommodityInfo().getSupplierCode()));
+        cg.setSellerName(goods.getCommodityInfo().getSupplierName());
+        cg.setShopType(CommonGoods.SHOP_TYPE_SUNING);
+        cg.setState(CommonGoods.STATE_NORMAL);
+        cg.setTitle(goods.getCommodityInfo().getCommodityName());
+        // 淇濈暀瀛楁
+        cg.setVideoCover(null);
+        cg.setVideoUrl(null);
+        cg.setState(0);
+        cg.setMaterialLibType(1);
+
+        // 鍒嗙被淇℃伅
+        CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
+        categoryInfo.setCid1(Long.parseLong(goods.getCategoryInfo().getFirstSaleCategoryId()));
+        categoryInfo.setCid1Name(goods.getCategoryInfo().getFirstSaleCategoryName());
+
+        categoryInfo.setCid2(Long.parseLong(goods.getCategoryInfo().getSecondSaleCategoryId()));
+        categoryInfo.setCid2Name(goods.getCategoryInfo().getSecondSaleCategoryName());
+
+        cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString());
+
+        return cg;
+    }
+
+
+    public static CommonGoods create(HaoDanKuPDDGoodsInfo goods) {
+        if (goods == null)
+            return null;
+        CommonGoods cg = new CommonGoods();
+        if (goods.getCouponmoney() != null) {
+            cg.setCouponAmount(goods.getCouponmoney());
+            cg.setCouponStartPrice(goods.getItemprice());
+            cg.setCouponInfo(String.format("婊�%s鍏冨噺%s鍏�", MoneyBigDecimalUtil.getWithNoZera(goods.getItemprice()) + "", MoneyBigDecimalUtil.getWithNoZera(cg.getCouponAmount()) + ""));
+        }
+
+        if (StringUtil.isNullOrEmpty(goods.getCouponnum()))
+            cg.setCouponLeftCount(0);
+        else
+            cg.setCouponLeftCount(Integer.parseInt(goods.getCouponnum()));
+        cg.setCouponTotalCount(1);
+        cg.setRate(goods.getPromotion_rate());
+        cg.setSellerName(goods.getShopname());
+
+        cg.setGoodsId(Long.parseLong(goods.getGoods_id())+"");
+        cg.setTitle(goods.getGoodsname());
+        cg.setGoodsType(CommonGoods.GOODS_TYPE_PDD);
+        cg.setPicture(goods.getItempic());
+        cg.setPrice(goods.getItemprice());
+        cg.setSales(Integer.parseInt(goods.getItemsale()));
+        cg.setShopType(CommonGoods.SHOP_TYPE_PDD); // 鎷煎澶�
+        cg.setState(CommonGoods.STATE_NORMAL);
+        // 淇濈暀瀛楁
+        cg.setVideoCover(null);
+        cg.setVideoUrl(null);
+        return cg;
+    }
+
+
+    public static CommonGoods create(HaoDanKuJDGoodsInfo goods) {
+        if (goods == null)
+            return null;
+        CommonGoods cg = new CommonGoods();
+        if (goods.getCouponmoney() != null) {
+            cg.setCouponAmount(goods.getCouponmoney());
+            cg.setCouponStartPrice(goods.getItemprice());
+            cg.setCouponInfo(String.format("婊�%s鍏冨噺%s鍏�", MoneyBigDecimalUtil.getWithNoZera(goods.getItemprice()) + "", MoneyBigDecimalUtil.getWithNoZera(cg.getCouponAmount()) + ""));
+        }
+        cg.setCouponLeftCount(goods.getCouponnum());
+        cg.setCouponTotalCount(1);
+        cg.setRate(goods.getCommissionshare());
+        cg.setSellerName(goods.getShopname());
+
+        cg.setGoodsId(goods.getSkuid());
+        cg.setTitle(goods.getGoodsname());
+        cg.setGoodsType(CommonGoods.GOODS_TYPE_JD);
+        cg.setPicture(goods.getItempic());
+        cg.setPrice(goods.getItemprice());
+        cg.setSales(Integer.parseInt(goods.getItemsale()));
+        cg.setShopType(CommonGoods.SHOP_TYPE_JD); // 鎷煎澶�
+        cg.setState(CommonGoods.STATE_NORMAL);
+        // 淇濈暀瀛楁
+        cg.setVideoCover(null);
+        cg.setVideoUrl(null);
+        return cg;
+    }
+
+    public static CommonGoods create(HDKGoodsDetail goods) {
+        if (goods == null)
+            return null;
+        return CommonGoodsFactory.create(TaoBaoGoodsFactory.create(goods));
+    }
+
+}

--
Gitblit v1.8.0