|
|
@@ -5,12 +5,14 @@ import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.shop.YhShopMapper;
|
|
|
+import com.cyksj.model.dto.YhShopSkuDownInfo;
|
|
|
import com.cyksj.model.entity.YhShop;
|
|
|
import com.cyksj.model.entity.YhShopGoodsSku;
|
|
|
import com.cyksj.model.views.YhShopAvailableGoodsView;
|
|
|
import com.cyksj.model.views.YhShopGoodsRateView;
|
|
|
import com.cyksj.model.views.YhShopGoodsView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
+import com.cyksj.service.mange.RefreshCacheService;
|
|
|
import com.cyksj.service.shop.YhShopGoodsSkuService;
|
|
|
import com.cyksj.web.util.StpYhShopManageUser;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
@@ -22,7 +24,6 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
|
|
|
/*
|
|
|
*项目名: yhlxj
|
|
|
@@ -45,6 +46,8 @@ public class YhShopGoodsController {
|
|
|
|
|
|
private final HttpServletRequest request;
|
|
|
|
|
|
+ private final RefreshCacheService refreshCacheService;
|
|
|
+
|
|
|
/**
|
|
|
* 新增平台
|
|
|
*/
|
|
|
@@ -72,9 +75,7 @@ public class YhShopGoodsController {
|
|
|
sku.setYhsId(yhShop.getId());
|
|
|
});
|
|
|
yhShopGoodsSkuService.saveOrUpdateBatch(goodsSkus);
|
|
|
- String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhShop.getId() + "*";
|
|
|
- Set<String> keys = redisService.keys(yhShopCacheKey);
|
|
|
- redisService.del(keys.toArray(String[]::new));
|
|
|
+ refreshCacheService.refreshShopUserIdCacheByYshId(yhShop.getId());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
|
|
|
@@ -82,14 +83,22 @@ public class YhShopGoodsController {
|
|
|
* 上下架
|
|
|
*/
|
|
|
@PutMapping("/put/goodsStatus/{goodsId}")
|
|
|
- public Result<Void> updGoodsStatus(@PathVariable Long goodsId, Boolean status){
|
|
|
+ public Result<Void> updGoodsStatus(@PathVariable Long goodsId, Boolean status) {
|
|
|
long userId = StpYhShopManageUser.getLoginIdAsLong();
|
|
|
YhShop yhShop = yhShopMapper.selectOne(Wrappers.lambdaQuery(YhShop.class)
|
|
|
.eq(YhShop::getUserId, userId).last("limit 1"));
|
|
|
+ List<YhShopGoodsSku> list = yhShopGoodsSkuService.list(Wrappers.lambdaQuery(YhShopGoodsSku.class)
|
|
|
+ .eq(YhShopGoodsSku::getUserId, userId)
|
|
|
+ .eq(YhShopGoodsSku::getGoodsId, goodsId)
|
|
|
+ .eq(YhShopGoodsSku::getDeleted, true));
|
|
|
+ list.forEach(sku -> {
|
|
|
+ YhShopGoodsRateView.YhShopGoodsSkuRateView yhShopGoodsSkuRateView = beanSearcher.searchFirst(YhShopGoodsRateView.YhShopGoodsSkuRateView.class, MapUtils.builder().field(YhShopGoodsRateView.YhShopGoodsSkuRateView::getSkuId, sku.getSkuId()).build());
|
|
|
+ if (sku.getPrice().compareTo(yhShopGoodsSkuRateView.getMaxPrice()) > 0 || sku.getPrice().compareTo(yhShopGoodsSkuRateView.getMinPrice()) < 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("价格不能超出区间范围");
|
|
|
+ }
|
|
|
+ });
|
|
|
yhShopGoodsSkuService.update(Wrappers.lambdaUpdate(YhShopGoodsSku.class).eq(YhShopGoodsSku::getGoodsId, goodsId).eq(YhShopGoodsSku::getDeleted, true).eq(YhShopGoodsSku::getUserId, userId).set(YhShopGoodsSku::getStatus, status));
|
|
|
- String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhShop.getId() + "*";
|
|
|
- Set<String> keys = redisService.keys(yhShopCacheKey);
|
|
|
- redisService.del(keys.toArray(String[]::new));
|
|
|
+ refreshCacheService.refreshShopUserIdCacheByYshId(yhShop.getId());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
|
|
|
@@ -103,9 +112,7 @@ public class YhShopGoodsController {
|
|
|
YhShop yhShop = yhShopMapper.selectOne(Wrappers.lambdaQuery(YhShop.class)
|
|
|
.eq(YhShop::getUserId, userId).last("limit 1"));
|
|
|
yhShopGoodsSkuService.update(Wrappers.lambdaUpdate(YhShopGoodsSku.class).eq(YhShopGoodsSku::getGoodsId, goodsId).eq(YhShopGoodsSku::getUserId, userId).set(YhShopGoodsSku::getDeleted, false));
|
|
|
- String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhShop.getId() + "*";
|
|
|
- Set<String> keys = redisService.keys(yhShopCacheKey);
|
|
|
- redisService.del(keys.toArray(String[]::new));
|
|
|
+ refreshCacheService.refreshShopUserIdCacheByYshId(yhShop.getId());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
|
|
|
@@ -142,4 +149,25 @@ public class YhShopGoodsController {
|
|
|
.field(YhShopGoodsView.YhShopGoodsSkuView::getGoodsId, goodsId).build());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(views);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 小店规格被下架提示
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/get/sku/down/info")
|
|
|
+ public Result<List<YhShopSkuDownInfo>> yhShopSkuSysStatusDownInfo() {
|
|
|
+ long userId = StpYhShopManageUser.getLoginIdAsLong();
|
|
|
+ List<YhShopSkuDownInfo> infos = yhShopGoodsSkuService.yhShopSkuSysStatusDownInfo(userId);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(infos);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除提示
|
|
|
+ */
|
|
|
+ @DeleteMapping("/delete/sku/down/info")
|
|
|
+ public Result<String> deleteSkuDownInfo() {
|
|
|
+ long userId = StpYhShopManageUser.getLoginIdAsLong();
|
|
|
+ yhShopGoodsSkuService.deleteSkuDownInfo(userId);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
}
|