库存预警功能回退

This commit is contained in:
chc 2024-01-16 10:10:07 +08:00
parent 055a7fffdb
commit 085dad2107
10 changed files with 2 additions and 69 deletions

View File

@ -164,9 +164,6 @@ public class GoodsSku extends BaseEntity {
@ApiModelProperty(value = "商品类型", required = true)
private String goodsType;
@ApiModelProperty(value = "预警数量")
private Integer alertQuantity;
public Double getWeight() {
if (weight == null) {
return 0d;

View File

@ -90,9 +90,6 @@ public class GoodsSearchParams extends PageVO {
@ApiModelProperty(value = "销售模式", required = true)
private String salesModel;
@ApiModelProperty(value = "预警库存")
private Boolean alertQuantity;
public <T> QueryWrapper<T> queryWrapper() {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
if (CharSequenceUtil.isNotEmpty(goodsId)) {
@ -137,9 +134,6 @@ public class GoodsSearchParams extends PageVO {
if (recommend != null) {
queryWrapper.le("recommend", recommend);
}
if(alertQuantity != null && alertQuantity){
queryWrapper.apply("quantity < alert_quantity");
}
if (CharSequenceUtil.isNotEmpty(goodsType)) {
queryWrapper.eq("goods_type", goodsType);
}

View File

@ -21,8 +21,5 @@ public class GoodsSkuStockDTO {
@ApiModelProperty(value = "库存")
private Integer quantity;
@ApiModelProperty(value = "预警库存")
private Integer alertQuantity;
}

View File

@ -188,8 +188,6 @@ public interface GoodsSkuService extends IService<GoodsSku> {
*/
void updateStocks(List<GoodsSkuStockDTO> goodsSkuStockDTOS);
void updateAlertQuantity(List<GoodsSkuStockDTO> goodsSkuStockDTOS);
/**
* 更新SKU库存
*

View File

@ -536,26 +536,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
}
}
@Override
public void updateAlertQuantity(List<GoodsSkuStockDTO> goodsSkuStockDTOS) {
List<GoodsSku> goodsSkuList = new ArrayList<>();
List<String> skuIds = goodsSkuStockDTOS.stream().map(GoodsSkuStockDTO::getSkuId).collect(Collectors.toList());
List<GoodsSkuStockDTO> goodsSkuStockList = this.baseMapper.queryStocks(GoodsSearchParams.builder().ids(skuIds).build().queryWrapper());
List<String> goodsIdList = goodsSkuStockList.stream().map(GoodsSkuStockDTO::getGoodsId).collect(Collectors.toList());
HashSet<String> uniqueSet = new HashSet<>(goodsIdList);
// 将去重后的元素转回列表
List<String> uniqueGoodsIdList = new ArrayList<>(uniqueSet);
for (String goodsId : uniqueGoodsIdList) {
cache.remove(CachePrefix.GOODS.getPrefix() + goodsId);
}
for (GoodsSkuStockDTO goodsSkuStockDTO : goodsSkuStockDTOS) {
GoodsSku goodsSku = this.getById(goodsSkuStockDTO.getSkuId());
goodsSku.setAlertQuantity(goodsSkuStockDTO.getAlertQuantity());
goodsSkuList.add(goodsSku);
}
this.updateBatchById(goodsSkuList);
}
@Override
@Transactional(rollbackFor = Exception.class)

View File

@ -64,7 +64,7 @@ public class GoodsSkuBuilder {
Map<String, Object> specMap = new LinkedHashMap<>();
// 原始规格项
String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight","alertQuantity"};
String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight"};
//获取规格信息
for (Map.Entry<String, Object> spec : skuInfo.entrySet()) {
//保存新增规格信息
@ -91,7 +91,6 @@ public class GoodsSkuBuilder {
goodsSku.setQuantity(Convert.toInt(skuInfo.get("quantity"), 0));
goodsSku.setSpecs(JSONUtil.toJsonStr(specMap));
goodsSku.setSimpleSpecs(simpleSpecs.toString());
goodsSku.setAlertQuantity(Convert.toInt(skuInfo.get("alertQuantity"), 0));
}

View File

@ -21,9 +21,6 @@ public interface GoodsStatisticsService extends IService<Goods> {
* @return 所有的已上架的商品数量
*/
long goodsNum(GoodsStatusEnum goodsStatusEnum, GoodsAuthEnum goodsAuthEnum);
long alertQuantityNum();
/**
* 获取今天的已上架的商品数量
*

View File

@ -52,17 +52,6 @@ public class GoodsStatisticsServiceImpl extends ServiceImpl<GoodsStatisticsMappe
return this.count(queryWrapper);
}
@Override
public long alertQuantityNum() {
QueryWrapper queryWrapper = new QueryWrapper();
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
queryWrapper.eq(CharSequenceUtil.equals(currentUser.getRole().name(), UserEnums.STORE.name()),
"store_id", currentUser.getStoreId());
queryWrapper.eq("market_enable",GoodsStatusEnum.UPPER.name());
queryWrapper.apply("quantity < alert_quantity");
return goodsSkuService.count(queryWrapper);
}
@Override
public long todayUpperNum() {
LambdaQueryWrapper<Goods> queryWrapper = Wrappers.lambdaQuery();

View File

@ -182,7 +182,6 @@ public class IndexStatisticsServiceImpl implements IndexStatisticsService {
//商品总数量
storeIndexStatisticsVO.setGoodsNum(goodsStatisticsService.goodsNum(GoodsStatusEnum.UPPER, null));
// storeIndexStatisticsVO.setAlertQuantityNum(goodsStatisticsService.alertQuantityNum());
//订单总数量订单总金额
Map<String, Object> map = storeFlowStatisticsService.getOrderStatisticsPrice();
storeIndexStatisticsVO.setOrderNum(Convert.toInt(map.get("num").toString()));

View File

@ -93,8 +93,7 @@ public class GoodsStoreController {
StoreDetail storeDetail = OperationalJudgment.judgment(storeDetailService.getStoreDetail(storeId));
Integer stockWarnNum = storeDetail.getStockWarning();
goodsSearchParams.setStoreId(storeId);
// goodsSearchParams.setLeQuantity(stockWarnNum);
goodsSearchParams.setAlertQuantity(true);
goodsSearchParams.setLeQuantity(stockWarnNum);
goodsSearchParams.setMarketEnable(GoodsStatusEnum.UPPER.name());
IPage<GoodsSku> goodsSku = goodsSkuService.getGoodsSkuByPage(goodsSearchParams);
StockWarningVO stockWarning = new StockWarningVO(stockWarnNum, goodsSku);
@ -182,22 +181,6 @@ public class GoodsStoreController {
goodsSkuService.updateStocks(collect);
return ResultUtil.success();
}
@ApiOperation(value = "修改商品预警库存")
@PutMapping(value = "/update/alert/stocks", consumes = "application/json")
public ResultMessage<Object> updateAlertQuantity(@RequestBody List<GoodsSkuStockDTO> updateStockList) {
String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
// 获取商品skuId集合
List<String> goodsSkuIds = updateStockList.stream().map(GoodsSkuStockDTO::getSkuId).collect(Collectors.toList());
// 根据skuId集合查询商品信息
List<GoodsSku> goodsSkuList = goodsSkuService.list(new LambdaQueryWrapper<GoodsSku>().in(GoodsSku::getId, goodsSkuIds).eq(GoodsSku::getStoreId, storeId));
// 过滤不符合当前店铺的商品
List<String> filterGoodsSkuIds = goodsSkuList.stream().map(GoodsSku::getId).collect(Collectors.toList());
List<GoodsSkuStockDTO> collect = updateStockList.stream().filter(i -> filterGoodsSkuIds.contains(i.getSkuId())).collect(Collectors.toList());
goodsSkuService.updateAlertQuantity(collect);
return ResultUtil.success();
}
@ApiOperation(value = "通过id获取商品信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, paramType = "path"),