问答 / 1908 / 4 / 创建于 5年前
@leo 如上所说,商品减库存改成这种方式后,是如何支持高并发的?不太理解?求解。
并不是这样就能支持高并发,而是在高并发的情况下不会超卖
update(['stock' => $sku->stock - $amount]) 变成 SQL 语句之后是直接 :
update(['stock' => $sku->stock - $amount])
update product_skus set stock = stock - $amount where id = $id
而修改后的 :
update product_skus set stock = stock - $amount where id = $id and stock >= $amount
是这个意思么?
@Larwas 有道理
@Larwas @GEt!
我要举报该,理由是:
推荐文章: