商城系统开发从0到1(商品库存单独缓存)
Service层
package com.ems.emall.common.service;
import com.ems.emall.basic.dto.mall.CheckSubmitOrderDto;
import com.ems.emall.basic.dto.mall.ProductCacheDto;
import com.ems.emall.basic.dto.product.ProductSkuDetailDto;
import com.ems.emall.common.ResultMap;
import java.util.List;
/**
* 对商品库存
* 商品限购数量
* 用户已购买的商品数量
* 使用缓存统一管理
*
*/
public interface IProductCacheService {
/**减库存
* @param productCacheDto 传入productId,skuId,stock
* @return true扣减成功,false扣减失败
*/
boolean subStock(ProductCacheDto productCacheDto);
/**
* 用户取消订单或订单超时关闭调用
* 增加库存
* @param productCacheDtoList 传入productId,productCount,skuId
* @return
*/
boolean addStock(List<ProductCacheDto> productCacheDtoList);
/**
* 获取库存
* 获取当前商品剩余库存
* @param productCacheDto 传入productId,skuId
* @return
*/
Long getStock(ProductCacheDto productCacheDto);
/**
* 更新库存
* 更新当前商品库存
* @param productCacheDto 传入productId,stock,skuId
* @return
*/
boolean setStock(ProductCacheDto productCacheDto);
/**
* 初始化数据库的库存到redis
* 更新当前商品库存和商品限购数量
* @param productCacheDtoList 传入productId,stock,limitCount,skuId
* @return
*/
boolean initStockLimitCount(List<ProductCacheDto> productCacheDtoList);
/**
* 获取当前商品限购数量
* @param productCacheDto 传入productId,skuId
* @return
*/
Long getLimitCount(ProductCacheDto productCacheDto);
/**
* 更新商品限购数量
* @param productCacheDto 传入productId,limitCount,skuId
* @return
*/
boolean setLimitCount(ProductCacheDto productCacheDto);
/**
* 获取当前商品的上下架状态
* @param productCacheDto 传入productId
* @return
*/
Integer getPublishStatus(ProductCacheDto productCacheDto);
/**
* 更新商品的上下架状态
* @param productCacheDto 传入productId,publishStatus
* @return
*/
boolean setPublishStatus(ProductCacheDto productCacheDto);
/**
* 提交订单使用和结算页使用
* 更新用户购买的商品数量
* @param type (0:结算页校验 1:提交订单)
* @param productCacheDtoList 传入userId,productId,productCount,skuId
* @return
* [{
* "productId" : "11123457856444",
* "code" : "100320"
* }]
*
* 返回SUCCESS,代表全部商品的库存和限购数量校验正常
*/
ResultMap<List<CheckSubmitOrderDto>> addProductCount(List<ProductCacheDto> productCacheDtoList, Integer type);
/**
* 在取消订单和退款成功时返还用户的商品限购数量
* @param productCacheDtoList 传入userId,productId,productCount,skuId
* @return
*/
boolean subProductCount(List<ProductCacheDto> productCacheDtoList);
/**
* 提交订单使用和结算页使用
* 更新用户购买的商品数量
* @param type (0:结算页校验 1:提交订单)
* @param productCacheDto 传入userId,productId,productCount,skuId
* @return
* [{
* "productId" : "11123457856444",
* "code" : "100320"
* }]
*
* 返回SUCCESS,代表全部商品的库存和限购数量校验正常
*/
ResultMap<List<CheckSubmitOrderDto>> addProductCount(ProductCacheDto productCacheDto, Integer type);
/**
* 在取消订单和退款成功时返还用户的商品限购数量
* @param productCacheDto 传入userId,productId,productCount,skuId
* @return
*/
boolean subProductCount(ProductCacheDto productCacheDto);
/**
* 获取用户已购买的商品数量
* @param productCacheDto 传入userId,productId,skuId
* @return
*/
Long getProductCount(ProductCacheDto productCacheDto);
/**
* 获取用户真实限购数量
* @param productCacheDto 传入userId,productId,skuId
* @return
*/
Long getRealLimitCount(ProductCacheDto productCacheDto);
/**
* 获取该商品下所有规格的总库存
* @param productCacheDto 传入productId
* @return
*/
Long getAllStock(ProductCacheDto productCacheDto);
/**
* 删除库存,当修改商品的时候规格类型修改的话需要删除原来的库存,不然统计总库存不正确
* @param productCacheDto 传入productId
* @return
*/
boolean deleteStock(ProductCacheDto productCacheDto);
/**
* 规格修改的时候,删除已经被删掉的sku
* @param productCacheDto 传入productId,skuId
* @return
*/
boolean deleteSkuStockLimitCount(