소스 검색

fix 批量上下架、批量删除

zoujiajian 3 년 전
부모
커밋
84152e1d2d
1개의 변경된 파일23개의 추가작업 그리고 4개의 파일을 삭제
  1. 23 4
      netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/CmsGoodsDonSkuController.java

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

@@ -168,19 +168,22 @@ public class CmsGoodsDonSkuController {
     }
 
     /**
-     * 批量上架
+     * 批量上
      */
     @PutMapping("/batch/update/status/{goodsId}")
-    public Result<String> batchUpdateStatus(@PathVariable Long goodsId, @RequestBody List<Long> skuIds) {
+    public Result<String> batchUpdateStatus(@PathVariable Long goodsId, @RequestBody List<Long> skuIds, Boolean status) {
+        if (status == null) {
+            throw BusinessRuntimeException.getInstance("请选择上下架状态");
+        }
         GoodsDon goodsDon = goodsDonService.getById(goodsId);
         if (goodsDon == null || !goodsDon.getDeleted()) {
             throw BusinessRuntimeException.getInstance("商品不存在");
         }
         boolean update = goodsDonSkuService.update(null, Wrappers.lambdaUpdate(GoodsDonSku.class)
-                .set(GoodsDonSku::getStatus, true)
+                .set(GoodsDonSku::getStatus, status)
                 .eq(GoodsDonSku::getGoodsId, goodsId)
                 .in(GoodsDonSku::getId, skuIds)
-                .eq(GoodsDonSku::getStatus, false));
+                .ne(GoodsDonSku::getStatus, status));
         if (update) {
             goodsDonService.updateGoodsSkuPrice(goodsId, null);
             Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
@@ -188,4 +191,20 @@ public class CmsGoodsDonSkuController {
         }
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
+
+    /**
+     * 批量删除规格
+     */
+    @DeleteMapping("/batch/delete/{goodsId}")
+    public Result<String> batchDeleteByGoodsId(@PathVariable Long goodsId, @RequestBody List<Long> skuIds) {
+        GoodsDon goodsDon = goodsDonService.getById(goodsId);
+        if (goodsDon == null || !goodsDon.getDeleted()) {
+            throw BusinessRuntimeException.getInstance("商品不存在");
+        }
+        goodsDonSkuService.removeByIds(skuIds);
+        goodsDonService.updateGoodsSkuPrice(goodsId, null);
+        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
+        redisService.del(keys.toArray(String[]::new));
+        return GatewayResponse.SUCCESS.newBuilder().toResult();
+    }
 }