|
@@ -170,12 +170,19 @@ class Buy extends Core
|
|
|
$where['num'] = $num;
|
|
|
|
|
|
# 验证库存
|
|
|
- Dever::load('shop/lib/info')->checkTotal($where['num'], $info['goods_id'], $this->shop_id, $info['sku_id'], 2);
|
|
|
+ $total = Dever::load('shop/lib/info')->checkTotal($num, $info['goods_id'], $this->shop_id, $info['sku_id']);
|
|
|
+
|
|
|
+ if ($where['num'] > $total) {
|
|
|
+ # 库存不足
|
|
|
+ $where['num'] = $total;
|
|
|
+ $state = Dever::db('shop/cart')->update($where);
|
|
|
+ return array('cart' => 2, 'data' => $total);
|
|
|
+ }
|
|
|
$state = Dever::db('shop/cart')->update($where);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return $this->getCart();
|
|
|
+ return array('cart' => 1, 'data' => $this->getCart());
|
|
|
}
|
|
|
|
|
|
# 确认订单页面
|