| | |
| | | package com.yeshi.fanli.util.factory.goods;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Arrays;
|
| | |
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.goods.PullNewGoods;
|
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.goods.facade.entity.taobao.haodanku.HDKGoodsDetail;
|
| | | import org.yeshi.utils.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | public class TaoBaoGoodsFactory {
|
| | |
|
| | | /**
|
| | | * 好单库商品转换
|
| | | * @param hdkGoods
|
| | | * @return
|
| | | */
|
| | | public static TaoBaoGoodsBrief create(HDKGoodsDetail hdkGoods) {
|
| | | if (hdkGoods == null)
|
| | | return null;
|
| | |
|
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief();
|
| | | goods.setAuctionId(hdkGoods.getItemid());
|
| | | goods.setTitle(hdkGoods.getItemtitle());
|
| | | goods.setPictUrl(TbImgUtil.getTBSize320Img((hdkGoods.getItempic())));
|
| | | goods.setZkPrice(new BigDecimal(hdkGoods.getItemprice() + ""));
|
| | | goods.setBiz30day(hdkGoods.getItemsale());
|
| | | goods.setTkRate(BigDecimal.valueOf(hdkGoods.getTkrates()));
|
| | | goods.setState(0);
|
| | | |
| | | // 图片列表
|
| | | String taobao_image = hdkGoods.getTaobao_image();
|
| | | if (!StringUtil.isNullOrEmpty(taobao_image)) {
|
| | | goods.setImgList(Arrays.asList(taobao_image.split(",")));
|
| | | }
|
| | | |
| | | // 券信息
|
| | | if (hdkGoods.getCouponmoney() != null && hdkGoods.getCouponmoney() > 0) {
|
| | | goods.setCouponAmount(BigDecimal.valueOf(hdkGoods.getCouponmoney()));
|
| | | |
| | | if (hdkGoods.getCoupon_condition() != null) {
|
| | | BigDecimal couponCondition = new BigDecimal(hdkGoods.getCoupon_condition());
|
| | | goods.setCouponStartFee(couponCondition);
|
| | | if (couponCondition.compareTo(new BigDecimal(0)) > 0)
|
| | | goods.setCouponInfo(String.format("满%s元减%s元", MoneyBigDecimalUtil.getWithNoZera(couponCondition)+ "",
|
| | | MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount())+ ""));
|
| | | else
|
| | | goods.setCouponInfo(String.format("%s元无条件券", goods.getCouponAmount() + ""));
|
| | | |
| | | }
|
| | | goods.setCouponLink(hdkGoods.getCouponurl());
|
| | | goods.setCouponLeftCount(hdkGoods.getCouponsurplus());
|
| | | goods.setCouponTotalCount(hdkGoods.getCouponnum());
|
| | | }
|
| | | |
| | | // 店铺
|
| | | goods.setShopTitle(hdkGoods.getShopname());
|
| | | if ("B".equalsIgnoreCase(hdkGoods.getShoptype()))
|
| | | goods.setUserType(1); // 天猫
|
| | | else
|
| | | goods.setUserType(0); // 淘宝
|
| | | |
| | | return goods;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 好单库商品转换
|
| | | * @param hdkGoods
|
| | | * @return
|
| | | */
|
| | | public static TaoBaoGoodsBrief create(PullNewGoods hdkGoods) {
|
| | | if (hdkGoods == null)
|
| | | return null;
|
| | |
|
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief();
|
| | | goods.setAuctionId(hdkGoods.getItemid());
|
| | | goods.setTitle(hdkGoods.getItemtitle());
|
| | | goods.setPictUrl(TbImgUtil.getTBSize320Img((hdkGoods.getItempic())));
|
| | | goods.setZkPrice(new BigDecimal(hdkGoods.getItemprice() + ""));
|
| | | goods.setBiz30day(hdkGoods.getItemsale());
|
| | | goods.setTkRate(BigDecimal.valueOf(hdkGoods.getTkrates()));
|
| | | goods.setState(0);
|
| | | |
| | | // 图片列表
|
| | | String taobao_image = hdkGoods.getTaobao_image();
|
| | | if (!StringUtil.isNullOrEmpty(taobao_image)) {
|
| | | goods.setImgList(Arrays.asList(taobao_image.split(",")));
|
| | | }
|
| | | |
| | | // 券信息
|
| | | if (hdkGoods.getCouponmoney() != null && hdkGoods.getCouponmoney() > 0) {
|
| | | goods.setCouponAmount(BigDecimal.valueOf(hdkGoods.getCouponmoney()));
|
| | | |
| | | if (hdkGoods.getCoupon_condition() != null) {
|
| | | BigDecimal couponCondition = new BigDecimal(hdkGoods.getCoupon_condition());
|
| | | goods.setCouponStartFee(couponCondition);
|
| | | if (couponCondition.compareTo(new BigDecimal(0)) > 0)
|
| | | goods.setCouponInfo(String.format("满%s元减%s元", MoneyBigDecimalUtil.getWithNoZera(couponCondition)+ "",
|
| | | MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount())+ ""));
|
| | | else
|
| | | goods.setCouponInfo(String.format("%s元无条件券", goods.getCouponAmount() + ""));
|
| | | |
| | | }
|
| | | goods.setCouponLink(hdkGoods.getCouponurl());
|
| | | goods.setCouponLeftCount(hdkGoods.getCouponsurplus());
|
| | | goods.setCouponTotalCount(hdkGoods.getCouponnum());
|
| | | }
|
| | | |
| | | // 店铺
|
| | | goods.setShopTitle(hdkGoods.getShopname());
|
| | | if ("B".equalsIgnoreCase(hdkGoods.getShoptype()))
|
| | | goods.setUserType(1); // 天猫
|
| | | else
|
| | | goods.setUserType(0); // 淘宝
|
| | | |
| | | return goods;
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | | package com.yeshi.fanli.util.factory.goods; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | |
| | | import org.yeshi.utils.taobao.TbImgUtil; |
| | | |
| | | import com.yeshi.fanli.entity.goods.PullNewGoods; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.goods.facade.entity.taobao.haodanku.HDKGoodsDetail; |
| | | import org.yeshi.utils.MoneyBigDecimalUtil; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | |
| | | public class TaoBaoGoodsFactory { |
| | | |
| | | /** |
| | | * 好单库商品转换 |
| | | * @param hdkGoods |
| | | * @return |
| | | */ |
| | | public static TaoBaoGoodsBrief create(HDKGoodsDetail hdkGoods) { |
| | | if (hdkGoods == null) |
| | | return null; |
| | | |
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); |
| | | goods.setAuctionId(hdkGoods.getItemid()); |
| | | goods.setTitle(hdkGoods.getItemtitle()); |
| | | goods.setPictUrl(TbImgUtil.getTBSize320Img((hdkGoods.getItempic()))); |
| | | goods.setZkPrice(new BigDecimal(hdkGoods.getItemprice() + "")); |
| | | goods.setBiz30day(hdkGoods.getItemsale()); |
| | | goods.setTkRate(BigDecimal.valueOf(hdkGoods.getTkrates())); |
| | | goods.setState(0); |
| | | |
| | | // 图片列表 |
| | | String taobao_image = hdkGoods.getTaobao_image(); |
| | | if (!StringUtil.isNullOrEmpty(taobao_image)) { |
| | | goods.setImgList(Arrays.asList(taobao_image.split(","))); |
| | | } |
| | | |
| | | // 券信息 |
| | | if (hdkGoods.getCouponmoney() != null && hdkGoods.getCouponmoney() > 0) { |
| | | goods.setCouponAmount(BigDecimal.valueOf(hdkGoods.getCouponmoney())); |
| | | |
| | | if (hdkGoods.getCoupon_condition() != null) { |
| | | BigDecimal couponCondition = new BigDecimal(hdkGoods.getCoupon_condition()); |
| | | goods.setCouponStartFee(couponCondition); |
| | | if (couponCondition.compareTo(new BigDecimal(0)) > 0) |
| | | goods.setCouponInfo(String.format("满%s元减%s元", MoneyBigDecimalUtil.getWithNoZera(couponCondition)+ "", |
| | | MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount())+ "")); |
| | | else |
| | | goods.setCouponInfo(String.format("%s元无条件券", goods.getCouponAmount() + "")); |
| | | } |
| | | goods.setCouponLink(hdkGoods.getCouponurl()); |
| | | if(hdkGoods.getCouponsurplus()!=null) { |
| | | goods.setCouponLeftCount(hdkGoods.getCouponsurplus()); |
| | | } |
| | | if(hdkGoods.getCouponnum()!=null){ |
| | | goods.setCouponTotalCount(hdkGoods.getCouponnum()); |
| | | } |
| | | } |
| | | |
| | | // 店铺 |
| | | goods.setShopTitle(hdkGoods.getShopname()); |
| | | if ("B".equalsIgnoreCase(hdkGoods.getShoptype())) |
| | | goods.setUserType(1); // 天猫 |
| | | else |
| | | goods.setUserType(0); // 淘宝 |
| | | |
| | | return goods; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 好单库商品转换 |
| | | * @param hdkGoods |
| | | * @return |
| | | */ |
| | | public static TaoBaoGoodsBrief create(PullNewGoods hdkGoods) { |
| | | if (hdkGoods == null) |
| | | return null; |
| | | |
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); |
| | | goods.setAuctionId(hdkGoods.getItemid()); |
| | | goods.setTitle(hdkGoods.getItemtitle()); |
| | | goods.setPictUrl(TbImgUtil.getTBSize320Img((hdkGoods.getItempic()))); |
| | | goods.setZkPrice(new BigDecimal(hdkGoods.getItemprice() + "")); |
| | | goods.setBiz30day(hdkGoods.getItemsale()); |
| | | goods.setTkRate(BigDecimal.valueOf(hdkGoods.getTkrates())); |
| | | goods.setState(0); |
| | | |
| | | // 图片列表 |
| | | String taobao_image = hdkGoods.getTaobao_image(); |
| | | if (!StringUtil.isNullOrEmpty(taobao_image)) { |
| | | goods.setImgList(Arrays.asList(taobao_image.split(","))); |
| | | } |
| | | |
| | | // 券信息 |
| | | if (hdkGoods.getCouponmoney() != null && hdkGoods.getCouponmoney() > 0) { |
| | | goods.setCouponAmount(BigDecimal.valueOf(hdkGoods.getCouponmoney())); |
| | | |
| | | if (hdkGoods.getCoupon_condition() != null) { |
| | | BigDecimal couponCondition = new BigDecimal(hdkGoods.getCoupon_condition()); |
| | | goods.setCouponStartFee(couponCondition); |
| | | if (couponCondition.compareTo(new BigDecimal(0)) > 0) |
| | | goods.setCouponInfo(String.format("满%s元减%s元", MoneyBigDecimalUtil.getWithNoZera(couponCondition)+ "", |
| | | MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount())+ "")); |
| | | else |
| | | goods.setCouponInfo(String.format("%s元无条件券", goods.getCouponAmount() + "")); |
| | | |
| | | } |
| | | goods.setCouponLink(hdkGoods.getCouponurl()); |
| | | goods.setCouponLeftCount(hdkGoods.getCouponsurplus()); |
| | | goods.setCouponTotalCount(hdkGoods.getCouponnum()); |
| | | } |
| | | |
| | | // 店铺 |
| | | goods.setShopTitle(hdkGoods.getShopname()); |
| | | if ("B".equalsIgnoreCase(hdkGoods.getShoptype())) |
| | | goods.setUserType(1); // 天猫 |
| | | else |
| | | goods.setUserType(0); // 淘宝 |
| | | |
| | | return goods; |
| | | } |
| | | |
| | | |
| | | } |