From dd5b15229cb15459fa7c31ccea77dac28cbfafbd Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 13 四月 2020 10:04:20 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div --- fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java | 293 +++++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 228 insertions(+), 65 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java b/fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java index 424397e..b73c90b 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java @@ -5,7 +5,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Date; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.yeshi.utils.taobao.TbImgUtil; @@ -25,6 +27,7 @@ import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.MoneyBigDecimalUtil; import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.jd.JDUtil; import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil; import com.yeshi.fanli.util.taobao.TaoBaoCouponUtil; @@ -157,11 +160,25 @@ // 璧勯噾淇℃伅 MoneyInfoVO moneyInfoVO = new MoneyInfoVO(); moneyInfoVO.setMoneyType(1); // 榛樿鏄剧ず锛氳繑 楼6.6 - + BigDecimal commission = CommonGoodsUtil.getCommission(goods, params.getFanLiRate()); moneyInfoVO.setFanliMoney("楼" + commission); - moneyInfoVO.setMaxMoney("楼" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate()))); + + BigDecimal maxCommission = CommonGoodsUtil.getCommission(goods, params.getVipFanLiRate()); + if (params.getMaxRewardRate() != null) + moneyInfoVO + .setMaxMoney("楼" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate()))); + else + moneyInfoVO.setMaxMoney("楼" + maxCommission); + moneyInfoVO.setShareMoney(CommonGoodsUtil.getCommissionInfo(goods, params.getShareRate())); + + moneyInfoVO.setRateInfo("杩斿埄姣� " + MoneyBigDecimalUtil.div(commission.multiply(new BigDecimal(100)), + CommonGoodsUtil.getAfterUseCouplePrice(goods)) + "%"); + + moneyInfoVO.setMaxRateInfo("杩斿埄姣� " + MoneyBigDecimalUtil.div(maxCommission.multiply(new BigDecimal(100)), + CommonGoodsUtil.getAfterUseCouplePrice(goods)) + "%"); + goodsInfo.setMoneyInfo(moneyInfoVO); // 鍒镐俊鎭� @@ -188,10 +205,10 @@ if (!StringUtil.isNullOrEmpty(goods.getSellerName())) { ShopInfoVO shop = new ShopInfoVO(); shop.setShopName(goods.getSellerName()); - - if( goods.getSellerId() != null) + + if (goods.getSellerId() != null) shop.setId(goods.getSellerId().toString()); - + if (shopType == null || shopType == 0) { shop.setUserType(10); } else if (shopType == 1) { @@ -199,22 +216,22 @@ } 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); -// } - + + // 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; } @@ -240,6 +257,7 @@ goodsInfo.setState(goods.getState() == null ? 0 : goods.getState()); goodsInfo.setSalesCount(goods.getSalesCount()); goodsInfo.setPicUrl(goods.getPictUrl()); + goodsInfo.setDescription(goods.getDescription()); Integer shopType = goods.getUserType(); if (shopType != null && shopType == 1) { @@ -258,11 +276,19 @@ TaoBaoHongBaoInfo taoBaoHongBaoInfo = goods.getTaoBaoHongBaoInfo(); moneyInfoVO.setFanliMoney("楼" + taoBaoHongBaoInfo.getHongbao()); moneyInfoVO.setShareMoney("楼" + taoBaoHongBaoInfo.getHongbao()); - moneyInfoVO.setMaxMoney("楼" + taoBaoHongBaoInfo.getHongbao().add(MoneyBigDecimalUtil.mul(taoBaoHongBaoInfo.getHongbao(), params.getMaxRewardRate()))); + if (params.getMaxRewardRate() != null) + moneyInfoVO.setMaxMoney("楼" + taoBaoHongBaoInfo.getHongbao() + .add(MoneyBigDecimalUtil.mul(taoBaoHongBaoInfo.getHongbao(), params.getMaxRewardRate()))); + else + moneyInfoVO.setMaxMoney("楼" + TaoBaoUtil.getGoodsHongBaoMoney(goods, params.getVipFanLiRate())); } else { BigDecimal commission = TaoBaoUtil.getGoodsHongBaoMoney(goods, params.getFanLiRate()); moneyInfoVO.setFanliMoney("楼" + commission); - moneyInfoVO.setMaxMoney("楼" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate()))); + if (params.getMaxRewardRate() != null) + moneyInfoVO.setMaxMoney( + "楼" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate()))); + else + moneyInfoVO.setMaxMoney("楼" + TaoBaoUtil.getGoodsHongBaoMoney(goods, params.getVipFanLiRate())); moneyInfoVO.setShareMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods, params.getShareRate())); } goodsInfo.setMoneyInfo(moneyInfoVO); @@ -283,21 +309,22 @@ coupon.setStartTime(sdf.format(new Date(Long.parseLong(couponEffectiveStartTime)))); coupon.setLink(taoBaoQuanInfo.getCouponLink()); coupon.setStartFee(taoBaoQuanInfo.getCouponStartFee()); + coupon.setShopCoupon(goods.isShopCoupon()); goodsInfo.setHasCoupon(true); goodsInfo.setCouponInfo(coupon); } // 搴楅摵淇℃伅 String shopTitle = goods.getShopTitle(); - + if (!StringUtil.isNullOrEmpty(shopTitle)) { ShopInfoVO shop = new ShopInfoVO(); shop.setShopName(shopTitle); - + Long sellerId = goods.getSellerId(); - if(sellerId != null) + if (sellerId != null) shop.setId(goods.getSellerId().toString()); - + if (shopType != null && shopType == 1) { shop.setUserType(11); } else { @@ -306,18 +333,18 @@ 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); -// } - + // 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; } @@ -339,6 +366,7 @@ goodsInfo.setTitle(goods.getTitle()); goodsInfo.setSalesType(1); // 榛樿鏈堥攢閲� goodsInfo.setZkPrice(goods.getZkPrice()); + goodsInfo.setDescription(goods.getDescription()); String provcity = goods.getProvcity(); if (!StringUtil.isNullOrEmpty(provcity)) { @@ -384,10 +412,37 @@ // 璧勯噾淇℃伅 MoneyInfoVO moneyInfoVO = new MoneyInfoVO(); moneyInfoVO.setMoneyType(1); // 榛樿鏄剧ず锛氳繑 楼6.6 + BigDecimal commission = TaoBaoUtil.getGoodsHongBaoMoney(goods, params.getFanLiRate()); + BigDecimal baseCommisstion = null; + if (params.getBaseFanliRate() != null) + baseCommisstion = TaoBaoUtil.getGoodsHongBaoMoney(goods, params.getBaseFanliRate()); moneyInfoVO.setFanliMoney("楼" + commission); - moneyInfoVO.setMaxMoney("楼" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate()))); + if (params.getMaxRewardRate() != null) + moneyInfoVO + .setMaxMoney("楼" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate()))); + else {// 鍙湁鏈塚IP鍚庣殑鐗堟湰鎵嶄細鏄剧ず杩斿埄姣� + + BigDecimal price = TaoBaoUtil.getAfterUseCouplePrice(goods); + BigDecimal rate = MoneyBigDecimalUtil.div(commission.multiply(new BigDecimal(100)), price); + moneyInfoVO.setRateInfo("杩斿埄姣� " + rate + "%"); + + BigDecimal maxCommission = TaoBaoUtil.getGoodsHongBaoMoney(goods, params.getVipFanLiRate()); + BigDecimal maxRate = MoneyBigDecimalUtil.div(maxCommission.multiply(new BigDecimal(100)), price); + moneyInfoVO.setMaxRateInfo("杩斿埄姣� " + maxRate + "%"); + moneyInfoVO.setMaxMoney("楼" + maxCommission); + if (baseCommisstion != null) { + String desc = String.format("浣i噾楼 %s+骞冲彴琛ヨ创楼 %s", baseCommisstion.setScale(2).toString(), + commission.subtract(baseCommisstion).setScale(2).toString()); + String maxDesc = String.format("浣i噾楼 %s+骞冲彴琛ヨ创楼 %s", baseCommisstion.setScale(2).toString(), + maxCommission.subtract(baseCommisstion).setScale(2).toString()); + moneyInfoVO.setCompositionInfo(desc); + moneyInfoVO.setMaxCompositionInfo(maxDesc); + } + } + moneyInfoVO.setShareMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods, params.getShareRate())); + goodsInfo.setMoneyInfo(moneyInfoVO); // 鍒镐俊鎭� @@ -413,9 +468,13 @@ coupon.setStartTime(goods.getCouponEffectiveStartTime().replace("-", ".")); } - coupon.setLink(TaoBaoCouponUtil.getCoupleUrl(goods.getCouponActivityId(), null, goods.getAuctionId() + "")); + if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) + coupon.setLink(goods.getCouponLink()); + else + coupon.setLink( + TaoBaoCouponUtil.getCoupleUrl(goods.getCouponActivityId(), null, goods.getAuctionId() + "")); coupon.setStartFee(goods.getCouponStartFee()); - + coupon.setShopCoupon(goods.isShopCoupon()); goodsInfo.setHasCoupon(true); goodsInfo.setCouponInfo(coupon); } @@ -424,16 +483,16 @@ if (!StringUtil.isNullOrEmpty(goods.getShopTitle())) { ShopInfoVO shop = new ShopInfoVO(); shop.setShopName(goods.getShopTitle()); - + if (goods.getSellerId() != null) shop.setId(goods.getSellerId().toString()); - + if (shopType != null && shopType == 1) { shop.setUserType(11); } else { shop.setUserType(10); } - + goodsInfo.setShopInfo(shop); } @@ -444,15 +503,15 @@ if (Constant.IS_TEST) { // 娣诲姞鏍囩 List<ClientTextStyleVO> labels = goodsInfo.getLabels(); - if (labels == null) + 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; } @@ -466,6 +525,51 @@ goodsInfo.getLabels().add(new ClientTextStyleVO("棰勫敭", "#FF2B4E")); } return goodsInfo; + } + + private static CouponInfoVO convertJDCouponInfo(JDCouponInfo couponInfo) { + CouponInfoVO coupon = new CouponInfoVO(); + coupon.setAmount(couponInfo.getDiscount()); + coupon.setLink(couponInfo.getLink()); + coupon.setStartFee(couponInfo.getQuota()); + + if (couponInfo.getGetStartTime() != null) { + coupon.setStartTime(TimeUtil.getGernalTime(couponInfo.getGetStartTime(), "yyyy.MM.dd")); + } + + if (couponInfo.getGetEndTime() != null) { + coupon.setEndTime(TimeUtil.getGernalTime(couponInfo.getGetEndTime(), "yyyy.MM.dd")); + } + + return coupon; + } + + private static List<CouponInfoVO> filterCouponInfo(List<CouponInfoVO> couponList) { + if (couponList == null) + return null; + long currentTime = System.currentTimeMillis(); + Set<String> sets = new HashSet<>(); + // 杩囨护鎺夎繃鏈熷埜 + for (int i = 0; i < couponList.size(); i++) { + if (couponList.get(i).getStartTime() != null && couponList.get(i).getEndTime() != null) { + long startTime = TimeUtil.convertToTimeTemp(couponList.get(i).getStartTime(), "yyyy.MM.dd"); + long endTime = TimeUtil.convertToTimeTemp(couponList.get(i).getEndTime(), "yyyy.MM.dd") + + 1000 * 60 * 60 * 24L; + if (currentTime < startTime || currentTime >= endTime) { + couponList.remove(i--); + continue; + } + } + // 杩囨护鎺夐潰鍊肩浉鍚屼笌璧峰閲戦鐩稿悓鐨� + String key = couponList.get(i).getStartFee() + "-" + couponList.get(i).getAmount(); + if (!sets.contains(key)) + sets.add(key); + else { + couponList.remove(i--); + continue; + } + } + return couponList; } /** @@ -504,11 +608,36 @@ moneyInfoVO.setMoneyType(1); // 榛樿鏄剧ず锛氳繑 楼6.6 BigDecimal commission = JDUtil.getGoodsFanLiMoney(goods, params.getFanLiRate()); moneyInfoVO.setFanliMoney("楼" + commission); - moneyInfoVO.setMaxMoney("楼" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate()))); + BigDecimal baseCommisstion = null; + if (params.getBaseFanliRate() != null) + baseCommisstion = JDUtil.getGoodsFanLiMoney(goods, params.getBaseFanliRate()); + + if (params.getMaxRewardRate() != null) + moneyInfoVO + .setMaxMoney("楼" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate()))); + else { + BigDecimal price = JDUtil.getQuanPrice(goods); + BigDecimal rate = MoneyBigDecimalUtil.div(commission.multiply(new BigDecimal(100)), price); + moneyInfoVO.setRateInfo("杩斿埄姣� " + rate + "%"); + + BigDecimal maxCommission = JDUtil.getGoodsFanLiMoney(goods, params.getVipFanLiRate()); + BigDecimal maxRate = MoneyBigDecimalUtil.div(maxCommission.multiply(new BigDecimal(100)), price); + moneyInfoVO.setMaxRateInfo("杩斿埄姣� " + maxRate + "%"); + moneyInfoVO.setMaxMoney("楼" + maxCommission); + + if (baseCommisstion != null) { + String desc = String.format("浣i噾楼 %s+骞冲彴琛ヨ创楼 %s", baseCommisstion.setScale(2).toString(), + commission.subtract(baseCommisstion).setScale(2).toString()); + String maxDesc = String.format("浣i噾楼 %s+骞冲彴琛ヨ创楼 %s", baseCommisstion.setScale(2).toString(), + maxCommission.subtract(baseCommisstion).setScale(2).toString()); + moneyInfoVO.setCompositionInfo(desc); + moneyInfoVO.setMaxCompositionInfo(maxDesc); + } + } 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(); // 璁$畻鍒稿悗浠� @@ -530,6 +659,14 @@ goodsInfo.setHasCoupon(true); goodsInfo.setCouponInfo(coupon); + } + + if (goods.getCouponInfoList() != null && goods.getCouponInfoList().size() > 0) { + List<CouponInfoVO> couponList = new ArrayList<>(); + for (JDCouponInfo jdCoupon : goods.getCouponInfoList()) { + couponList.add(convertJDCouponInfo(jdCoupon)); + } + goodsInfo.setCouponInfoList(filterCouponInfo(couponList)); } List<ClientTextStyleVO> labels = goodsInfo.getLabels(); @@ -572,7 +709,7 @@ ShopInfoVO shop = new ShopInfoVO(); shop.setShopName(shopInfo.getShopName()); shop.setId(shopInfo.getShopId().toString()); - + if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) { shop.setUserType(20); } else { @@ -586,7 +723,7 @@ if (isFreeShipping != null && isFreeShipping == 1) { goodsInfo.setBaoyou(true); } - + return goodsInfo; } @@ -637,9 +774,7 @@ moneyInfoVO.setMoneyType(1); // 榛樿鏄剧ず锛氳繑 楼6.6 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); + moneyInfoVO.setShareMoney("楼" + commission); Boolean hasCoupon = goods.getHasCoupon(); if (hasCoupon != null && hasCoupon) { @@ -680,6 +815,35 @@ goodsInfo.setCouponInfo(coupon); } + BigDecimal baseCommisstion = null; + if (params.getBaseFanliRate() != null) + baseCommisstion = PinDuoDuoUtil.getGoodsFanLiMoney(goods, params.getBaseFanliRate()); + + if (params.getMaxRewardRate() != null) + moneyInfoVO + .setMaxMoney("楼" + commission.add(MoneyBigDecimalUtil.mul(commission, params.getMaxRewardRate()))); + else { + BigDecimal price = goodsInfo.getCouponPrice() != null ? goodsInfo.getCouponPrice() : goodsInfo.getZkPrice(); + BigDecimal rate = MoneyBigDecimalUtil.div(commission.multiply(new BigDecimal(100)), price); + moneyInfoVO.setRateInfo("杩斿埄姣� " + rate + "%"); + + BigDecimal maxCommission = PinDuoDuoUtil.getGoodsFanLiMoney(goods, params.getVipFanLiRate()); + BigDecimal maxRate = MoneyBigDecimalUtil.div(maxCommission.multiply(new BigDecimal(100)), price); + moneyInfoVO.setMaxRateInfo("杩斿埄姣� " + maxRate + "%"); + + moneyInfoVO.setMaxMoney("楼" + maxCommission); + + if (baseCommisstion != null) { + String desc = String.format("浣i噾楼 %s+骞冲彴琛ヨ创楼 %s", baseCommisstion.setScale(2).toString(), + commission.subtract(baseCommisstion).setScale(2).toString()); + String maxDesc = String.format("浣i噾楼 %s+骞冲彴琛ヨ创楼 %s", baseCommisstion.setScale(2).toString(), + maxCommission.subtract(baseCommisstion).setScale(2).toString()); + moneyInfoVO.setCompositionInfo(desc); + moneyInfoVO.setMaxCompositionInfo(maxDesc); + } + } + goodsInfo.setMoneyInfo(moneyInfoVO); + // 搴楅摵淇℃伅 String mallName = goods.getMallName(); if (!StringUtil.isMobile(mallName)) { @@ -692,18 +856,17 @@ 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); -// } + // 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; } -- Gitblit v1.8.0