ソースを参照

单品优惠价加入sku

zhijiezhao 2 年 前
コミット
f31225cfec

+ 8 - 0
src/main/java/com/caimei365/order/components/OrderCommonService.java

@@ -1,5 +1,6 @@
 package com.caimei365.order.components;
 
+import com.caimei365.order.mapper.BaseMapper;
 import com.caimei365.order.mapper.OrderCommonMapper;
 import com.caimei365.order.model.enums.OrderStatus;
 import com.caimei365.order.model.enums.ReceivablesType;
@@ -31,6 +32,8 @@ public class OrderCommonService {
     private String domain;
     @Resource
     private OrderCommonMapper orderCommonMapper;
+    @Resource
+    private BaseMapper baseMapper;
 
     /**
      * 设置订单状态
@@ -87,6 +90,11 @@ public class OrderCommonService {
                 if (null != orderProduct.getOrderPromotionsId() && orderProduct.getOrderPromotionsId() > 0) {
                     PromotionsVo promotions = orderCommonMapper.getOrderPromotionsById(orderProduct.getOrderPromotionsId());
                     if (null != promotions) {
+                        if (1 == promotions.getType() && 1 == promotions.getMode()) {
+                            // 单品优惠价取sku的优惠价
+                            Double touchPrice = baseMapper.getTouchPriceBySku(orderProduct.getSkuId());
+                            promotions.setTouchPrice(touchPrice);
+                        }
                         if (taxFlag && Integer.valueOf(1).equals(promotions.getType()) && Integer.valueOf(1).equals(promotions.getMode())) {
                             promotions.setTouchPrice(MathUtil.add(promotions.getTouchPrice(), MathUtil.div(MathUtil.mul(promotions.getTouchPrice(), orderProduct.getTaxRate()), 100)).doubleValue());
                         }

+ 3 - 0
src/main/java/com/caimei365/order/components/ProductService.java

@@ -108,6 +108,9 @@ public class ProductService {
         promotionPrice.setNumber(cartItemVo.getNumber());
         // 设置价格
         if (promotions.getType() == 1 && promotions.getMode() == 1) {
+            // 查询当前sku的优惠价
+            Double touchPrice=baseMapper.getTouchPriceBySku(cartItemVo.getSkuId());
+            promotions.setTouchPrice(touchPrice);
             // 单品优惠价添加税费
             if (taxFlag) {
                 BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(promotions.getTouchPrice(), cartItemVo.getTaxRate()), BigDecimal.valueOf(100), 2);

+ 2 - 0
src/main/java/com/caimei365/order/mapper/BaseMapper.java

@@ -242,4 +242,6 @@ public interface BaseMapper {
     CouponVo findCoupon(Integer couponId);
 
     VipSkuPriceDto getSvipSku(Integer skuId);
+
+    Double getTouchPriceBySku(Integer skuId);
 }

+ 2 - 0
src/main/java/com/caimei365/order/model/vo/OrderProductVo.java

@@ -14,6 +14,8 @@ import java.math.BigDecimal;
 @Data
 public class OrderProductVo implements Serializable {
     private static final long serialVersionUID = 1L;
+
+    private Integer skuId;
     /**
      * 商品货号
      */

+ 4 - 0
src/main/java/com/caimei365/order/service/impl/HeliPayServiceImpl.java

@@ -1159,6 +1159,10 @@ public class HeliPayServiceImpl implements HeliPayService {
                 if (null != orderProduct.getOrderPromotionsId() && orderProduct.getOrderPromotionsId() > 0) {
                     PromotionsVo promotions = orderCommonMapper.getOrderPromotionsById(orderProduct.getOrderPromotionsId());
                     if (null != promotions) {
+                        if (1 == promotions.getType() && 1 == promotions.getMode()) {
+                            //单品优惠价的时候取当前sku的touchprice
+                            promotions.setTouchPrice(baseMapper.getTouchPriceBySku(orderProduct.getSkuId()));
+                        }
                         if (taxFlag && Integer.valueOf(1).equals(promotions.getType()) && Integer.valueOf(1).equals(promotions.getMode())) {
                             promotions.setTouchPrice(MathUtil.add(promotions.getTouchPrice(), MathUtil.div(MathUtil.mul(promotions.getTouchPrice(), orderProduct.getTaxRate()), 100)).doubleValue());
                         }

+ 7 - 4
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -536,6 +536,10 @@ public class SubmitServiceImpl implements SubmitService {
                     // 店铺促销优先
                     if (null == shopPromotions) {
                         promotions = baseMapper.getPromotionByProductId(product.getProductId());
+                        if (null != promotions && 1 == promotions.getType() && 1 == promotions.getMode()) {
+                            //单品促销的优惠价时,touchPrice取当前sku的
+                            promotions.setTouchPrice(baseMapper.getTouchPriceBySku(skuId));
+                        }
                     }
                     //促销活动如果协销不可见,置为空
                     if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 2 && 3 == orderParamBo.getCartType()) {
@@ -599,8 +603,7 @@ public class SubmitServiceImpl implements SubmitService {
                         }
                         product.setLadderPrices(ladderPrices);
                         product.setActProduct(2);
-                    }
-                    else {
+                    } else {
                         // 复购价
                         Double repurchase = baseMapper.getRepurchasePrice(skuId, orderParamBo.getUserId());
                         if (null != repurchase && repurchase > 0) {
@@ -639,9 +642,9 @@ public class SubmitServiceImpl implements SubmitService {
                     // 单个商品总税费
                     Double taxFee = MathUtil.mul(discountTax, productNum).doubleValue();
                     if (hasActProductFlag && null != promotions) {
-                        // 单品优惠
+                        // 单品促销
                         if (promotions.getType() == 1) {
-                            // 是否满足单品优惠条件
+                            // 是否满足单品优惠条件(满足优惠价或者满减在这里进行设值)
                             if (promotions.getMode() == 1 || MathUtil.compare(productFee, promotions.getTouchPrice()) >= 0) {
                                 // 满减
                                 if (promotions.getMode() == 2) {

+ 6 - 1
src/main/resources/mapper/BaseMapper.xml

@@ -131,7 +131,7 @@
                pr.discount,
                pr.seen
         FROM cm_promotions pr
-                 LEFT JOIN cm_promotions_product prp ON pr.id = prp.promotionsId
+        LEFT JOIN cm_promotions_product prp ON pr.id = prp.promotionsId
         WHERE prp.productId = #{productId}
           and pr.delFlag = 0
           and pr.type in (1, 2)
@@ -388,4 +388,9 @@
         where skuId = #{skuId}
         and csp.status=0
     </select>
+    <select id="getTouchPriceBySku" resultType="java.lang.Double">
+        select touchPrice
+        from cm_promotion_sku
+        where skuId = #{skuId}
+    </select>
 </mapper>

+ 2 - 1
src/main/resources/mapper/OrderCommonMapper.xml

@@ -65,7 +65,8 @@
         WHERE id = #{orderPromotionsId}
     </select>
     <select id="getShopOrderProduct" resultType="com.caimei365.order.model.vo.OrderProductVo">
-        SELECT cop.orderProductID AS orderProductId,
+        SELECT cop.skuId,
+               cop.orderProductID AS orderProductId,
                cop.orderID        AS orderId,
                cop.orderNo,
                cop.shopOrderID    AS shopOrderId,