Jelajahi Sumber

促销活动价bugfix

zhijiezhao 1 tahun lalu
induk
melakukan
4706d832a3

+ 1 - 1
src/main/java/com/caimei/modules/order/service/NewShopOrderService.java

@@ -124,7 +124,7 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
                     CmPromotion promotions = cmPromotionDao.findOrderPromotions(bean.getOrderPromotionsId());
                     if (promotions != null && "1".equals(promotions.getMode())) {
                         //取对应sku的优惠价
-                        Double price = productDao.getTouchPriceBySku(bean.getSkuId());
+                        Double price = productDao.getTouchPriceByPromotions(bean.getSkuId(),promotions.getPromotionsId());
                         bean.setDiscountPrice(price);
                     }
                 }

+ 7 - 0
src/main/java/com/caimei/modules/product/dao/ProductDao.java

@@ -224,9 +224,16 @@ public interface ProductDao extends CrudDao<Product> {
 
     String findProductIdBySku(String productId);
 
+    /**
+     * todo 应加上promotionsId,其他几处引用暂时未处理
+     * @param skuId
+     * @return
+     */
     Double getTouchPriceBySku(Integer skuId);
 
     List<CmSku> findSkuByPromotion(String id);
 
     List<CmSku> getSkuByPromotionId(String id);
+
+    Double getTouchPriceByPromotions(@Param("skuId")Integer skuId,@Param("promotionsId") Integer promotionsId);
 }

+ 29 - 15
src/main/resources/mappings/modules/product/ProductMapper.xml

@@ -1215,8 +1215,9 @@
         select productId
         from cm_sku cs
         where skuId = #{productId}
-        #暂时写死0
-        and  cs.organizeId = 0 limit 1
+          #暂时写死0
+          and cs.organizeId = 0
+        limit 1
     </select>
 
     <select id="toAddProductList" resultType="product">
@@ -2019,7 +2020,8 @@
                stock,
                (select costCheckFlag
                 from cm_organize_product_info
-                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
+                where productId = cs.productId
+                  and organizeId = cs.organizeId) as costCheckFlag,
                shopPercent,
                costPrice,
                price,
@@ -2050,7 +2052,8 @@
                stock,
                (select costCheckFlag
                 from cm_organize_product_info
-                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
+                where productId = cs.productId
+                  and organizeId = cs.organizeId) as costCheckFlag,
                shopPercent,
                organizePercent,
                cmPercent,
@@ -2078,8 +2081,9 @@
                cs.stock,
                (select costCheckFlag
                 from cm_organize_product_info
-                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
-               cs.shopPercent                                                  as shopPercent,
+                where productId = cs.productId
+                  and organizeId = cs.organizeId) as costCheckFlag,
+               cs.shopPercent                     as shopPercent,
                cs.costPrice,
                cs.organizeCostPrice,
                cs.cmCostPrice,
@@ -2133,11 +2137,12 @@
                cs.stock,
                (select costCheckFlag
                 from cm_organize_product_info
-                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
+                where productId = cs.productId
+                  and organizeId = cs.organizeId) as costCheckFlag,
                cs.costPrice,
-               ifnull(cs.shopPercent, 0)                                       as shopPercent,
-               ifnull(cs.organizePercent, 0)                                   as organizePercent,
-               ifnull(cs.cmPercent, 0)                                         as cmPercent,
+               ifnull(cs.shopPercent, 0)          as shopPercent,
+               ifnull(cs.organizePercent, 0)      as organizePercent,
+               ifnull(cs.cmPercent, 0)            as cmPercent,
                chs.price
         from cm_sku cs
                  left join cm_hehe_sku chs on cs.skuId = chs.skuId
@@ -2151,10 +2156,11 @@
     </select>
     <select id="findSku" resultType="com.caimei.modules.product.entity.CmSku">
         select cs.price,
-               ifnull(cs.costPrice, 0)                                         as costPrice,
+               ifnull(cs.costPrice, 0)            as costPrice,
                (select costCheckFlag
                 from cm_organize_product_info
-                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
+                where productId = cs.productId
+                  and organizeId = cs.organizeId) as costCheckFlag,
                cs.shopPercent,
                cs.normalPrice
         from cm_sku cs
@@ -2168,8 +2174,9 @@
                ifnull(cs.costPrice, 0),
                (select costCheckFlag
                 from cm_organize_product_info
-                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
-               cs.shopPercent                                                  AS shopPercent,
+                where productId = cs.productId
+                  and organizeId = cs.organizeId) as costCheckFlag,
+               cs.shopPercent                     AS shopPercent,
                cs.normalPrice,
                cs.organizeId
         FROM cm_sku cs
@@ -2184,7 +2191,8 @@
                cs.costPrice,
                (select costCheckFlag
                 from cm_organize_product_info
-                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
+                where productId = cs.productId
+                  and organizeId = cs.organizeId) as costCheckFlag,
                cs.shopPercent,
                cs.unit,
                cs.organizeId
@@ -2220,4 +2228,10 @@
         WHERE promotionsId = #{id}
           and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = cs.productId)
     </select>
+    <select id="getTouchPriceByPromotions" resultType="java.lang.Double">
+        select touchPrice
+        from cm_promotion_sku
+        where skuId = #{skuId}
+          and promotionId = #{promotionsId}
+    </select>
 </mapper>