From 4d7db6fd66f5b2c9cae9954e46314f9711ce1e8f Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 06 十一月 2019 18:51:40 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div
---
fanli/src/main/java/com/yeshi/fanli/util/factory/CommonGoodsFactory.java | 146 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 146 insertions(+), 0 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 eb3ce8b..ad88ebb 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,7 +1,18 @@
package com.yeshi.fanli.util.factory;
+import java.math.BigDecimal;
+
+import com.alibaba.fastjson.JSONObject;
+import com.yeshi.fanli.dto.common.GoodsOtherInfoDTO;
+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.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;
public class CommonGoodsFactory {
@@ -44,4 +55,139 @@
return cg;
}
+
+ /**
+ * 娣樺疂鍟嗗搧鏋勯��
+ *
+ * @param goods
+ * @return
+ */
+ public static CommonGoods create(JDGoods goods) {
+ if (goods == null)
+ return null;
+
+ CommonGoods cg = new CommonGoods();
+ JDCouponInfo couponInfo = goods.getCouponInfo();
+ 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));
+ }
+ }
+
+ 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());
+
+ // 淇濈暀瀛楁
+ 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);
+ return cg;
+ }
+
}
--
Gitblit v1.8.0