yujian
2020-05-23 dd6a31aae79b35ccf0e006704a4d9e1d950c57d6
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;
@@ -56,7 +57,6 @@
      cg.setState(goods.getState());
      cg.setMaterialLibType(goods.getMaterialLibType());
      
      // 分类信息
      CategoryInfoDTO categoryInfo = new CategoryInfoDTO();
      Integer rootCatId = goods.getRootCatId();
@@ -74,7 +74,6 @@
      
      return cg;
   }
   
   /**
    * 淘宝商品构造
@@ -140,7 +139,6 @@
      other.setIsFreeShipping(goods.getIsFreeShipping()); // 是否包邮
      cg.setOtherInfo(JSONObject.toJSON(other).toString());
      
      // 分类信息
      JDCategoryInfo categoryJD = goods.getCategoryInfo();
      if (categoryJD != null) {
@@ -159,7 +157,6 @@
      cg.setVideoUrl(null);
      return cg;
   }
   
   public static CommonGoods create(PDDGoodsDetail goods) {
      if (goods == null)
@@ -230,6 +227,47 @@
      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;
   }