|
|
@@ -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();
|
|
|
+ }
|
|
|
}
|