From dd6a31aae79b35ccf0e006704a4d9e1d950c57d6 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期六, 23 五月 2020 09:55:58 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div

---
 fanli/src/main/java/com/yeshi/fanli/util/factory/CommonGoodsFactory.java |   84 ++++++++++++++++++++++++++++++-----------
 1 files changed, 61 insertions(+), 23 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 9c01dc5..1104649 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
@@ -10,6 +10,7 @@
 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.vip.goods.VIPGoodsInfo;
 import com.yeshi.fanli.entity.goods.CommonGoods;
 import com.yeshi.fanli.entity.jd.JDGoods;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -55,8 +56,7 @@
 		cg.setVideoUrl(null);
 		cg.setState(goods.getState());
 		cg.setMaterialLibType(goods.getMaterialLibType());
-		
-		
+
 		// 鍒嗙被淇℃伅
 		CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
 		Integer rootCatId = goods.getRootCatId();
@@ -64,18 +64,17 @@
 			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;
 	}
 
-	
 	/**
 	 * 娣樺疂鍟嗗搧鏋勯��
 	 * 
@@ -103,44 +102,43 @@
 			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.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.setPinGouInfo(goods.getPinGouInfo()); // 鎷艰喘淇℃伅
 		other.setIsFreeShipping(goods.getIsFreeShipping()); // 鏄惁鍖呴偖
 		cg.setOtherInfo(JSONObject.toJSON(other).toString());
-		
-		
+
 		// 鍒嗙被淇℃伅
 		JDCategoryInfo categoryJD = goods.getCategoryInfo();
 		if (categoryJD != null) {
@@ -153,14 +151,13 @@
 			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;
@@ -193,7 +190,7 @@
 		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";
@@ -203,11 +200,11 @@
 				salesTip = salesTip.substring(0, indexOf);
 			}
 		}
-		
+
 		int totalSales = 0;
 		if (salesTip.contains("涓�")) {
 			salesTip = salesTip.substring(0, salesTip.indexOf("涓�"));
-			totalSales= (int) (Float.parseFloat(salesTip) * 10000);
+			totalSales = (int) (Float.parseFloat(salesTip) * 10000);
 		} else {
 			totalSales = Integer.parseInt(salesTip);
 		}
@@ -223,14 +220,55 @@
 		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_PDD);
+		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_PDD);
+		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());
+
 		return cg;
 	}
 

--
Gitblit v1.8.0