作者 SHW\戥岁。。

购物车加入错误

... ... @@ -53,16 +53,16 @@ class Cart extends Api
}
$model->where('id', $cart['id'])->delete();
}
$spec_sku = new Litestoregoodsspec();
$spec_sku = new Litestoregoodsspec();
$spec_info = $spec_sku->where('goods_spec_id', $sku_id)->find();
if ($cart) {
$spec_sku->where('goods_spec_id', $sku_id)->find();
if ($spec_sku['stock_num'] + $cart['number'] < $number) {
if ($spec_info['stock_num'] + $cart['number'] < $number) {
$this->error('库存不足');
}
$cart->setInc('number', $number);
} else {
$spec_sku->where('goods_spec_id', $sku_id)->find();
if ($spec_sku['stock_num'] < $number) {
if ($spec_info['stock_num'] < $number) {
$this->error('库存不足');
}
$data['number'] = $number;
... ...