| | |
| | | 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.vip.goods.VIPGoodsInfo; |
| | | import com.yeshi.fanli.entity.goods.CommonGoods; |
| | | import com.yeshi.fanli.entity.jd.JDGoods; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import org.yeshi.utils.MoneyBigDecimalUtil; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.factory.goods.TaoBaoGoodsFactory; |
| | | import com.yeshi.fanli.util.jd.JDUtil; |
| | | 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 { |
| | | |
| | |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | 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(Long.parseLong(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)); |
| | | } |
| | | |
| | | } |