Aslee пре 3 година
родитељ
комит
4228990c27

+ 21 - 1
src/main/java/com/caimei365/commodity/components/PriceUtilService.java

@@ -96,7 +96,23 @@ public class PriceUtilService {
             price.setOriginalPrice(price.getPrice());
             //税费标志
             boolean taxFlag = "0".equals(price.getIncludedTax()) && ("1".equals(price.getInvoiceType()) || "2".equals(price.getInvoiceType()));
-            if (null != promotions) {
+            if (1 == price.getSvipProductFlag()) {
+                // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
+                price.setLadderPriceFlag(0);
+                if (1 == price.getSvipPriceType()) {
+                    // 折扣价
+                    price.setSvipPriceTag(MathUtil.div(price.getSvipDiscount(), 10, 1) + "折");
+                } else if (2 == price.getSvipPriceType()) {
+                    // 直接优惠价
+                    BigDecimal svipDiscountPrice = price.getSvipDiscountPrice();
+                    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));
+                }
+            } else if (null != promotions) {
                 // 促销活动
                 price.setActStatus(1);
                 price.setLadderPriceFlag(0);
@@ -142,7 +158,9 @@ 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);
                 price.setPrice(MathUtil.add(price.getPrice(), thisTaxFee).doubleValue());
+                price.setOriginalPrice(MathUtil.add(price.getOriginalPrice(), originalTaxFee).doubleValue());
             }
         } else {
             price.setPrice(0d);
@@ -189,6 +207,8 @@ public class PriceUtilService {
         product.setUserIdentity(price.getUserIdentity());
         product.setRepurchaseFlag(price.getRepurchaseFlag());
         product.setMaxBuyNumber(price.getMaxBuyNumber());
+        product.setSvipProductFlag(price.getSvipProductFlag());
+        product.setSvipPriceTag(price.getSvipPriceTag());
         List<LadderPriceVo> ladderPrices = priceMapper.getLadderPricesByProductId(product.getProductId());
         TaxVo tax = priceMapper.getTaxByProductId(product.getProductId());
         if (!CollectionUtils.isEmpty(ladderPrices)) {

+ 8 - 0
src/main/java/com/caimei365/commodity/controller/ProductPageApi.java

@@ -275,4 +275,12 @@ public class ProductPageApi {
         }
         return pageService.getArchiveDetail(archiveId, userId);
     }
+
+    /**
+     * 超级会员优惠商品页面
+     */
+    @GetMapping("/svip/product/page")
+    public ResponseJson<Map<String,Object>> getSvipProductPage(){
+        return null;
+    }
 }

+ 4 - 0
src/main/java/com/caimei365/commodity/mapper/PriceMapper.java

@@ -48,4 +48,8 @@ public interface PriceMapper {
      * 根据商品ID含税和发票信息
      */
     TaxVo getTaxByProductId(Integer productId);
+    /**
+     * 根据用户id查询超级会员用户id
+     */
+    Integer getSvipUserIdByUserId(Integer userId);
 }

+ 25 - 0
src/main/java/com/caimei365/commodity/model/vo/PriceVo.java

@@ -102,5 +102,30 @@ public class PriceVo implements Serializable {
      */
     private Boolean couponsLogo = false;
 
+    /**
+     * 超级会员优惠商品标识:0不是,1是
+     */
+    private Integer svipProductFlag;
+
+    /**
+     * 超级会员优惠价类型:1折扣价,2直接优惠价
+     */
+    private Integer svipPriceType;
+
+    /**
+     * 超级会员折扣
+     */
+    private BigDecimal svipDiscount;
+
+    /**
+     * 超级会员优惠价
+     */
+    private BigDecimal svipDiscountPrice;
+
+    /**
+     * 超级会员价格标签
+     */
+    private String svipPriceTag;
+
 }
 

+ 8 - 0
src/main/java/com/caimei365/commodity/model/vo/ProductDetailVo.java

@@ -311,4 +311,12 @@ public class ProductDetailVo implements Serializable {
      * 商品资料id
      */
     private Integer archiveId;
+    /**
+     * 超级会员优惠商品标识:0不是,1是
+     */
+    private Integer svipProductFlag;
+    /**
+     * 超级会员优惠价标签
+     */
+    private String svipPriceTag;
 }

+ 10 - 0
src/main/java/com/caimei365/commodity/model/vo/ProductItemVo.java

@@ -224,4 +224,14 @@ public class ProductItemVo implements Serializable {
      * 优惠券标识是否显示
      */
     private Boolean couponsLogo = false;
+
+    /**
+     * 超级会员优惠商品标识:0不是,1是
+     */
+    private Integer svipProductFlag;
+
+    /**
+     * 超级会员优惠价标签
+     */
+    private String svipPriceTag;
 }

+ 2 - 0
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -481,6 +481,8 @@ public class PageServiceImpl implements PageService {
             product.setUserIdentity(price.getUserIdentity());
             product.setRepurchaseFlag(price.getRepurchaseFlag());
             product.setMaxBuyNumber(price.getMaxBuyNumber());
+            product.setSvipProductFlag(price.getSvipProductFlag());
+            product.setSvipPriceTag(price.getSvipPriceTag());
             // 设置阶梯价格详情
             if (1 == price.getLadderPriceFlag()) {
                 List<LadderPriceVo> ladderPrices = priceMapper.getLadderPricesByProductId(product.getProductId());

+ 22 - 4
src/main/resources/mapper/PriceMapper.xml

@@ -21,9 +21,14 @@
             p.shopID as shopId,
             p.taxPoint as taxRate,
             p.includedTax,
-            p.invoiceType
+            p.invoiceType,
+            if(csp.id is not null,1,0) as svipProductFlag,
+            csp.priceType as svipPriceType,
+            csp.discount as svipDiscount,
+            csp.discountPrice as svipDiscountPrice
         from product p
-        where productID = #{productId}
+        left join cm_svip_product csp on p.productID = csp.productId
+        where p.productID = #{productId}
     </select>
     <select id="getListPriceByProductIds" resultType="com.caimei365.commodity.model.vo.PriceVo">
         select
@@ -42,9 +47,14 @@
             p.shopID as shopId,
             p.includedTax,
             p.invoiceType,
-            p.taxPoint as taxRate
+            p.taxPoint as taxRate,
+            if(csp.id is not null,1,0) as svipProductFlag,
+            csp.priceType as svipPriceType,
+            csp.discount as svipDiscount,
+            csp.discountPrice as svipDisountPrice
         from product p
-        where productID in
+        left join cm_svip_product csp on p.productID = csp.productId
+        where p.productID in
           <foreach collection="productIds" open="(" separator="," close=")" item="productId">
               #{productId}
           </foreach>
@@ -91,4 +101,12 @@
         where productID = #{productId}
     </select>
 
+    <select id="getSvipUserIdByUserId" resultType="java.lang.Integer">
+        select userId
+        from cm_svip_user
+        where now() <![CDATA[ < ]]> endTime
+          and delFlag = '0'
+          and userId = #{userId}
+    </select>
+
 </mapper>