bug下单时普通商品库存不足

This commit is contained in:
xuwenbo
2020-09-09 10:57:30 +08:00
parent 9dd0147819
commit ba68425fe3
3 changed files with 12 additions and 9 deletions

View File

@ -148,19 +148,22 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
//先处理商品库存,活动商品也要处理,因为共享库存
int product = storeProductMapper.decStockIncSales(num,productId);
if(product == 0) {
throw new YshopException("商品库存不足");
throw new YshopException("共享商品库存不足");
}
//处理商品外层显示的库存
int res = 0;
if("combination".equals(type)){
res = storeProductMapper.decCombinationStockIncSales(num,productId,activityId);
int combinationRes = storeProductMapper.decCombinationStockIncSales(num,productId,activityId);
if(combinationRes == 0) {
throw new YshopException("拼团商品库存不足");
}
}else if("seckill".equals(type)){
res = storeProductMapper.decSeckillStockIncSales(num,productId,activityId);
int seckillRes = storeProductMapper.decSeckillStockIncSales(num,productId,activityId);
if(seckillRes == 0) {
throw new YshopException("秒杀商品库存不足");
}
}
//todo 处理砍价库存
if(res == 0) {
throw new YshopException("商品库存不足");
}
}