记录一下方法
- 在订单表加上 orderID和userID 为唯一索引
- 在生成订单表之前会有一个减少库存的操作,在这一步加上数量大于0的操作
@Update("update miaosha_goods set stock_count = stock_count - 1 where goods_id = #{goodsId} and stock_count > 0")
数据库更新记录的时候会加锁,实际上是串行的执行update的,因此绝对不会卖超!
记录一下方法
@Update("update miaosha_goods set stock_count = stock_count - 1 where goods_id = #{goodsId} and stock_count > 0")
数据库更新记录的时候会加锁,实际上是串行的执行update的,因此绝对不会卖超!