|
@@ -332,7 +332,8 @@ class cartControl extends mobileControl
|
|
|
|
|
|
$cart_list = explode(',', urldecode($_POST['cart_list']));
|
|
|
$new_cart_list = array();
|
|
|
- if (is_array($cart_list)) {
|
|
|
+ if (is_array($cart_list))
|
|
|
+ {
|
|
|
foreach ($cart_list as $value) {
|
|
|
if (preg_match_all('/^(\d{1,10})\|(\d{1,6})$/', $value, $match)) {
|
|
|
if (intval($match[2][0]) > 0) {
|
|
@@ -345,10 +346,13 @@ class cartControl extends mobileControl
|
|
|
$condition = array('buyer_id' => $_SESSION['member_id']);
|
|
|
$original_cart_list = $model_cart->listCart('db', $condition);
|
|
|
$quantity_error = array();
|
|
|
- foreach ($original_cart_list as $key => $value) {
|
|
|
- if (array_key_exists($value['cart_id'], $new_cart_list)) {
|
|
|
+ foreach ($original_cart_list as $key => $value)
|
|
|
+ {
|
|
|
+ if (array_key_exists($value['cart_id'], $new_cart_list))
|
|
|
+ {
|
|
|
$quantity = intval($new_cart_list[$value['cart_id']]);
|
|
|
- if (intval($value['goods_num']) !== $quantity) {
|
|
|
+ if (intval($value['goods_num']) !== $quantity)
|
|
|
+ {
|
|
|
if (!$this->_check_goods_storage($value, $quantity, $_SESSION['member_id'])) {
|
|
|
array_push($quantity_error, array('cart_id' => $value['cart_id'], 'quantity' => $quantity, 'err_info' => '库存不足'));
|
|
|
} else {
|
|
@@ -356,25 +360,28 @@ class cartControl extends mobileControl
|
|
|
$data['goods_num'] = $quantity;
|
|
|
$update = $model_cart->editCart($data, array('cart_id' => $value['cart_id']));
|
|
|
if (!$update) {
|
|
|
- return joutput_error(errcode::ErrCart, '购物车修改失败');
|
|
|
+ return self::outerr(errcode::ErrCart, '购物车修改失败');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
$delete = $model_cart->delCart('db', array('cart_id' => $value['cart_id']));
|
|
|
if (!$delete) {
|
|
|
- return joutput_error(errcode::ErrCart, '购物车修改失败');
|
|
|
+ return self::outerr(errcode::ErrCart, '购物车修改失败');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (count($quantity_error) > 0) {
|
|
|
- joutput_data(array('result' => '0', 'quantity_error' => $quantity_error));
|
|
|
+ self::outsuccess(array('result' => '0', 'quantity_error' => $quantity_error));
|
|
|
} else {
|
|
|
- joutput_data(array('result' => '1'));
|
|
|
+ self::outsuccess(array('result' => '1','quantity_error' => NULL));
|
|
|
}
|
|
|
- } else {
|
|
|
- return joutput_error(errcode::ErrCart, '购物车列表格式错误');
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return self::outerr(errcode::ErrCart, '购物车列表格式错误');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -552,7 +559,7 @@ class cartControl extends mobileControl
|
|
|
$model_cart->delCart('db', $condition);
|
|
|
}
|
|
|
|
|
|
- joutput_data(array('result' => '1'));
|
|
|
+ self::outsuccess(array('result' => '1'));
|
|
|
}
|
|
|
|
|
|
/**
|