Selaa lähdekoodia

svip商品价格3

Aslee 3 vuotta sitten
vanhempi
commit
0920aafbaf

+ 17 - 3
src/main/java/com/caimei365/commodity/components/PriceUtilService.java

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

+ 8 - 4
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -452,13 +452,17 @@ public class PageServiceImpl implements PageService {
         if (null != userId && userId > 0) {
             // 用户身份:0个人,1协销,2会员机构,3供应商,4普通机构
             Integer identity = shopMapper.getUserIdentityById(userId);
+            // 超级会员用户id
+            Integer svipUserId = priceMapper.getSvipUserIdByUserId(userId);
+            // 超级会员
+            boolean pass1 = null != svipUserId;
             // 协销 | 会员机构 | 综合供应商
-            boolean pass1 = null != identity && (identity == 1 || identity == 2);
+            boolean pass2 = null != identity && (identity == 1 || identity == 2);
             // 普通机构
-            boolean pass2 = null != identity && (identity == 4 && (visibility == 2 || visibility == 3));
+            boolean pass3 = null != identity && (identity == 4 && (visibility == 2 || visibility == 3));
             // 游客
-            boolean pass3 = visibility == 3;
-            if (!(pass1 || pass2 || pass3)) {
+            boolean pass4 = visibility == 3;
+            if (!(pass1 || pass2 || pass3 || pass4)) {
                 return ResponseJson.success(1, "没有权限查看该商品", new ProductDetailVo());
             }
         } else if (2 == visibility || 1 == visibility) {