大講臺大數(shù)據(jù)運維尖刀班 四期
// 根據(jù)商品id獲取商品剩余庫存select stock_remaing from stock_table where id=${goodsId};// 操作庫存// 比較庫存if(stock_remaing <quantity){
? // 拋出庫存不足的異常}else{// 抵扣以后的庫存值int new_stock=stock_remaing - quantity;}// 根據(jù)商品id設(shè)置計算后的庫存update stock_table ?set stock_remaing =${new_stock} id=${goodsId};
標簽: