Explorar o código

超级会员优惠商品/单品优惠价加入sku

zhijiezhao %!s(int64=2) %!d(string=hai) anos
pai
achega
11665d91ec

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

@@ -92,7 +92,7 @@ public class OrderCommonService {
                     if (null != promotions) {
                         if (1 == promotions.getType() && 1 == promotions.getMode()) {
                             // 单品优惠价取sku的优惠价
-                            Double touchPrice = baseMapper.getTouchPriceBySku(orderProduct.getSkuId());
+                            Double touchPrice = baseMapper.getTouchPriceBySku(orderProduct.getSkuId(),promotions.getId());
                             promotions.setTouchPrice(touchPrice);
                         }
                         if (taxFlag && Integer.valueOf(1).equals(promotions.getType()) && Integer.valueOf(1).equals(promotions.getMode())) {

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

@@ -109,7 +109,7 @@ public class ProductService {
         // 设置价格
         if (promotions.getType() == 1 && promotions.getMode() == 1) {
             // 查询当前sku的优惠价
-            Double touchPrice=baseMapper.getTouchPriceBySku(cartItemVo.getSkuId());
+            Double touchPrice=baseMapper.getTouchPriceBySku(cartItemVo.getSkuId(),promotions.getId());
             promotions.setTouchPrice(touchPrice);
             // 单品优惠价添加税费
             if (taxFlag) {

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

@@ -243,5 +243,5 @@ public interface BaseMapper {
 
     VipSkuPriceDto getSvipSku(Integer skuId);
 
-    Double getTouchPriceBySku(Integer skuId);
+    Double getTouchPriceBySku(Integer skuId,Integer promotionId);
 }

+ 16 - 0
src/main/java/com/caimei365/order/model/vo/Sku.java

@@ -13,6 +13,22 @@ import java.util.List;
 @Data
 public class Sku {
 
+    /**
+     * 单品促销优惠价
+     */
+    private Double touchPrice;
+    /**
+     * 超级会员折扣
+     */
+    private Double discount;
+    /**
+     * 超级会员优惠价
+     */
+    private Double discountPrice;
+    /**
+     * 超级会员价类型:1折扣,2优惠价
+     */
+    private Integer priceType;
     /**
      * 划线价格
      */

+ 41 - 35
src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java

@@ -203,6 +203,9 @@ public class CartClubServiceImpl implements CartClubService {
                                      * 设置商品促销优惠
                                      */
                                     if (null != promotions) {
+                                        if (1 == promotions.getMode()) {
+                                            promotions.setTouchPrice(baseMapper.getTouchPriceBySku(cartItemVo.getSkuId(), promotions.getId()));
+                                        }
                                         // 当前促销活动的价格计算列表
                                         List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
                                         BigDecimal totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice());
@@ -592,6 +595,9 @@ public class CartClubServiceImpl implements CartClubService {
                  * 设置商品促销优惠
                  */
                 if (null != promotions) {
+                    if (1 == promotions.getMode()) {
+                        promotions.setTouchPrice(baseMapper.getTouchPriceBySku(cartItemVo.getSkuId(), promotions.getId()));
+                    }
                     BigDecimal totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice());
                     Double floor = Math.floor(MathUtil.div(totalAmount, promotions.getTouchPrice()).doubleValue());
                     // 关闭阶梯价格,活动优先
@@ -910,18 +916,18 @@ public class CartClubServiceImpl implements CartClubService {
         if (firstSize != shopList.size()) {
             shopList = cartClubMapper.getCartShopsByProductIds(userId, skuIdList, 2);
         }
-        String helpContent=null;
-        boolean flag=false;
+        String helpContent = null;
+        boolean flag = false;
         if (null != shopList && shopList.size() > 0) {
             // 遍历供应商列表
             List<String> finalIdList = skuIdList;//购物车商品skuId列表
             Integer finalUserIdentity = userIdentity;
             Integer finalUserClubType = userClubType;
             Integer finalUserIdentity1 = userIdentity;
-            for (int i=0;i<shopList.size();i++) {
+            for (int i = 0; i < shopList.size(); i++) {
                 //订单中存在不能退货的商品则给出不能退货提示
-                if(null!=shopList.get(i).getReturnGoodsStutas()&&shopList.get(i).getReturnGoodsStutas()==2){
-                    flag=true;
+                if (null != shopList.get(i).getReturnGoodsStutas() && shopList.get(i).getReturnGoodsStutas() == 2) {
+                    flag = true;
                     helpContent = cartClubMapper.getHelpContent(1040);
                     break;
                 }
@@ -1210,10 +1216,10 @@ public class CartClubServiceImpl implements CartClubService {
         resultData.put("userBeans", userBeans);
         resultData.put("includeRecharge", includeRecharge);
         resultData.put("couponList", couponList);
-        if(flag){
+        if (flag) {
             resultData.put("returnGoodsStutas", 2);
             resultData.put("helpContent", helpContent);
-        }else{
+        } else {
             resultData.put("returnGoodsStutas", 1);
             resultData.put("helpContent", null);
         }
@@ -1295,20 +1301,20 @@ public class CartClubServiceImpl implements CartClubService {
         // 商品的供应商列表
         List<CartShopVo> shopList = cartClubMapper.getShopsByProductIds(productIdList);
         //按供应商分类统计商品
-        String helpContent=null;
-        boolean flag=false;
+        String helpContent = null;
+        boolean flag = false;
         if (null != shopList && shopList.size() > 0) {
             // 遍历供应商列表
             List<Integer> finalIdList = skuIdList;//商品id列表
             Integer finalUserIdentity = userIdentity;
             Integer finalUserClubType = userClubType;
             Integer finalUserIdentity1 = userIdentity;
-            for (int i=0;i<shopList.size();i++) {
+            for (int i = 0; i < shopList.size(); i++) {
                 //订单中存在不能退货的商品则给出不能退货提示
-                if(null!=shopList.get(i).getReturnGoodsStutas()&&shopList.get(i).getReturnGoodsStutas()==2){
-                     flag=true;
-                     helpContent = cartClubMapper.getHelpContent(1040);
-                     break;
+                if (null != shopList.get(i).getReturnGoodsStutas() && shopList.get(i).getReturnGoodsStutas() == 2) {
+                    flag = true;
+                    helpContent = cartClubMapper.getHelpContent(1040);
+                    break;
                 }
             }
             shopList.forEach(shop -> {
@@ -1595,10 +1601,10 @@ public class CartClubServiceImpl implements CartClubService {
         resultData.put("userBeans", userBeans);
         resultData.put("includeRecharge", includeRecharge);
         resultData.put("couponList", couponList);
-        if(flag){
+        if (flag) {
             resultData.put("returnGoodsStutas", 2);
             resultData.put("helpContent", helpContent);
-        }else{
+        } else {
             resultData.put("returnGoodsStutas", 1);
             resultData.put("helpContent", null);
         }
@@ -1637,9 +1643,9 @@ public class CartClubServiceImpl implements CartClubService {
         CartItemVo cartItemVo = cartClubMapper.getCartItemByProductId(cartDto.getSkuId());
         if (null == cartItemVo) {
             return ResponseJson.error("商品数据异常!", null);
-        }else{
+        } else {
             //是否能退货
-            if(null!=cartItemVo.getReturnGoodsStutas()&&2==cartItemVo.getReturnGoodsStutas()){
+            if (null != cartItemVo.getReturnGoodsStutas() && 2 == cartItemVo.getReturnGoodsStutas()) {
                 String helpContent = orderCommonMapper.getHelpContent(1040);
                 cartItemVo.setHelpContent(helpContent);
             }
@@ -1839,21 +1845,21 @@ public class CartClubServiceImpl implements CartClubService {
         // 获取用户可用优惠券
         List<CouponVo> couponList = getUserCartCoupons(cartList, cartDto.getSource(), cartDto.getUserId());
         //订单中存在不能退货的商品则给出不能退货提示
-                boolean flag=false;
-                String helpContent=null;
-                if(null!=shopList&&shopList.size()>0){
-                    for (CartShopVo so:shopList) {
-                        List<CartItemVo> carList = so.getCartList();
-                        if(null!=carList&&carList.size()>0){
-                            for (CartItemVo op:carList) {
-                                if(null!=op.getReturnGoodsStutas()&&op.getReturnGoodsStutas()==2){
-                                    flag=true;
-                                    helpContent=op.getHelpContent();
-                                }
-                            }
+        boolean flag = false;
+        String helpContent = null;
+        if (null != shopList && shopList.size() > 0) {
+            for (CartShopVo so : shopList) {
+                List<CartItemVo> carList = so.getCartList();
+                if (null != carList && carList.size() > 0) {
+                    for (CartItemVo op : carList) {
+                        if (null != op.getReturnGoodsStutas() && op.getReturnGoodsStutas() == 2) {
+                            flag = true;
+                            helpContent = op.getHelpContent();
                         }
                     }
                 }
+            }
+        }
         // 包装返回数据
         Map<String, Object> resultData = new HashMap<>();
         resultData.put("list", shopList);
@@ -1869,10 +1875,10 @@ public class CartClubServiceImpl implements CartClubService {
         resultData.put("includeRecharge", includeRecharge);
         resultData.put("promotions", totalPromotions);
         resultData.put("couponList", couponList);
-        if(flag){
+        if (flag) {
             resultData.put("returnGoodsStutas", 2);
             resultData.put("helpContent", helpContent);
-        }else{
+        } else {
             resultData.put("returnGoodsStutas", 1);
             resultData.put("helpContent", null);
         }
@@ -1937,9 +1943,9 @@ public class CartClubServiceImpl implements CartClubService {
     /**
      * 获取结算商品运费
      *
-     * @param userId     用户ID
-     * @param skuIds     skuIds,逗号隔开
-     * @param townId     地区Id
+     * @param userId 用户ID
+     * @param skuIds skuIds,逗号隔开
+     * @param townId 地区Id
      */
     @Override
     public ResponseJson<Map<String, Object>> getProductsPostage(Integer userId, String skuIds, Integer townId) {

+ 4 - 1
src/main/java/com/caimei365/order/service/impl/CartSellerServiceImpl.java

@@ -159,6 +159,9 @@ public class CartSellerServiceImpl implements CartSellerService {
                                  * 设置商品促销优惠
                                  */
                                 if (null != promotions) {
+                                    if (1 == promotions.getMode()) {
+                                        promotions.setTouchPrice(baseMapper.getTouchPriceBySku(cartItemVo.getSkuId(), promotions.getId()));
+                                    }
                                     BigDecimal totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice());
                                     //叠加倍数
                                     Double floor = Math.floor(MathUtil.div(totalAmount, promotions.getTouchPrice()).doubleValue());
@@ -527,7 +530,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                                     // 当前促销活动的价格计算列表
                                     List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
                                     // 更新到总促销列表
-                                    if(MathUtil.compare(totalAmount, promotions.getTouchPrice()) > -1){
+                                    if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) > -1) {
                                         productService.updateTotalPromotions(totalPromotions, promotionsIds, promotions, promotionPriceList, floor);
                                     }
                                     //单品满减-计算供应商总价/满减金额

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

@@ -1161,7 +1161,7 @@ public class HeliPayServiceImpl implements HeliPayService {
                     if (null != promotions) {
                         if (1 == promotions.getType() && 1 == promotions.getMode()) {
                             //单品优惠价的时候取当前sku的touchprice
-                            promotions.setTouchPrice(baseMapper.getTouchPriceBySku(orderProduct.getSkuId()));
+                            promotions.setTouchPrice(baseMapper.getTouchPriceBySku(orderProduct.getSkuId(),promotions.getId()));
                         }
                         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());

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

@@ -538,7 +538,7 @@ public class SubmitServiceImpl implements SubmitService {
                         promotions = baseMapper.getPromotionByProductId(product.getProductId());
                         if (null != promotions && 1 == promotions.getType() && 1 == promotions.getMode()) {
                             //单品促销的优惠价时,touchPrice取当前sku的
-                            promotions.setTouchPrice(baseMapper.getTouchPriceBySku(skuId));
+                            promotions.setTouchPrice(baseMapper.getTouchPriceBySku(skuId, promotions.getId()));
                         }
                     }
                     //促销活动如果协销不可见,置为空

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

@@ -392,5 +392,6 @@
         select touchPrice
         from cm_promotion_sku
         where skuId = #{skuId}
+        and promotionId=#{promotionId}
     </select>
 </mapper>

+ 9 - 4
src/main/resources/mapper/OrderClubMapper.xml

@@ -732,7 +732,8 @@
         where userId = #{userId}
     </select>
     <select id="findSkus" resultType="com.caimei365.order.model.vo.Sku">
-        select skuId,
+        select DISTINCT
+               cs.skuId,
                price,
                normalPrice,
                costPrice,
@@ -741,9 +742,13 @@
                costProportional,
                stock,
                unit,
-               minBuyNumber
-        from cm_sku
-        where productId = #{productId}
+               minBuyNumber,
+               csps.discount,
+               csps.discountPrice,
+               csps.priceType
+        from cm_sku cs
+        left join cm_svip_product_sku csps on cs.skuId = csps.skuId
+        where cs.productId = #{productId}
         ORDER BY price ASC
     </select>
 </mapper>