| | |
| | |
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.dto.common.GoodsOtherInfoDTO;
|
| | | import com.yeshi.fanli.dto.jd.JDCouponInfo;
|
| | | import com.yeshi.fanli.dto.jd.JDPingouInfo;
|
| | | 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.vo.goods.GoodsDetailVO;
|
| | | import com.yeshi.fanli.vo.goods.MoneyInfoVO;
|
| | | import com.yeshi.fanli.vo.goods.ShopInfoVO;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 商品加工
|
| | |
| | | /**
|
| | | * 淘宝商品组织
|
| | | *
|
| | | * @param goods 淘宝商品
|
| | | * @param goods
|
| | | * 淘宝商品
|
| | | * @param pid
|
| | | * @param fanLiRate 返利比例
|
| | | * @param fanLiRate
|
| | | * 返利比例
|
| | | * @return
|
| | | */
|
| | | public static GoodsDetailVO convertCommonGoods(CommonGoods goods, String pid, BigDecimal fanLiRate,
|
| | | BigDecimal shareRate) {
|
| | | public static GoodsDetailVO convertCommonGoods(CommonGoods goods, ConfigParamsDTO params) {
|
| | | GoodsDetailVO goodsInfo = new GoodsDetailVO();
|
| | | goodsInfo.setGoodsId(goods.getGoodsId());
|
| | | goodsInfo.setTitle(goods.getTitle());
|
| | | |
| | |
|
| | | Integer shopType = goods.getShopType();
|
| | | if (shopType == null) { |
| | | if (shopType == null) {
|
| | | goodsInfo.setShopType(10); // 淘宝
|
| | | } else if (shopType == 1) {
|
| | | goodsInfo.setPriceName("淘宝价");
|
| | | } else if (shopType == 1) {
|
| | | goodsInfo.setShopType(10); // 淘宝
|
| | | goodsInfo.setPriceName("淘宝价");
|
| | | } else if (shopType == 2) {
|
| | | goodsInfo.setShopType(11); // 天猫
|
| | | goodsInfo.setPriceName("天猫价");
|
| | | } else {
|
| | | goodsInfo.setShopType(goods.getShopType());
|
| | | }
|
| | | |
| | |
|
| | | Integer goodsType = goods.getGoodsType();
|
| | | if (goodsType == null) {
|
| | | goodsType = Constant.SOURCE_TYPE_TAOBAO;
|
| | | }
|
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | |
|
| | | GoodsOtherInfoDTO otherDTO = null;
|
| | | String otherInfo = goods.getOtherInfo();
|
| | | if (!StringUtil.isNullOrEmpty(otherInfo)) {
|
| | | JSONObject json = JSONObject.fromObject(otherInfo);
|
| | | otherDTO = (GoodsOtherInfoDTO) JSONObject.toBean(json, GoodsOtherInfoDTO.class);
|
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | // 月销量
|
| | | goodsInfo.setSalesType(1);
|
| | |
|
| | | Integer isFreeShipping = otherDTO.getIsFreeShipping();
|
| | | if (isFreeShipping != null && isFreeShipping == 1) {
|
| | | goodsInfo.setBaoyou(true);
|
| | | }
|
| | |
|
| | | List<ClientTextStyleVO> labels = goodsInfo.getLabels();
|
| | | // 自营
|
| | | String owner = otherDTO.getOwner();
|
| | | if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) {
|
| | | if (labels == null) {
|
| | | labels = new ArrayList<ClientTextStyleVO>();
|
| | | }
|
| | | ClientTextStyleVO textStyleVO = new ClientTextStyleVO();
|
| | | textStyleVO.setContent("京东自营");
|
| | | textStyleVO.setColor("#E42219");
|
| | | labels.add(textStyleVO);
|
| | | }
|
| | | // 拼团价
|
| | | JDPingouInfo pinGouInfo = otherDTO.getPinGouInfo();
|
| | | if (pinGouInfo != null) {
|
| | | goods.setPrice(pinGouInfo.getPingouPrice());
|
| | | goodsInfo.setPriceName("拼购价");
|
| | |
|
| | | if (labels == null) {
|
| | | labels = new ArrayList<ClientTextStyleVO>();
|
| | | }
|
| | | ClientTextStyleVO textStyleVO = new ClientTextStyleVO();
|
| | | textStyleVO.setContent("拼购");
|
| | | textStyleVO.setColor("#E42219");
|
| | | labels.add(textStyleVO);
|
| | | } else {
|
| | | goodsInfo.setPriceName("京东价");
|
| | | }
|
| | | goodsInfo.setLabels(labels);
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | goodsInfo.setSalesType(4); // 总销量
|
| | | goodsInfo.setPriceName("拼团价");
|
| | | goodsInfo.setBaoyou(true);
|
| | | } else {
|
| | | goodsInfo.setSalesType(1); // 月销量
|
| | | goodsInfo.setBaoyou(true);
|
| | | }
|
| | | |
| | |
|
| | | goodsInfo.setGoodsType(goodsType);
|
| | | goodsInfo.setZkPrice(goods.getPrice());
|
| | | goodsInfo.setState(goods.getState());
|
| | | Integer state = goods.getState();
|
| | | if (state == null) {
|
| | | goodsInfo.setState(0);
|
| | | } else {
|
| | | goodsInfo.setState(goods.getState());
|
| | | }
|
| | | goodsInfo.setSalesCount(TaoBaoUtil.getSaleCount(goods.getSales()));
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | |
| | | } else {
|
| | | goodsInfo.setPicUrl(goods.getPicture());
|
| | | }
|
| | | |
| | |
|
| | | // 资金信息
|
| | | MoneyInfoVO moneyInfoVO = new MoneyInfoVO();
|
| | | moneyInfoVO.setMoneyType(1); // 默认显示:返 ¥6.6
|
| | | moneyInfoVO.setFanliMoney(CommonGoodsUtil.getCommissionInfo(goods, fanLiRate));
|
| | | moneyInfoVO.setShareMoney(CommonGoodsUtil.getCommissionInfo(goods, shareRate));
|
| | |
|
| | | BigDecimal commission = CommonGoodsUtil.getCommission(goods, params.getFanLiRate());
|
| | | moneyInfoVO.setFanliMoney("¥" + commission);
|
| | | moneyInfoVO.setMaxMoney("¥" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate())));
|
| | | moneyInfoVO.setShareMoney(CommonGoodsUtil.getCommissionInfo(goods, params.getShareRate()));
|
| | | goodsInfo.setMoneyInfo(moneyInfoVO);
|
| | |
|
| | | // 券信息
|
| | | if (goods.getCouponAmount().compareTo(BigDecimal.valueOf(0)) > 0) {
|
| | | if (goods.getCouponAmount() != null && goods.getCouponAmount().compareTo(BigDecimal.valueOf(0)) > 0) {
|
| | | // 计算券后价
|
| | | BigDecimal sub = goods.getPrice().subtract(goods.getCouponStartPrice());
|
| | | if (sub.compareTo(BigDecimal.valueOf(0)) >= 0) {
|
| | |
| | | goodsInfo.setCouponInfo(coupon);
|
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | // 店铺信息
|
| | | if (!StringUtil.isNullOrEmpty(goods.getSellerName()) && goods.getSellerId() != null) {
|
| | | ShopInfoVO shop = new ShopInfoVO();
|
| | | shop.setShopName(goods.getSellerName());
|
| | | // 店铺信息
|
| | | if (!StringUtil.isNullOrEmpty(goods.getSellerName())) {
|
| | | ShopInfoVO shop = new ShopInfoVO();
|
| | | shop.setShopName(goods.getSellerName());
|
| | |
|
| | | if (goods.getSellerId() != null)
|
| | | shop.setId(goods.getSellerId().toString());
|
| | | goodsInfo.setShopInfo(shop);
|
| | |
|
| | | if (shopType == null || shopType == 0) {
|
| | | shop.setUserType(10);
|
| | | } else if (shopType == 1) {
|
| | | shop.setUserType(11);
|
| | | } else {
|
| | | shop.setUserType(goods.getShopType());
|
| | | }
|
| | |
|
| | | goodsInfo.setShopInfo(shop);
|
| | | }
|
| | |
|
| | | // if (Constant.IS_TEST) {
|
| | | // // 添加标签
|
| | | // List<ClientTextStyleVO> labels = goodsInfo.getLabels();
|
| | | // if (labels == null)
|
| | | // labels = new ArrayList<>();
|
| | | //
|
| | | // labels.add(new ClientTextStyleVO("预售", "#FF2B4E"));
|
| | | // labels.add(new ClientTextStyleVO("爆款", "#FF2B4E"));
|
| | | // labels.add(new ClientTextStyleVO("超级划算", "#FF2B4E"));
|
| | | // goodsInfo.setLabels(labels);
|
| | | // }
|
| | |
|
| | | return goodsInfo;
|
| | | }
|
| | |
| | | /**
|
| | | * 淘宝商品组织
|
| | | *
|
| | | * @param goods 淘宝商品
|
| | | * @param goods
|
| | | * 淘宝商品
|
| | | * @param pid
|
| | | * @param fanLiRate 返利比例
|
| | | * @param fanLiRate
|
| | | * 返利比例
|
| | | * @return
|
| | | */
|
| | | public static GoodsDetailVO convertTaoBaoGoodsBriefExtra(TaoBaoGoodsBriefExtra goods, BigDecimal fanLiRate,
|
| | | BigDecimal shareRate) {
|
| | | public static GoodsDetailVO convertTaoBaoGoodsBriefExtra(TaoBaoGoodsBriefExtra goods, ConfigParamsDTO params) {
|
| | | GoodsDetailVO goodsInfo = new GoodsDetailVO();
|
| | | goodsInfo.setBaoyou(true);
|
| | | goodsInfo.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | goodsInfo.setGoodsId(goods.getAuctionId());
|
| | | goodsInfo.setTitle(goods.getTitle());
|
| | |
| | | goodsInfo.setPicUrl(goods.getPictUrl());
|
| | |
|
| | | Integer shopType = goods.getUserType();
|
| | | if (shopType != null && shopType == 2) {
|
| | | if (shopType != null && shopType == 1) {
|
| | | goodsInfo.setShopType(11); // 天猫
|
| | | goodsInfo.setPriceName("天猫价");
|
| | | } else {
|
| | | goodsInfo.setShopType(10); // 淘宝
|
| | | goodsInfo.setPriceName("淘宝价");
|
| | | }
|
| | |
|
| | | // 资金信息
|
| | | MoneyInfoVO moneyInfoVO = new MoneyInfoVO();
|
| | | moneyInfoVO.setMoneyType(1); // 默认显示:返 ¥6.6
|
| | | |
| | |
|
| | | if (goods.getTkRate() == null) {
|
| | | TaoBaoHongBaoInfo taoBaoHongBaoInfo = goods.getTaoBaoHongBaoInfo();
|
| | | moneyInfoVO.setFanliMoney("¥"+ taoBaoHongBaoInfo.getHongbao());
|
| | | moneyInfoVO.setShareMoney("¥"+ taoBaoHongBaoInfo.getHongbao());
|
| | | moneyInfoVO.setFanliMoney("¥" + taoBaoHongBaoInfo.getHongbao());
|
| | | moneyInfoVO.setShareMoney("¥" + taoBaoHongBaoInfo.getHongbao());
|
| | | moneyInfoVO.setMaxMoney("¥" + taoBaoHongBaoInfo.getHongbao()
|
| | | .add(MoneyBigDecimalUtil.mul(taoBaoHongBaoInfo.getHongbao(), params.getMaxRewardRate())));
|
| | | } else {
|
| | | moneyInfoVO.setFanliMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods, fanLiRate));
|
| | | moneyInfoVO.setShareMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods, shareRate));
|
| | | BigDecimal commission = TaoBaoUtil.getGoodsHongBaoMoney(goods, params.getFanLiRate());
|
| | | moneyInfoVO.setFanliMoney("¥" + commission);
|
| | | moneyInfoVO
|
| | | .setMaxMoney("¥" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate())));
|
| | | moneyInfoVO.setShareMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods, params.getShareRate()));
|
| | | }
|
| | | goodsInfo.setMoneyInfo(moneyInfoVO);
|
| | |
|
| | |
| | |
|
| | | // 店铺信息
|
| | | String shopTitle = goods.getShopTitle();
|
| | | Long sellerId = goods.getSellerId();
|
| | | if (!StringUtil.isNullOrEmpty(shopTitle) && sellerId != null) {
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(shopTitle)) {
|
| | | ShopInfoVO shop = new ShopInfoVO();
|
| | | shop.setShopName(shopTitle);
|
| | | shop.setId(goods.getSellerId().toString());
|
| | |
|
| | | Long sellerId = goods.getSellerId();
|
| | | if (sellerId != null)
|
| | | shop.setId(goods.getSellerId().toString());
|
| | |
|
| | | if (shopType != null && shopType == 1) {
|
| | | shop.setUserType(11);
|
| | | } else {
|
| | | shop.setUserType(10);
|
| | | }
|
| | | goodsInfo.setShopInfo(shop);
|
| | | }
|
| | |
|
| | | // if (Constant.IS_TEST) {
|
| | | // // 添加标签
|
| | | // List<ClientTextStyleVO> labels = goodsInfo.getLabels();
|
| | | // if (labels == null)
|
| | | // labels = new ArrayList<>();
|
| | | //
|
| | | // labels.add(new ClientTextStyleVO("预售", "#FF2B4E"));
|
| | | // labels.add(new ClientTextStyleVO("爆款", "#FF2B4E"));
|
| | | // labels.add(new ClientTextStyleVO("超级划算", "#FF2B4E"));
|
| | | // goodsInfo.setLabels(labels);
|
| | | // }
|
| | |
|
| | | return goodsInfo;
|
| | | }
|
| | |
| | | /**
|
| | | * 淘宝商品组织
|
| | | *
|
| | | * @param goods 淘宝商品
|
| | | * @param goods
|
| | | * 淘宝商品
|
| | | * @param pid
|
| | | * @param fanLiRate 返利比例
|
| | | * @param fanLiRate
|
| | | * 返利比例
|
| | | * @return
|
| | | */
|
| | | public static GoodsDetailVO convertTaoBao(TaoBaoGoodsBrief goods, String pid, BigDecimal fanLiRate,
|
| | | BigDecimal shareRate) {
|
| | | public static GoodsDetailVO convertTaoBao(TaoBaoGoodsBrief goods, ConfigParamsDTO params) {
|
| | | GoodsDetailVO goodsInfo = new GoodsDetailVO();
|
| | | goodsInfo.setBaoyou(true);
|
| | | goodsInfo.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | goodsInfo.setGoodsId(goods.getAuctionId());
|
| | | goodsInfo.setTitle(goods.getTitle());
|
| | | goodsInfo.setSalesType(1); // 默认月销量
|
| | | goodsInfo.setZkPrice(goods.getZkPrice());
|
| | | |
| | |
|
| | | String provcity = goods.getProvcity();
|
| | | if (!StringUtil.isNullOrEmpty(provcity)) {
|
| | | String[] arr = provcity.split("\\s+");
|
| | | goodsInfo.setProvcity(arr[arr.length - 1]);
|
| | | }
|
| | |
|
| | | List<String> imgList = goods.getImgList();
|
| | | if (imgList != null) {
|
| | | goodsInfo.setImgList(imgList);
|
| | |
| | | imgList.add(goods.getPictUrl());
|
| | | goodsInfo.setImgList(imgList);
|
| | | }
|
| | | |
| | |
|
| | | Integer state = goods.getState();
|
| | | if (state == null) {
|
| | | goodsInfo.setState(0);
|
| | | } else {
|
| | | goodsInfo.setState(state);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | goodsInfo.setSalesCount(TaoBaoUtil.getSaleCount(goods.getBiz30day()));
|
| | |
|
| | | // 白底图可能有错误
|
| | | // https://img.alicdn.com/bao/uploaded/TB1LVqmVZbpK1RjSZFyXXX_qFXa.png
|
| | | if (!StringUtil.isNullOrEmpty(goods.getPictUrlWhite())) {
|
| | | goodsInfo.setPicUrl(TbImgUtil.getTBSize320Img(goods.getPictUrlWhite()));
|
| | | } else {
|
| | |
| | | }
|
| | |
|
| | | Integer shopType = goods.getUserType();
|
| | | if (shopType != null && shopType == 2) {
|
| | | if (shopType != null && shopType == 1) {
|
| | | goodsInfo.setShopType(11); // 天猫
|
| | | goodsInfo.setPriceName("天猫价");
|
| | | } else {
|
| | | goodsInfo.setShopType(10); // 淘宝
|
| | | goodsInfo.setPriceName("淘宝价");
|
| | | }
|
| | |
|
| | | // 资金信息
|
| | | MoneyInfoVO moneyInfoVO = new MoneyInfoVO();
|
| | | moneyInfoVO.setMoneyType(1); // 默认显示:返 ¥6.6
|
| | | moneyInfoVO.setFanliMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods, fanLiRate));
|
| | | moneyInfoVO.setShareMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods, shareRate));
|
| | | BigDecimal commission = TaoBaoUtil.getGoodsHongBaoMoney(goods, params.getFanLiRate());
|
| | | moneyInfoVO.setFanliMoney("¥" + commission);
|
| | | moneyInfoVO.setMaxMoney("¥" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate())));
|
| | | moneyInfoVO.setShareMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods, params.getShareRate()));
|
| | | goodsInfo.setMoneyInfo(moneyInfoVO);
|
| | |
|
| | | // 券信息
|
| | |
| | | if (goods.getCouponEffectiveEndTime() != null) {
|
| | | coupon.setEndTime(goods.getCouponEffectiveEndTime().replace("-", "."));
|
| | | }
|
| | | |
| | |
|
| | | if (goods.getCouponEffectiveStartTime() != null) {
|
| | | coupon.setStartTime(goods.getCouponEffectiveStartTime().replace("-", "."));
|
| | | } |
| | | |
| | | coupon.setLink(TaoBaoCouponUtil.getCoupleUrl(goods.getCouponActivityId(), pid, goods.getAuctionId() + ""));
|
| | | }
|
| | |
|
| | | coupon.setLink(TaoBaoCouponUtil.getCoupleUrl(goods.getCouponActivityId(), null, goods.getAuctionId() + ""));
|
| | | coupon.setStartFee(goods.getCouponStartFee());
|
| | |
|
| | | goodsInfo.setHasCoupon(true);
|
| | |
| | | }
|
| | |
|
| | | // 店铺信息
|
| | | if (!StringUtil.isNullOrEmpty(goods.getShopTitle()) && goods.getSellerId() != null) {
|
| | | if (!StringUtil.isNullOrEmpty(goods.getShopTitle())) {
|
| | | ShopInfoVO shop = new ShopInfoVO();
|
| | | shop.setShopName(goods.getShopTitle());
|
| | | shop.setId(goods.getSellerId().toString());
|
| | |
|
| | | if (goods.getSellerId() != null)
|
| | | shop.setId(goods.getSellerId().toString());
|
| | |
|
| | | if (shopType != null && shopType == 1) {
|
| | | shop.setUserType(11);
|
| | | } else {
|
| | | shop.setUserType(10);
|
| | | }
|
| | |
|
| | | goodsInfo.setShopInfo(shop);
|
| | | }
|
| | |
|
| | | if (TaoBaoUtil.isYUShou(goods)) {// 预售商品
|
| | | goodsInfo = loadYuShouInfo(goodsInfo, goods, null, params.getFanLiRate(), params.getShareRate());
|
| | | }
|
| | |
|
| | | if (Constant.IS_TEST) {
|
| | | // 添加标签
|
| | | List<ClientTextStyleVO> labels = goodsInfo.getLabels();
|
| | | if (labels == null)
|
| | | labels = new ArrayList<>();
|
| | |
|
| | | labels.add(new ClientTextStyleVO("预售", "#FF2B4E"));
|
| | | labels.add(new ClientTextStyleVO("爆款", "#FF2B4E"));
|
| | | labels.add(new ClientTextStyleVO("超级划算", "#FF2B4E"));
|
| | | goodsInfo.setLabels(labels);
|
| | | }
|
| | |
|
| | | return goodsInfo;
|
| | | }
|
| | |
|
| | | private static GoodsDetailVO loadYuShouInfo(GoodsDetailVO goodsInfo, TaoBaoGoodsBrief goods, String pid,
|
| | | BigDecimal fanLiRate, BigDecimal shareRate) {
|
| | |
|
| | | if (goodsInfo != null && goods != null) {
|
| | | // 添加标签
|
| | | if (goodsInfo.getLabels() == null)
|
| | | goodsInfo.setLabels(new ArrayList<>());
|
| | | goodsInfo.getLabels().add(new ClientTextStyleVO("预售", "#FF2B4E"));
|
| | | }
|
| | | return goodsInfo;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 淘宝商品组织
|
| | | *
|
| | | * @param goods 淘宝商品
|
| | | * @param goods
|
| | | * 淘宝商品
|
| | | * @param pid
|
| | | * @param fanLiRate 返利比例
|
| | | * @param fanLiRate
|
| | | * 返利比例
|
| | | * @return
|
| | | */
|
| | | public static GoodsDetailVO convertJDGoods(JDGoods goods, String pid, BigDecimal fanLiRate, BigDecimal shareRate) {
|
| | | public static GoodsDetailVO convertJDGoods(JDGoods goods, ConfigParamsDTO params) {
|
| | | GoodsDetailVO goodsInfo = new GoodsDetailVO();
|
| | | goodsInfo.setGoodsType(Constant.SOURCE_TYPE_JD);
|
| | | goodsInfo.setGoodsId(goods.getSkuId());
|
| | | goodsInfo.setTitle(goods.getSkuName());
|
| | | goodsInfo.setSalesType(1); // 默认月销量
|
| | | goodsInfo.setPicUrl(goods.getPicUrl());
|
| | | goodsInfo.setZkPrice(goods.getPrice());
|
| | | goodsInfo.setImgList(goods.getImageList());
|
| | | goodsInfo.setState(0);
|
| | |
|
| | |
| | | }
|
| | | goodsInfo.setSalesCount(salesCountMidea);
|
| | |
|
| | | String owner = goods.getOwner();
|
| | | if (StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) {
|
| | | goodsInfo.setShopType(21); // 京东自营
|
| | | } else {
|
| | | goodsInfo.setShopType(20); // 京东
|
| | | }
|
| | |
|
| | | // 资金信息
|
| | | MoneyInfoVO moneyInfoVO = new MoneyInfoVO();
|
| | | moneyInfoVO.setMoneyType(1); // 默认显示:返 ¥6.6
|
| | | moneyInfoVO.setFanliMoney("¥" + JDUtil.getGoodsFanLiMoney(goods, fanLiRate));
|
| | | moneyInfoVO.setShareMoney("¥" + JDUtil.getGoodsFanLiMoney(goods, shareRate));
|
| | | BigDecimal commission = JDUtil.getGoodsFanLiMoney(goods, params.getFanLiRate());
|
| | | moneyInfoVO.setFanliMoney("¥" + commission);
|
| | | moneyInfoVO.setMaxMoney("¥" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate())));
|
| | | moneyInfoVO.setShareMoney("¥" + JDUtil.getGoodsFanLiMoney(goods, params.getShareRate()));
|
| | | goodsInfo.setMoneyInfo(moneyInfoVO);
|
| | |
|
| | | JDCouponInfo couponInfo = goods.getCouponInfo();
|
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods);
|
| | | if (couponInfo != null) {
|
| | | BigDecimal discount = couponInfo.getDiscount();
|
| | | BigDecimal price = goods.getPrice();
|
| | | // 计算券后价
|
| | | BigDecimal sub = price.subtract(couponInfo.getQuota());
|
| | | if (sub.compareTo(BigDecimal.valueOf(0)) >= 0) {
|
| | | BigDecimal quanPrice = MoneyBigDecimalUtil.sub(price, discount);
|
| | | goodsInfo.setCouponPrice(quanPrice);
|
| | | } else {
|
| | | goodsInfo.setCouponPrice(price);
|
| | | }
|
| | | goodsInfo.setCouponPrice(JDUtil.getQuanPrice(goods));
|
| | |
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
| | | CouponInfoVO coupon = new CouponInfoVO();
|
| | | coupon.setAmount(discount);
|
| | | coupon.setLink(couponInfo.getLink());
|
| | | coupon.setStartFee(couponInfo.getQuota());
|
| | |
|
| | | if (couponInfo.getGetStartTime() != null) {
|
| | | coupon.setStartTime(sdf.format(new Date(couponInfo.getGetStartTime())));
|
| | | } else {
|
| | | coupon.setStartTime(sdf.format(new Date()));
|
| | | }
|
| | |
|
| | | if (couponInfo.getGetEndTime() != null) {
|
| | | coupon.setEndTime(sdf.format(new Date(couponInfo.getGetEndTime())));
|
| | | } else {
|
| | | coupon.setEndTime(sdf.format(new Date()));
|
| | | }
|
| | | |
| | | // TODO
|
| | | // coupon.setLeftCount(leftCount);
|
| | | // coupon.setTotalCount(totalCount);
|
| | | |
| | | coupon.setLink(couponInfo.getLink());
|
| | | coupon.setStartFee(couponInfo.getQuota());
|
| | |
|
| | | goodsInfo.setHasCoupon(true);
|
| | | goodsInfo.setCouponInfo(coupon);
|
| | | }
|
| | |
|
| | | List<ClientTextStyleVO> labels = goodsInfo.getLabels();
|
| | | // 京东自营标签
|
| | | String owner = goods.getOwner();
|
| | | if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) {
|
| | | goodsInfo.setShopType(21); // 京东自营
|
| | | if (labels == null) {
|
| | | labels = new ArrayList<ClientTextStyleVO>();
|
| | | }
|
| | | ClientTextStyleVO textStyleVO = new ClientTextStyleVO();
|
| | | textStyleVO.setContent("京东自营");
|
| | | textStyleVO.setColor("#E42219");
|
| | | labels.add(textStyleVO);
|
| | | } else {
|
| | | goodsInfo.setShopType(20); // 京东
|
| | | }
|
| | |
|
| | | JDPingouInfo pinGouInfo = goods.getPinGouInfo();
|
| | | if (pinGouInfo != null) {
|
| | | goodsInfo.setZkPrice(pinGouInfo.getPingouPrice());
|
| | | goodsInfo.setPriceName("拼购价");
|
| | |
|
| | | if (labels == null) {
|
| | | labels = new ArrayList<ClientTextStyleVO>();
|
| | | }
|
| | | ClientTextStyleVO textStyleVO = new ClientTextStyleVO();
|
| | | textStyleVO.setContent("拼购");
|
| | | textStyleVO.setColor("#E42219");
|
| | | labels.add(textStyleVO);
|
| | | } else {
|
| | | goodsInfo.setZkPrice(goods.getPrice());
|
| | | goodsInfo.setPriceName("京东价");
|
| | | }
|
| | | goodsInfo.setLabels(labels);
|
| | |
|
| | | // 店铺信息
|
| | | // JDShopInfo shopInfo = goods.getShopInfo();
|
| | | // if (shopInfo != null && !StringUtil.isNullOrEmpty(shopInfo.getShopName())) {
|
| | | // ShopInfoVO shop = new ShopInfoVO();
|
| | | // shop.setShopName(shopInfo.getShopName());
|
| | | // shop.setId(shopInfo.getShopId().toString());
|
| | | // goodsInfo.setShopInfo(shop);
|
| | | // }
|
| | | JDShopInfo shopInfo = goods.getShopInfo();
|
| | | if (shopInfo != null && !StringUtil.isNullOrEmpty(shopInfo.getShopName())) {
|
| | | ShopInfoVO shop = new ShopInfoVO();
|
| | | shop.setShopName(shopInfo.getShopName());
|
| | | shop.setId(shopInfo.getShopId().toString());
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) {
|
| | | shop.setUserType(20);
|
| | | } else {
|
| | | shop.setUserType(21);
|
| | | }
|
| | | goodsInfo.setShopInfo(shop);
|
| | | }
|
| | |
|
| | | // 是否包邮
|
| | | Integer isFreeShipping = goods.getIsFreeShipping();
|
| | | if (isFreeShipping != null && isFreeShipping == 1) {
|
| | | goodsInfo.setBaoyou(true);
|
| | | }
|
| | |
|
| | | return goodsInfo;
|
| | | }
|
| | |
| | | /**
|
| | | * 拼多多商品
|
| | | *
|
| | | * @param goods 拼多多商品
|
| | | * @param goods
|
| | | * 拼多多商品
|
| | | * @param pid
|
| | | * @param fanLiRate 返利比例
|
| | | * @param fanLiRate
|
| | | * 返利比例
|
| | | * @return
|
| | | */
|
| | | public static GoodsDetailVO convertPDDGoods(PDDGoodsDetail goods, String pid, BigDecimal fanLiRate,
|
| | | BigDecimal shareRate) {
|
| | | public static GoodsDetailVO convertPDDGoods(PDDGoodsDetail goods, ConfigParamsDTO params) {
|
| | | GoodsDetailVO goodsInfo = new GoodsDetailVO();
|
| | | goodsInfo.setBaoyou(true);
|
| | | goodsInfo.setGoodsType(Constant.SOURCE_TYPE_PDD);
|
| | | goodsInfo.setGoodsId(goods.getGoodsId());
|
| | | goodsInfo.setTitle(goods.getGoodsName());
|
| | | goodsInfo.setSalesType(4); // 总销量
|
| | | goodsInfo.setPicUrl(goods.getGoodsImageUrl());
|
| | | goodsInfo.setZkPrice(new BigDecimal(goods.getMinNormalPrice()));
|
| | | goodsInfo.setPriceName("拼团价");
|
| | | goodsInfo.setPicUrl(goods.getGoodsThumbnailUrl()); // 缩略图
|
| | | goodsInfo.setZkPrice(
|
| | | MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)).setScale(2));
|
| | | goodsInfo.setShopType(30); // 拼多多
|
| | |
|
| | | String[] goodsGalleryUrls = goods.getGoodsGalleryUrls();
|
| | |
| | | }
|
| | |
|
| | | // 总销量
|
| | | String salesCountMidea = null;
|
| | | Long soldQuantity = goods.getSoldQuantity();
|
| | | if (soldQuantity == null)
|
| | | soldQuantity = 0L;
|
| | |
|
| | | if (soldQuantity < 10000) {
|
| | | salesCountMidea = soldQuantity + "";
|
| | | } else {
|
| | | double sales = soldQuantity;
|
| | | salesCountMidea = String.format("%.1f", sales / 10000);
|
| | | salesCountMidea = salesCountMidea + "万";
|
| | | String salesTip = goods.getSalesTip();
|
| | | if (StringUtil.isNullOrEmpty(salesTip)) {
|
| | | salesTip = "0";
|
| | | }
|
| | | goodsInfo.setSalesCount(salesCountMidea);
|
| | | goodsInfo.setSalesCount(salesTip);
|
| | |
|
| | | // 资金信息
|
| | | MoneyInfoVO moneyInfoVO = new MoneyInfoVO();
|
| | | moneyInfoVO.setMoneyType(1); // 默认显示:返 ¥6.6
|
| | | moneyInfoVO.setFanliMoney("¥" + PinDuoDuoUtil.getGoodsFanLiMoney(goods, fanLiRate));
|
| | | moneyInfoVO.setShareMoney("¥" + PinDuoDuoUtil.getGoodsFanLiMoney(goods, shareRate));
|
| | | BigDecimal commission = PinDuoDuoUtil.getGoodsFanLiMoney(goods, params.getFanLiRate());
|
| | | moneyInfoVO.setFanliMoney("¥" + commission);
|
| | | moneyInfoVO.setMaxMoney("¥" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate())));
|
| | | moneyInfoVO.setShareMoney("¥" + PinDuoDuoUtil.getGoodsFanLiMoney(goods, params.getShareRate()));
|
| | | goodsInfo.setMoneyInfo(moneyInfoVO);
|
| | |
|
| | | Boolean hasCoupon = goods.getHasCoupon();
|
| | | if (hasCoupon != null && hasCoupon) {
|
| | | BigDecimal amount = new BigDecimal(goods.getCouponDiscount());
|
| | | BigDecimal price = new BigDecimal(goods.getMinNormalPrice());
|
| | | BigDecimal startFree = new BigDecimal(goods.getCouponMinOrderAmount());
|
| | | BigDecimal hundred = new BigDecimal(100);
|
| | | BigDecimal amount = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred).setScale(2);
|
| | | BigDecimal price = MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), hundred).setScale(2);
|
| | | BigDecimal startFree = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponMinOrderAmount()), hundred)
|
| | | .setScale(2);
|
| | |
|
| | | // 计算券后价
|
| | | if (startFree.compareTo(price) <= 0) {
|
| | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
| | | CouponInfoVO coupon = new CouponInfoVO();
|
| | | coupon.setAmount(amount);
|
| | | coupon.setStartFee(startFree);
|
| | |
|
| | | if (goods.getCouponStartTime() != null) {
|
| | | coupon.setStartTime(sdf.format(new Date(goods.getCouponStartTime() * 1000)));
|
| | | }
|
| | |
| | | if (goods.getCouponEndTime() != null) {
|
| | | coupon.setEndTime(sdf.format(new Date(goods.getCouponEndTime() * 1000)));
|
| | | }
|
| | | coupon.setLink(null);
|
| | | coupon.setStartFee(startFree);
|
| | |
|
| | | if (goods.getCouponTotalQuantity() != null)
|
| | | coupon.setTotalCount(Integer.parseInt(goods.getCouponTotalQuantity().toString()));
|
| | |
| | | }
|
| | |
|
| | | // 店铺信息
|
| | | // String mallName = goods.getMallName();
|
| | | // if (!StringUtil.isMobile(mallName)) {
|
| | | // ShopInfoVO shop = new ShopInfoVO();
|
| | | // shop.setShopName(mallName);
|
| | | //
|
| | | // if (goods.getMallId() != null) {
|
| | | // shop.setId(goods.getMallId().toString());
|
| | | // }
|
| | | // goodsInfo.setShopInfo(shop);
|
| | | // }
|
| | | String mallName = goods.getMallName();
|
| | | if (!StringUtil.isMobile(mallName)) {
|
| | | ShopInfoVO shop = new ShopInfoVO();
|
| | | shop.setShopName(mallName);
|
| | | if (goods.getMallId() != null) {
|
| | | shop.setId(goods.getMallId().toString());
|
| | | }
|
| | | shop.setUserType(30);
|
| | | goodsInfo.setShopInfo(shop);
|
| | | }
|
| | |
|
| | | // if (Constant.IS_TEST) {
|
| | | // // 添加标签
|
| | | // List<ClientTextStyleVO> labels = goodsInfo.getLabels();
|
| | | // if (labels == null)
|
| | | // labels = new ArrayList<>();
|
| | | //
|
| | | // labels.add(new ClientTextStyleVO("预售", "#FF2B4E"));
|
| | | // labels.add(new ClientTextStyleVO("爆款", "#FF2B4E"));
|
| | | // labels.add(new ClientTextStyleVO("超级划算", "#FF2B4E"));
|
| | | // goodsInfo.setLabels(labels);
|
| | | // }
|
| | | return goodsInfo;
|
| | | }
|
| | |
|