悲观锁和乐观锁之乐观锁
修改内存的sql
update eb_sku t
set t.stock_inventory = t.stock_inventory - #{quanttity}
where t.sku_id = 1020
and t.stock > #{quanttity}
模拟线程并发问题(加上and 可以减少数据并非的问题 判断库存是否足够)
实例1
update eb_sku t
set t.stock_inventory = t.stock_inventory - 2
where t.sku_id = 1020实例2
update eb_sku t
set t.stock_inventory = t.stock_inventory - 3
where t.sku_id = 1020
一些js代码
<c:choose>
<span style="white-space:pre"> </span><c:when test ="${tip == 'stock_error'}">
<span style="white-space:pre"> </span><p class = "okMsg">对不起货已经被抢光</p>
<span style="white-space:pre"> </span></c:when>
<span style="white-space:pre"> </span><c:otherwise>
<span style="white-space:pre"> </span>---其他内容--
<span style="white-space:pre"> </span></c:otherwise>
</c:choose>
最后
以上就是悦耳唇彩最近收集整理的关于电商的库存修改的全部内容,更多相关电商内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复