作者 何书鹏

加入购物车库存判断

... ... @@ -303,7 +303,8 @@ class Order extends Api
$model = new GoodsSpec();
$sku = $model::get($sku_id);
if (!$sku) $this->error('规格已失效,请重新选择');
if ($sku['stock_num'] < $number) $this->error('已超出最大库存');
$cart_number = \app\api\model\Cart::where('sku_id',$sku_id)->sum('number');
if ($sku['stock_num'] < $number+$cart_number) $this->error('已超出最大库存');
$this->success('SUCCESS');
}
... ...