优化sku处理
This commit is contained in:
@ -29,24 +29,6 @@ public interface YxStoreCombinationService extends BaseService<YxStoreCombinati
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 减库存增加销量
|
|
||||||
* @param num 数量
|
|
||||||
* @param combinationId 拼团产品id
|
|
||||||
*/
|
|
||||||
void decStockIncSales(int num,Long combinationId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加库存 减少销量
|
|
||||||
* @param num 数量
|
|
||||||
* @param combinationId 拼团产品id
|
|
||||||
*/
|
|
||||||
void incStockDecSales(int num,Long combinationId);
|
|
||||||
|
|
||||||
YxStoreCombination getCombination(int id);
|
|
||||||
|
|
||||||
//boolean judgeCombinationStock(Long combinationId,Integer cartNum);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拼团列表
|
* 拼团列表
|
||||||
* @param page page
|
* @param page page
|
||||||
|
@ -27,21 +27,6 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public interface YxStoreSeckillService extends BaseService<YxStoreSeckill>{
|
public interface YxStoreSeckillService extends BaseService<YxStoreSeckill>{
|
||||||
|
|
||||||
/**
|
|
||||||
* 退回库存减少销量
|
|
||||||
* @param num 数量
|
|
||||||
* @param seckillId 秒杀产品id
|
|
||||||
*/
|
|
||||||
void incStockDecSales(int num,Long seckillId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 减库存增加销量
|
|
||||||
* @param num 数量
|
|
||||||
* @param seckillId 秒杀产品id
|
|
||||||
*/
|
|
||||||
void decStockIncSales(int num,Long seckillId);
|
|
||||||
|
|
||||||
//YxStoreSeckill getSeckill(int id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 产品详情
|
* 产品详情
|
||||||
|
@ -97,52 +97,6 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
|
|||||||
private YxShippingTemplatesService shippingTemplatesService;
|
private YxShippingTemplatesService shippingTemplatesService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 减库存增加销量
|
|
||||||
* @param num 数量
|
|
||||||
* @param combinationId 拼团产品id
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void decStockIncSales(int num, Long combinationId) {
|
|
||||||
int res = yxStoreCombinationMapper.decStockIncSales(num,combinationId);
|
|
||||||
if(res == 0) {
|
|
||||||
throw new YshopException("拼团产品库存不足");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加库存 减少销量
|
|
||||||
* @param num 数量
|
|
||||||
* @param combinationId 拼团产品id
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void incStockDecSales(int num, Long combinationId) {
|
|
||||||
yxStoreCombinationMapper.incStockDecSales(num,combinationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public YxStoreCombination getCombination(int id) {
|
|
||||||
QueryWrapper<YxStoreCombination> wrapper = new QueryWrapper<>();
|
|
||||||
wrapper.eq("id",id).eq("is_del",0).eq("is_show",1);
|
|
||||||
return yxStoreCombinationMapper.selectOne(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 判断库存是否足够
|
|
||||||
// * @param combinationId 平团产品id
|
|
||||||
// * @param cartNum 购物车数量
|
|
||||||
// * @return boolean
|
|
||||||
// */
|
|
||||||
// @Override
|
|
||||||
// public boolean judgeCombinationStock(Long combinationId, Integer cartNum) {
|
|
||||||
// YxStoreCombination storeCombination = this.getById(combinationId);
|
|
||||||
// return storeCombination.getStock() >= cartNum;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public YxStoreCombinationQueryVo getCombinationT(int id) {
|
|
||||||
// return yxStoreCombinationMapper.getCombDetail(id);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取拼团详情
|
* 获取拼团详情
|
||||||
|
@ -78,28 +78,7 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private YxShippingTemplatesService shippingTemplatesService;
|
private YxShippingTemplatesService shippingTemplatesService;
|
||||||
/**
|
|
||||||
* 退回库存减少销量
|
|
||||||
* @param num 数量
|
|
||||||
* @param seckillId 秒杀产品id
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void incStockDecSales(int num, Long seckillId) {
|
|
||||||
yxStoreSeckillMapper.incStockDecSales(num,seckillId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 减库存增加销量
|
|
||||||
* @param num 数量
|
|
||||||
* @param seckillId 秒杀产品id
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void decStockIncSales(int num, Long seckillId) {
|
|
||||||
int res = yxStoreSeckillMapper.decStockIncSales(num,seckillId);
|
|
||||||
if(res == 0) {
|
|
||||||
throw new YshopException("秒杀产品库存不足");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
// public YxStoreSeckill getSeckill(int id) {
|
// public YxStoreSeckill getSeckill(int id) {
|
||||||
|
@ -26,13 +26,6 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface YxStoreCombinationMapper extends CoreMapper<YxStoreCombination> {
|
public interface YxStoreCombinationMapper extends CoreMapper<YxStoreCombination> {
|
||||||
@Update("update yx_store_combination set stock=stock-#{num}, sales=sales+#{num}" +
|
|
||||||
" where id=#{combinationId} and stock >= #{num}")
|
|
||||||
int decStockIncSales(@Param("num") int num, @Param("combinationId") Long combinationId);
|
|
||||||
|
|
||||||
@Update("update yx_store_combination set stock=stock+#{num}, sales=sales-#{num}" +
|
|
||||||
" where id=#{combinationId}")
|
|
||||||
int incStockDecSales(@Param("num") int num,@Param("combinationId") Long combinationId);
|
|
||||||
|
|
||||||
@Select("SELECT c.id,c.effective_time as effectiveTime,c.image,c.people,c.price, s.sales as sales," +
|
@Select("SELECT c.id,c.effective_time as effectiveTime,c.image,c.people,c.price, s.sales as sales," +
|
||||||
"c.title,c.unit_name as unitName,s.price as productPrice FROM yx_store_combination c " +
|
"c.title,c.unit_name as unitName,s.price as productPrice FROM yx_store_combination c " +
|
||||||
|
@ -22,13 +22,6 @@ import org.springframework.stereotype.Repository;
|
|||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface YxStoreSeckillMapper extends CoreMapper<YxStoreSeckill> {
|
public interface YxStoreSeckillMapper extends CoreMapper<YxStoreSeckill> {
|
||||||
@Update("update yx_store_seckill set stock=stock+#{num}, sales=sales-#{num}" +
|
|
||||||
" where id=#{seckillId}")
|
|
||||||
int incStockDecSales(@Param("num") int num, @Param("seckillId") Long seckillId);
|
|
||||||
|
|
||||||
@Update("update yx_store_seckill set stock=stock-#{num}, sales=sales+#{num}" +
|
|
||||||
" where id=#{seckillId} and stock >= #{num}")
|
|
||||||
int decStockIncSales(@Param("num") int num,@Param("seckillId") Long seckillId);
|
|
||||||
|
|
||||||
@Select("SELECT c.id,c.image,c.price,c.title as storeName,c.is_show as isShow,c.cost," +
|
@Select("SELECT c.id,c.image,c.price,c.title as storeName,c.is_show as isShow,c.cost," +
|
||||||
"c.is_postage as isPostage,c.postage,c.sales,c.stock,c.is_del as isDel" +
|
"c.is_postage as isPostage,c.postage,c.sales,c.stock,c.is_del as isDel" +
|
||||||
|
@ -639,9 +639,6 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 确认订单退款
|
* 确认订单退款
|
||||||
* @param orderId 单号
|
* @param orderId 单号
|
||||||
@ -1685,14 +1682,14 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
|
|||||||
YxStoreCartQueryVo cart = JSONObject.parseObject(cartInfo.getCartInfo()
|
YxStoreCartQueryVo cart = JSONObject.parseObject(cartInfo.getCartInfo()
|
||||||
,YxStoreCartQueryVo.class);
|
,YxStoreCartQueryVo.class);
|
||||||
if(order.getCombinationId() != null && order.getCombinationId() > 0){//拼团
|
if(order.getCombinationId() != null && order.getCombinationId() > 0){//拼团
|
||||||
combinationService.incStockDecSales(cart.getCartNum(),order.getCombinationId());
|
productService.incProductStock(cart.getCartNum(),cart.getProductId(),cart.getProductAttrUnique(),order.getCombinationId(),"combination");
|
||||||
}else if(order.getSeckillId() != null && order.getSeckillId() > 0){//秒杀
|
}else if(order.getSeckillId() != null && order.getSeckillId() > 0){//秒杀
|
||||||
storeSeckillService.incStockDecSales(cart.getCartNum(),order.getSeckillId());
|
productService.incProductStock(cart.getCartNum(),cart.getProductId(),cart.getProductAttrUnique(),order.getSeckillId(),"seckill");
|
||||||
}else if(order.getBargainId() != null && order.getBargainId() > 0){//砍价
|
}else if(order.getBargainId() != null && order.getBargainId() > 0){//砍价
|
||||||
storeBargainService.incStockDecSales(cart.getCartNum(),order.getBargainId());
|
storeBargainService.incStockDecSales(cart.getCartNum(),order.getBargainId());
|
||||||
}else{
|
}else{
|
||||||
productService.incProductStock(cart.getCartNum(),cart.getProductId()
|
productService.incProductStock(cart.getCartNum(),cart.getProductId()
|
||||||
,cart.getProductAttrUnique());
|
,cart.getProductAttrUnique(),0L,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public interface YxStoreProductAttrService extends BaseService<YxStoreProductAt
|
|||||||
* @param productId 商品id
|
* @param productId 商品id
|
||||||
* @param unique sku唯一值
|
* @param unique sku唯一值
|
||||||
*/
|
*/
|
||||||
void incProductAttrStock(Integer num, Long productId, String unique);
|
void incProductAttrStock(Integer num, Long productId, String unique,String type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 减少库存增加销量
|
* 减少库存增加销量
|
||||||
|
@ -35,7 +35,7 @@ public interface YxStoreProductService extends BaseService<YxStoreProduct>{
|
|||||||
* @param productId 商品id
|
* @param productId 商品id
|
||||||
* @param unique sku唯一值
|
* @param unique sku唯一值
|
||||||
*/
|
*/
|
||||||
void incProductStock(Integer num, Long productId, String unique);
|
void incProductStock(Integer num, Long productId, String unique,Long activityId, String type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 减少库存与增加销量
|
* 减少库存与增加销量
|
||||||
|
@ -16,6 +16,7 @@ import co.yixiang.api.BusinessException;
|
|||||||
import co.yixiang.api.YshopException;
|
import co.yixiang.api.YshopException;
|
||||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||||
import co.yixiang.dozer.service.IGenerator;
|
import co.yixiang.dozer.service.IGenerator;
|
||||||
|
import co.yixiang.exception.BadRequestException;
|
||||||
import co.yixiang.modules.product.domain.YxStoreProductAttr;
|
import co.yixiang.modules.product.domain.YxStoreProductAttr;
|
||||||
import co.yixiang.modules.product.domain.YxStoreProductAttrValue;
|
import co.yixiang.modules.product.domain.YxStoreProductAttrValue;
|
||||||
import co.yixiang.modules.product.service.YxStoreProductAttrResultService;
|
import co.yixiang.modules.product.service.YxStoreProductAttrResultService;
|
||||||
@ -93,6 +94,9 @@ public class YxStoreProductAttrServiceImpl extends BaseServiceImpl<StoreProductA
|
|||||||
// List<String> stringList = productFormatDto.getDetail().values()
|
// List<String> stringList = productFormatDto.getDetail().values()
|
||||||
// .stream()
|
// .stream()
|
||||||
// .collect(Collectors.toList());
|
// .collect(Collectors.toList());
|
||||||
|
if(productFormatDto.getPinkStock()>productFormatDto.getStock() || productFormatDto.getSeckillStock()>productFormatDto.getStock()){
|
||||||
|
throw new BadRequestException("活动商品库存不能大于原有商品库存");
|
||||||
|
}
|
||||||
List<String> stringList = new ArrayList<>(productFormatDto.getDetail().values());
|
List<String> stringList = new ArrayList<>(productFormatDto.getDetail().values());
|
||||||
Collections.sort(stringList);
|
Collections.sort(stringList);
|
||||||
|
|
||||||
@ -162,12 +166,19 @@ public class YxStoreProductAttrServiceImpl extends BaseServiceImpl<StoreProductA
|
|||||||
* @param unique sku唯一值
|
* @param unique sku唯一值
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void incProductAttrStock(Integer num, Long productId, String unique) {
|
public void incProductAttrStock(Integer num, Long productId, String unique, String type ) {
|
||||||
|
|
||||||
|
if("combination".equals(type)){
|
||||||
|
yxStoreProductAttrValueMapper.incCombinationStockDecSales(num,productId,unique);
|
||||||
|
}else if("seckill".equals(type)){
|
||||||
|
yxStoreProductAttrValueMapper.incSeckillStockDecSales(num,productId,unique);
|
||||||
|
}else {
|
||||||
yxStoreProductAttrValueMapper.incStockDecSales(num,productId,unique);
|
yxStoreProductAttrValueMapper.incStockDecSales(num,productId,unique);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 减少库存增加销量
|
* 减少库存增加销量(针对sku操作)
|
||||||
* @param num 数量
|
* @param num 数量
|
||||||
* @param productId 商品id
|
* @param productId 商品id
|
||||||
* @param unique sku唯一值
|
* @param unique sku唯一值
|
||||||
|
@ -89,11 +89,8 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IGenerator generator;
|
private IGenerator generator;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private StoreProductMapper storeProductMapper;
|
private StoreProductMapper storeProductMapper;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private YxStoreCategoryService yxStoreCategoryService;
|
private YxStoreCategoryService yxStoreCategoryService;
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -120,11 +117,20 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
|||||||
* @param unique sku唯一值
|
* @param unique sku唯一值
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void incProductStock(Integer num, Long productId, String unique) {
|
public void incProductStock(Integer num, Long productId, String unique,Long activityId, String type) {
|
||||||
|
//处理属性sku
|
||||||
if(StrUtil.isNotEmpty(unique)){
|
if(StrUtil.isNotEmpty(unique)){
|
||||||
yxStoreProductAttrService.incProductAttrStock(num,productId,unique);
|
yxStoreProductAttrService.incProductAttrStock(num,productId,unique,type);
|
||||||
}
|
}
|
||||||
|
//先处理商品库存,活动商品也要处理,因为共享库存
|
||||||
storeProductMapper.incStockDecSales(num, productId);
|
storeProductMapper.incStockDecSales(num, productId);
|
||||||
|
//处理商品外层显示的库存
|
||||||
|
if("combination".equals(type)){
|
||||||
|
storeProductMapper.incCombinationStockIncSales(num,productId,activityId);
|
||||||
|
}else if("seckill".equals(type)){
|
||||||
|
storeProductMapper.incSeckillStockIncSales(num,productId,activityId);
|
||||||
|
}
|
||||||
|
//todo 处理砍价商品库存
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,18 +141,23 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void decProductStock(int num, Long productId, String unique,Long activityId,String type) {
|
public void decProductStock(int num, Long productId, String unique,Long activityId,String type) {
|
||||||
|
//处理属性sku
|
||||||
if(StrUtil.isNotEmpty(unique)){
|
if(StrUtil.isNotEmpty(unique)){
|
||||||
yxStoreProductAttrService.decProductAttrStock(num,productId,unique, type);
|
yxStoreProductAttrService.decProductAttrStock(num,productId,unique, type);
|
||||||
}
|
}
|
||||||
|
//先处理商品库存,活动商品也要处理,因为共享库存
|
||||||
|
int product = storeProductMapper.decStockIncSales(num,productId);
|
||||||
|
if(product == 0) {
|
||||||
|
throw new YshopException("商品库存不足");
|
||||||
|
}
|
||||||
|
//处理商品外层显示的库存
|
||||||
int res = 0;
|
int res = 0;
|
||||||
if("combination".equals(type)){
|
if("combination".equals(type)){
|
||||||
res = storeProductMapper.decCombinationStockIncSales(num,productId,activityId);
|
res = storeProductMapper.decCombinationStockIncSales(num,productId,activityId);
|
||||||
}else if("seckill".equals(type)){
|
}else if("seckill".equals(type)){
|
||||||
res = storeProductMapper.decSeckillStockIncSales(num,productId,activityId);
|
res = storeProductMapper.decSeckillStockIncSales(num,productId,activityId);
|
||||||
}else {
|
|
||||||
res = storeProductMapper.decStockIncSales(num,productId);
|
|
||||||
}
|
}
|
||||||
|
//todo 处理砍价库存
|
||||||
if(res == 0) {
|
if(res == 0) {
|
||||||
throw new YshopException("商品库存不足");
|
throw new YshopException("商品库存不足");
|
||||||
}
|
}
|
||||||
|
@ -22,24 +22,77 @@ import org.springframework.stereotype.Repository;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface StoreProductAttrValueMapper extends CoreMapper<YxStoreProductAttrValue> {
|
public interface StoreProductAttrValueMapper extends CoreMapper<YxStoreProductAttrValue> {
|
||||||
|
|
||||||
@Select("select sum(stock) from yx_store_product_attr_value " +
|
|
||||||
"where product_id = #{productId}")
|
|
||||||
Integer sumStock(long productId);
|
|
||||||
|
|
||||||
@Update("update yx_store_product_attr_value set stock=stock-#{num}, sales=sales+#{num}" +
|
|
||||||
" where product_id=#{productId} and `unique`=#{unique} and stock >= #{num}")
|
|
||||||
int decStockIncSales(@Param("num") int num, @Param("productId") Long productId,
|
|
||||||
@Param("unique") String unique);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正常商品 加库存 减销量
|
||||||
|
* @param num
|
||||||
|
* @param productId
|
||||||
|
* @param unique
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Update("update yx_store_product_attr_value set stock=stock+#{num}, sales=sales-#{num}" +
|
@Update("update yx_store_product_attr_value set stock=stock+#{num}, sales=sales-#{num}" +
|
||||||
" where product_id=#{productId} and `unique`=#{unique}")
|
" where product_id=#{productId} and `unique`=#{unique}")
|
||||||
int incStockDecSales(@Param("num") int num,@Param("productId") Long productId,
|
int incStockDecSales(@Param("num") int num,@Param("productId") Long productId,
|
||||||
@Param("unique") String unique);
|
@Param("unique") String unique);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼团商品 加库存 减销量
|
||||||
|
* @param num
|
||||||
|
* @param productId
|
||||||
|
* @param unique
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Update("update yx_store_product_attr_value set stock=stock+#{num}, pink_stock=pink_stock+#{num}, sales=sales-#{num}" +
|
||||||
|
" where product_id=#{productId} and and `unique`=#{unique}")
|
||||||
|
int incCombinationStockDecSales(@Param("num") int num,@Param("productId") Long productId,
|
||||||
|
@Param("unique") String unique);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 秒杀 加库存 减销量
|
||||||
|
* @param num
|
||||||
|
* @param productId
|
||||||
|
* @param unique
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Update("update yx_store_product_attr_value set stock=stock+#{num},seckill_stock=seckill_stock+#{num}, sales=sales-#{num}" +
|
||||||
|
" where product_id=#{productId} and `unique`=#{unique}")
|
||||||
|
int incSeckillStockDecSales(@Param("num") int num,@Param("productId") Long productId,
|
||||||
|
@Param("unique") String unique);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 普通商品 减库存 加销量
|
||||||
|
* @param num
|
||||||
|
* @param productId
|
||||||
|
* @param unique
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Update("update yx_store_product_attr_value set stock=stock-#{num}, sales=sales+#{num}" +
|
||||||
|
" where product_id=#{productId} and `unique`=#{unique} and stock >= #{num}")
|
||||||
|
int decStockIncSales(@Param("num") int num, @Param("productId") Long productId,
|
||||||
|
@Param("unique") String unique);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼团产品 减库存 加销量
|
||||||
|
* @param num
|
||||||
|
* @param productId
|
||||||
|
* @param unique
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Update("update yx_store_product_attr_value set stock=stock-#{num}, pink_stock=pink_stock-#{num} ,sales=sales+#{num}" +
|
@Update("update yx_store_product_attr_value set stock=stock-#{num}, pink_stock=pink_stock-#{num} ,sales=sales+#{num}" +
|
||||||
" where product_id=#{productId} and `unique`=#{unique} and stock >= #{num} and pink_stock>=#{num}")
|
" where product_id=#{productId} and `unique`=#{unique} and stock >= #{num} and pink_stock>=#{num}")
|
||||||
int decCombinationStockIncSales(int num, Long productId, String unique);
|
int decCombinationStockIncSales(int num, Long productId, String unique);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 秒杀产品 减库存 加销量
|
||||||
|
* @param num
|
||||||
|
* @param productId
|
||||||
|
* @param unique
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Update("update yx_store_product_attr_value set stock=stock-#{num}, seckill_stock=seckill_stock-#{num},sales=sales+#{num}" +
|
@Update("update yx_store_product_attr_value set stock=stock-#{num}, seckill_stock=seckill_stock-#{num},sales=sales+#{num}" +
|
||||||
" where product_id=#{productId} and `unique`=#{unique} and stock >= #{num} and seckill_stock>=#{num}")
|
" where product_id=#{productId} and `unique`=#{unique} and stock >= #{num} and seckill_stock>=#{num}")
|
||||||
int decSeckillStockIncSales(int num, Long productId, String unique);
|
int decSeckillStockIncSales(int num, Long productId, String unique);
|
||||||
|
@ -21,35 +21,70 @@ import org.springframework.stereotype.Repository;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface StoreProductMapper extends CoreMapper<YxStoreProduct> {
|
public interface StoreProductMapper extends CoreMapper<YxStoreProduct> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正常商品库存 减库存 加销量
|
||||||
|
* @param num
|
||||||
|
* @param productId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Update("update yx_store_product set stock=stock-#{num}, sales=sales+#{num}" +
|
@Update("update yx_store_product set stock=stock-#{num}, sales=sales+#{num}" +
|
||||||
" where id=#{productId} and stock >= #{num}")
|
" where id=#{productId} and stock >= #{num}")
|
||||||
int decStockIncSales(@Param("num") int num,@Param("productId") Long productId);
|
int decStockIncSales(@Param("num") int num,@Param("productId") Long productId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正常商品库存 加库存 减销量
|
||||||
|
* @param num
|
||||||
|
* @param productId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Update("update yx_store_product set stock=stock+#{num}, sales=sales-#{num}" +
|
@Update("update yx_store_product set stock=stock+#{num}, sales=sales-#{num}" +
|
||||||
" where id=#{productId}")
|
" where id=#{productId}")
|
||||||
int incStockDecSales(@Param("num") int num,@Param("productId") Long productId);
|
int incStockDecSales(@Param("num") int num,@Param("productId") Long productId);
|
||||||
|
|
||||||
@Update("update yx_store_product set sales=sales+#{num}" +
|
|
||||||
" where id=#{productId}")
|
|
||||||
int incSales(@Param("num") int num,@Param("productId") int productId);
|
|
||||||
|
|
||||||
@Update("update yx_store_product set sales=sales-#{num}" +
|
|
||||||
" where id=#{productId}")
|
|
||||||
int decSales(@Param("num") int num,@Param("productId") Long productId);
|
|
||||||
|
|
||||||
|
|
||||||
@Update("update yx_store_product set is_del = #{status} where id = #{id}")
|
|
||||||
void updateDel(@Param("status")int status,@Param("id") Integer id);
|
|
||||||
|
|
||||||
@Update("update yx_store_product set is_show = #{status} where id = #{id}")
|
@Update("update yx_store_product set is_show = #{status} where id = #{id}")
|
||||||
void updateOnsale(@Param("status") Integer status, @Param("id") Long id);
|
void updateOnsale(@Param("status") Integer status, @Param("id") Long id);
|
||||||
|
|
||||||
//todo 拼团商品库存+—
|
/**
|
||||||
|
* 拼团商品库存,减库存 加销量
|
||||||
|
* @param num
|
||||||
|
* @param productId
|
||||||
|
* @param activityId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Update("update yx_store_combination set stock=stock-#{num}, sales=sales+#{num}" +
|
@Update("update yx_store_combination set stock=stock-#{num}, sales=sales+#{num}" +
|
||||||
" where id=#{activityId} and stock >= #{num}")
|
" where id=#{activityId} and stock >= #{num}")
|
||||||
int decCombinationStockIncSales(int num, Long productId,Long activityId);
|
int decCombinationStockIncSales(int num, Long productId,Long activityId);
|
||||||
//todo 秒杀商品库存+—
|
|
||||||
|
/**
|
||||||
|
* 秒杀产品库存 减库存,加销量
|
||||||
|
* @param num
|
||||||
|
* @param productId
|
||||||
|
* @param activityId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Update("update yx_store_seckill set stock=stock-#{num}, sales=sales+#{num}" +
|
@Update("update yx_store_seckill set stock=stock-#{num}, sales=sales+#{num}" +
|
||||||
" where id=#{activityId} and stock >= #{num}")
|
" where id=#{activityId} and stock >= #{num}")
|
||||||
int decSeckillStockIncSales(int num, Long productId,Long activityId);
|
int decSeckillStockIncSales(int num, Long productId,Long activityId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼团商品库存,加库存 减销量
|
||||||
|
* @param num
|
||||||
|
* @param productId
|
||||||
|
* @param activityId
|
||||||
|
*/
|
||||||
|
@Update("update yx_store_combination set stock=stock+#{num}, sales=sales-#{num}" +
|
||||||
|
" where id=#{activityId} and stock >= #{num}")
|
||||||
|
void incCombinationStockIncSales(Integer num, Long productId, Long activityId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 秒杀产品库存 加库存,减销量
|
||||||
|
* @param num
|
||||||
|
* @param productId
|
||||||
|
* @param activityId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Update("update yx_store_seckill set stock=stock+#{num}, sales=sales-#{num}" +
|
||||||
|
" where id=#{activityId} and stock >= #{num}")
|
||||||
|
void incSeckillStockIncSales(Integer num, Long productId, Long activityId);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user