|
@@ -85,6 +85,10 @@ public class PriceUtilService {
|
|
public void setPriceByUserId(PriceVo price, Integer userId) {
|
|
public void setPriceByUserId(PriceVo price, Integer userId) {
|
|
// 根据用户Id查询用户身份
|
|
// 根据用户Id查询用户身份
|
|
Integer identity = priceMapper.getIdentityByUserId(userId);
|
|
Integer identity = priceMapper.getIdentityByUserId(userId);
|
|
|
|
+ // 根据用户Id查询超级会员id
|
|
|
|
+ Integer svipUserId = priceMapper.getSvipUserIdByUserId(userId);
|
|
|
|
+ // 超级会员标识
|
|
|
|
+ boolean svipUserFlag = null != svipUserId;
|
|
// 根据商品id查询商品活动
|
|
// 根据商品id查询商品活动
|
|
PromotionsVo promotions = promotionsMapper.getPromotionsByProductId(price.getProductId());
|
|
PromotionsVo promotions = promotionsMapper.getPromotionsByProductId(price.getProductId());
|
|
price.setRepurchaseFlag(0);
|
|
price.setRepurchaseFlag(0);
|
|
@@ -99,18 +103,28 @@ public class PriceUtilService {
|
|
if (1 == price.getSvipProductFlag()) {
|
|
if (1 == price.getSvipProductFlag()) {
|
|
// 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
// 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
price.setLadderPriceFlag(0);
|
|
price.setLadderPriceFlag(0);
|
|
|
|
+ // 超级会员优惠价
|
|
|
|
+ BigDecimal svipDiscountPrice = price.getSvipDiscountPrice();
|
|
if (1 == price.getSvipPriceType()) {
|
|
if (1 == price.getSvipPriceType()) {
|
|
// 折扣价
|
|
// 折扣价
|
|
price.setSvipPriceTag(MathUtil.div(price.getSvipDiscount(), 10, 1) + "折");
|
|
price.setSvipPriceTag(MathUtil.div(price.getSvipDiscount(), 10, 1) + "折");
|
|
|
|
+ if (svipUserFlag) {
|
|
|
|
+ // 超级会员用户设置优惠价
|
|
|
|
+ svipDiscountPrice = MathUtil.div(MathUtil.mul(price.getPrice(), price.getSvipDiscount()), 100, 2);
|
|
|
|
+ price.setPrice(svipDiscountPrice.doubleValue());
|
|
|
|
+ }
|
|
} else if (2 == price.getSvipPriceType()) {
|
|
} else if (2 == price.getSvipPriceType()) {
|
|
// 直接优惠价
|
|
// 直接优惠价
|
|
- BigDecimal svipDiscountPrice = price.getSvipDiscountPrice();
|
|
|
|
|
|
+ if (svipUserFlag) {
|
|
|
|
+ // 超级会员用户设置优惠价
|
|
|
|
+ price.setPrice(svipDiscountPrice.doubleValue());
|
|
|
|
+ }
|
|
if (taxFlag) {
|
|
if (taxFlag) {
|
|
//添加税费
|
|
//添加税费
|
|
BigDecimal thisTaxFee = MathUtil.div(MathUtil.mul(svipDiscountPrice, price.getTaxRate()), 100, 2);
|
|
BigDecimal thisTaxFee = MathUtil.div(MathUtil.mul(svipDiscountPrice, price.getTaxRate()), 100, 2);
|
|
svipDiscountPrice = MathUtil.add(svipDiscountPrice, thisTaxFee);
|
|
svipDiscountPrice = MathUtil.add(svipDiscountPrice, thisTaxFee);
|
|
}
|
|
}
|
|
- price.setSvipPriceTag("¥" + svipDiscountPrice.setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
|
+ price.setSvipPriceTag("¥" + svipDiscountPrice);
|
|
}
|
|
}
|
|
} else if (null != promotions) {
|
|
} else if (null != promotions) {
|
|
// 促销活动
|
|
// 促销活动
|
|
@@ -159,7 +173,7 @@ public class PriceUtilService {
|
|
//添加税费
|
|
//添加税费
|
|
if (taxFlag) {
|
|
if (taxFlag) {
|
|
BigDecimal thisTaxFee = MathUtil.div(MathUtil.mul(price.getPrice(), price.getTaxRate()), 100, 2);
|
|
BigDecimal thisTaxFee = MathUtil.div(MathUtil.mul(price.getPrice(), price.getTaxRate()), 100, 2);
|
|
- BigDecimal originalTaxFee = MathUtil.div(MathUtil.mul(price.getPrice(), price.getTaxRate()), 100, 2);
|
|
|
|
|
|
+ BigDecimal originalTaxFee = MathUtil.div(MathUtil.mul(price.getOriginalPrice(), price.getTaxRate()), 100, 2);
|
|
price.setPrice(MathUtil.add(price.getPrice(), thisTaxFee).doubleValue());
|
|
price.setPrice(MathUtil.add(price.getPrice(), thisTaxFee).doubleValue());
|
|
price.setOriginalPrice(MathUtil.add(price.getOriginalPrice(), originalTaxFee).doubleValue());
|
|
price.setOriginalPrice(MathUtil.add(price.getOriginalPrice(), originalTaxFee).doubleValue());
|
|
}
|
|
}
|