Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

下单锁库存,超卖 #353

Open
wangjia2016 opened this issue May 31, 2020 · 1 comment
Open

下单锁库存,超卖 #353

wangjia2016 opened this issue May 31, 2020 · 1 comment

Comments

@wangjia2016
Copy link

/**
* 锁定下单商品的所有库存
*/
private void lockStock(List cartPromotionItemList) {
for (CartPromotionItem cartPromotionItem : cartPromotionItemList) {
PmsSkuStock skuStock = skuStockMapper.selectByPrimaryKey(cartPromotionItem.getProductSkuId());
skuStock.setLockStock(skuStock.getLockStock() + cartPromotionItem.getQuantity());
skuStockMapper.updateByPrimaryKeySelective(skuStock);
}
}

1、建议采用redis的分布式锁进行控制处理 redisson这种
2、我看功能规划里面有秒杀,秒杀库存设置为1,这样必定会导致超卖了,这样就是重大事故了

@liaojiexin
Copy link

我也看到了,3年的问题还是没改,感觉这个项目只适合初学者,就是那种刚刚学框架的那种,里面还是有很多问题。给作者提个建议:希望作者看到可以把重点放到一些并发性能等等生产环境问题上的处理,一般的业务问题不需要做的太复杂(curd那种),这样的项目反而有利于其他人学习进步。 @macrozheng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants