|
@@ -179,9 +179,9 @@ public class HeheServiceImpl implements HeheService {
|
|
|
//相关参数
|
|
|
List<ProductParameterPo> parametersList = shopMapper.getProductParameters(productId);
|
|
|
product.setParametersList(parametersList);
|
|
|
- // 商城活动
|
|
|
+ // 商城活动id
|
|
|
Integer activityId = heheMapper.getActivityIdByProductId(product.getProductId());
|
|
|
- //内部优惠折扣
|
|
|
+ // 内部优惠折扣
|
|
|
Integer discount = heheMapper.getProductDiscount(product.getProductId(), userId);
|
|
|
//税费
|
|
|
boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
|
|
@@ -198,13 +198,14 @@ public class HeheServiceImpl implements HeheService {
|
|
|
ladder.setBuyPrice(price.doubleValue());
|
|
|
});
|
|
|
}
|
|
|
+ // 设置阶梯列表
|
|
|
product.setLadderList(ladderList);
|
|
|
}
|
|
|
setProductInfo(product, userId);
|
|
|
return ResponseJson.success(product);
|
|
|
}
|
|
|
|
|
|
- public void setProductInfo(HeheProductVo product, Integer userId) {
|
|
|
+ private void setProductInfo(HeheProductVo product, Integer userId) {
|
|
|
product.setMainImage(ImageUtils.getImageURL("product", product.getMainImage(), 0, domain));
|
|
|
// 活动id
|
|
|
Integer activityId = heheMapper.getActivityIdByProductId(product.getProductId());
|
|
@@ -218,7 +219,7 @@ public class HeheServiceImpl implements HeheService {
|
|
|
List<LadderPriceVo> ladderList = heheMapper.getActivityLadderList(activityId, product.getProductId());
|
|
|
if (ladderList != null && ladderList.size() > 0) {
|
|
|
LadderPriceVo ladder = ladderList.get(0);
|
|
|
- // 没有起订量概念,默认显示购买1个商品的价格,若第一阶梯为一个商品,则取第一阶梯时间
|
|
|
+ // 没有起订量概念,默认显示购买1个商品的价格,若第一阶梯为一个商品,则取第一阶梯价格
|
|
|
product.setPrice(1 == ladder.getBuyNum() ? new BigDecimal(ladder.getBuyPrice()) : product.getPrice());
|
|
|
}
|
|
|
} else if (collageProduct != null) {
|
|
@@ -231,6 +232,7 @@ public class HeheServiceImpl implements HeheService {
|
|
|
product.setPrice(discountPrice);
|
|
|
product.setDiscountStatus(1);
|
|
|
}
|
|
|
+ // 内部优惠折扣
|
|
|
Integer discount = heheMapper.getProductDiscount(product.getProductId(), userId);
|
|
|
if (null != discount && discount > 0) {
|
|
|
product.setPrice(MathUtil.div(MathUtil.mul(product.getPrice(), discount), 100));
|
|
@@ -263,17 +265,17 @@ public class HeheServiceImpl implements HeheService {
|
|
|
// 单价不满足优惠条件的优惠券列表
|
|
|
List<HeheCouponVo> unableCouponList = new ArrayList<>();
|
|
|
if (couponList.size() > 0) {
|
|
|
- // 有可用优惠券且商品未参与其他活动
|
|
|
+ // 有可用优惠券
|
|
|
couponList.forEach(coupon->{
|
|
|
- if (1 == coupon.getNoThresholdFlag() || MathUtil.compare(product.getPrice(),coupon.getTouchPrice())>0) {
|
|
|
+ if (1 == coupon.getNoThresholdFlag() || MathUtil.compare(product.getPrice(), coupon.getTouchPrice()) > 0) {
|
|
|
ableCouponList.add(coupon);
|
|
|
} else {
|
|
|
unableCouponList.add(coupon);
|
|
|
}
|
|
|
});
|
|
|
if (ableCouponList.size() > 0) {
|
|
|
- // 根据优惠金额排序,优惠大的排前面
|
|
|
- ableCouponList.sort(Comparator.comparing(HeheCouponVo::getCouponAmount));
|
|
|
+ // 根据优惠金额排序,优惠金额大的排前面
|
|
|
+ ableCouponList.sort((o1, o2) -> o2.getCouponAmount().compareTo(o1.getCouponAmount()));
|
|
|
HeheCouponVo biggestCoupon = ableCouponList.get(0);
|
|
|
// 现价-最大优惠金额=券后价
|
|
|
product.setCouponPrice(MathUtil.sub(product.getPrice(), biggestCoupon.getCouponAmount()));
|
|
@@ -285,7 +287,7 @@ public class HeheServiceImpl implements HeheService {
|
|
|
product.setCouponStatus(1);
|
|
|
} else {
|
|
|
// 根据优惠条件排序,条件小的排前面
|
|
|
- unableCouponList.sort((o1, o2) -> o2.getTouchPrice().compareTo(o1.getTouchPrice()));
|
|
|
+ unableCouponList.sort(Comparator.comparing(HeheCouponVo::getTouchPrice));
|
|
|
// 优惠券信息
|
|
|
product.setCouponStatus(2);
|
|
|
HeheCouponVo smallestCoupon = unableCouponList.get(0);
|