|
@@ -1,4 +1,4 @@
|
|
|
-000000000000000<?php
|
|
|
+<?php
|
|
|
/**
|
|
|
* 我的购物车
|
|
|
*
|
|
@@ -25,12 +25,15 @@ class member_cartControl extends mobileMemberControl
|
|
|
$model_cart = Model('cart');
|
|
|
$model_goods = Model('goods');
|
|
|
|
|
|
+
|
|
|
$condition = array('buyer_id' => $this->member_info['member_id']);
|
|
|
$cart_list = $model_cart->listCart('db', $condition);
|
|
|
$sum = 0;
|
|
|
- foreach ($cart_list as $key => $value) {
|
|
|
+ foreach ($cart_list as $key => $value)
|
|
|
+ {
|
|
|
$goods_id = $value['goods_id'];
|
|
|
$goods_promotion = $model_goods->getGoodsInfoAndPromotionById($goods_id);
|
|
|
+ $goos_storage = $model_goods->getGoodsStorageById($goods_id);
|
|
|
$promotion_type = '';
|
|
|
$promotion_price = '0.00';
|
|
|
if(!empty( $goods_promotion['groupbuy_info'])){
|
|
@@ -43,9 +46,12 @@ class member_cartControl extends mobileMemberControl
|
|
|
}
|
|
|
$goods_spec = unserialize($goods_promotion['goods_spec']);
|
|
|
$goods_spec_array = array();
|
|
|
- foreach ($goods_spec as $value) {
|
|
|
- array_push($goods_spec_array, $value);
|
|
|
+
|
|
|
+ foreach ($goods_spec as $val) {
|
|
|
+ array_push($goods_spec_array, $val);
|
|
|
}
|
|
|
+
|
|
|
+ $cart_list[$key]['goos_storage'] = $goos_storage;
|
|
|
$cart_list[$key]['goods_spec'] = implode(',', $goods_spec_array);
|
|
|
$cart_list[$key]['promotion_type'] = $promotion_type;
|
|
|
$cart_list[$key]['promotion_price'] = $promotion_price;
|
|
@@ -109,11 +115,14 @@ class member_cartControl extends mobileMemberControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function cart_editOp(){
|
|
|
+ public function cart_editOp()
|
|
|
+ {
|
|
|
$cart_list = explode(',', urldecode($_POST['cart_list']));
|
|
|
$new_cart_list= array();
|
|
|
- if (is_array($cart_list)) {
|
|
|
- foreach ($cart_list as $value) {
|
|
|
+ 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) {
|
|
|
$new_cart_list[$match[1][0]] = $match[2][0];
|
|
@@ -125,34 +134,42 @@ class member_cartControl extends mobileMemberControl
|
|
|
$condition = array('buyer_id' => $this->member_info['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, $this->member_info['member_id'])) {
|
|
|
array_push($quantity_error, array('cart_id' => $value['cart_id'], 'quantity' => $quantity));
|
|
|
- }else{
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
$data = array();
|
|
|
$data['goods_num'] = $quantity;
|
|
|
$update = $model_cart->editCart($data, array('cart_id'=> $value['cart_id']));
|
|
|
- if(!$update){
|
|
|
+ if(!$update) {
|
|
|
joutput_error(errcode::ErrCart, '购物车修改失败');
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
- $delete = $model_cart->delCart('db', array('cart_id'=>$cart_id));
|
|
|
- if(!$delete){
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $delete = $model_cart->delCart('db', array('cart_id'=>$value['cart_id']));
|
|
|
+ if(!$delete) {
|
|
|
joutput_error(errcode::ErrCart, '购物车修改失败');
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(count($quantity_error) > 0){
|
|
|
+
|
|
|
+ if(count($quantity_error) > 0) {
|
|
|
joutput_data(array('result'=> '0', 'quantity_error' => $quantity_error));
|
|
|
- }else{
|
|
|
- joutput_data(array('result'=> '1'));
|
|
|
+ } else {
|
|
|
+ joutput_data(array('result' => '1'));
|
|
|
}
|
|
|
}else{
|
|
|
joutput_error(errcode::ErrCart, '购物车列表格式错误');
|