From 573c491b4a1ba60e12a5678a01c1546c0077c1ee Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 30 七月 2019 09:07:42 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- fanli/src/main/java/com/yeshi/fanli/util/factory/CommonGoodsFactory.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 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 c467098..bcf29cf 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,11 @@ package com.yeshi.fanli.util.factory; +import java.math.BigDecimal; + +import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; import com.yeshi.fanli.entity.goods.CommonGoods; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; +import com.yeshi.fanli.util.MoneyBigDecimalUtil; public class CommonGoodsFactory { @@ -40,6 +44,54 @@ cg.setVideoCover(null); cg.setVideoUrl(null); cg.setState(goods.getState()); + cg.setMaterialLibType(goods.getMaterialLibType()); + 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.getMinNormalPrice()), new BigDecimal(100))); + cg.setSales(Integer.parseInt(goods.getSoldQuantity() + "")); + cg.setRate(MoneyBigDecimalUtil.div(new BigDecimal(goods.getPromotionRate()), new BigDecimal(10))); + cg.setSellerId(goods.getMallId()); + cg.setSellerName(goods.getMallName()); + cg.setShopType(goods.getMerchantType()); + 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