Browse Source

下架店铺不在后台设置规格浮动区间

zoujiajian 2 năm trước cách đây
mục cha
commit
81327cb99f

+ 2 - 2
netflix-dao/src/main/java/com/cyksj/mapper/shop/YhShopGoodsSkuMapper.java

@@ -26,6 +26,6 @@ public interface YhShopGoodsSkuMapper extends BaseMapper<YhShopGoodsSku> {
 	@Select("select sku_id,price from yh_shop_goods_sku where yhs_id = #{yhsId} and goods_id = #{goodsId} and deleted is true and status is true order by price limit 1")
 	YhShopGoodsSku selectMinPriceSkuByYhsId(@Param("yhsId") Long yhsId, @Param("goodsId") Long goodsId);
 
-	@Select("select * from yh_shop_goods_sku where sku_id = #{skuId} and price < #{minPrice} and status = 1")
-	List<YhShopGoodsSku> getBelowPriceShopSku(@Param("skuId") Long skuId, @Param("minPrice") BigDecimal minPrice);
+	@Select("select * from yh_shop_goods_sku where sku_id = #{skuId} and price not between #{minPrice} #{maxPrice} and status = 1")
+	List<YhShopGoodsSku> getBelowPriceShopSku(@Param("skuId") Long skuId, @Param("minPrice") BigDecimal minPrice, @Param("maxPrice") BigDecimal maxPrice);
 }

+ 5 - 3
netflix-service/src/main/java/com/cyksj/service/mange/goods/CmsGoodsDonSkuServiceImpl.java

@@ -132,10 +132,12 @@ public class CmsGoodsDonSkuServiceImpl extends ServiceImpl<GoodsDonSkuMapper,Goo
 				.eq(YhShopGoodsRate::getSkuId, skuId)
 				.last("limit 1"));
 		if (yhShopGoodsRate != null) {
-			BigDecimal oriDiscount = BigDecimal.valueOf(100).subtract(BigDecimal.valueOf(yhShopGoodsRate.getRate()));
-			BigDecimal minPrice = newPrice.multiply(oriDiscount.divide(BigDecimal.valueOf(100)));
+			BigDecimal differPrice = newPrice.multiply(BigDecimal.valueOf(yhShopGoodsRate.getRate()).divide(BigDecimal.valueOf(100)));
+			BigDecimal minPrice = newPrice.subtract(differPrice);
+			BigDecimal maxPrice = newPrice.add(differPrice);
+			//不在设置的价格区间店铺 统统下架
 			//记录那些店铺规格被下架
-			List<YhShopGoodsSku> yhShopGoodsSkus = yhShopGoodsSkuMapper.getBelowPriceShopSku(skuId, minPrice);
+			List<YhShopGoodsSku> yhShopGoodsSkus = yhShopGoodsSkuMapper.getBelowPriceShopSku(skuId, minPrice, maxPrice);
 			if (CollUtil.isNotEmpty(yhShopGoodsSkus)) {
 				yhShopSkuSysTakeDownRecordMapper.batchInsert(yhShopGoodsSkus, minPrice);
 				Integer update = yhShopGoodsSkuMapper.setBelowPriceShopSkuDown(skuId, minPrice);

+ 3 - 3
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/CmsGoodsDonSkuController.java

@@ -171,9 +171,9 @@ public class CmsGoodsDonSkuController {
         //前后两次价格不同 下架店铺低于这个折扣最低价格
         BigDecimal oldPrice = dbSku.getPrice();
         BigDecimal newPrice = sku.getPrice();
-        //规格新价 变高
-        if (newPrice.compareTo(oldPrice) > 0) {
-            //下架店铺低于这个规格价格的品
+        //规格变化
+        if (newPrice.compareTo(oldPrice) != 0) {
+            //下架店铺不在平台设置的价格区间
             goodsDonSkuService.setBelowPriceShopSkuDown(skuId, newPrice);
         }
         refreshCacheService.refreshYhHomePageCache();