Showing
3 changed files
with
13 additions
and
10 deletions
@@ -59,7 +59,7 @@ class CartData | @@ -59,7 +59,7 @@ class CartData | ||
59 | * @param string $shoppingKey 未登录用户唯一识别码 | 59 | * @param string $shoppingKey 未登录用户唯一识别码 |
60 | * @return array 购物车接口返回的数据 | 60 | * @return array 购物车接口返回的数据 |
61 | */ | 61 | */ |
62 | - public static function selectGoods($uid, $sku, $shoppingKey, $hasPromotion = false) | 62 | + public static function selectGoods($uid, $sku, $shoppingKey, $hasPromotion) |
63 | { | 63 | { |
64 | $param = Yohobuy::param(); | 64 | $param = Yohobuy::param(); |
65 | $param['method'] = $hasPromotion ? 'app.Shopping.selectedAndCart' : 'app.Shopping.selected'; | 65 | $param['method'] = $hasPromotion ? 'app.Shopping.selectedAndCart' : 'app.Shopping.selected'; |
@@ -111,7 +111,7 @@ class CartData | @@ -111,7 +111,7 @@ class CartData | ||
111 | public static function removeFromCart($uid, $sku, $shoppingKey, $hasPromotion = false) | 111 | public static function removeFromCart($uid, $sku, $shoppingKey, $hasPromotion = false) |
112 | { | 112 | { |
113 | $param = Yohobuy::param(); | 113 | $param = Yohobuy::param(); |
114 | - $param['method'] = $hasPromotion ? 'app.Shopping.removeAndCart' : 'app.Shopping.remove';; | 114 | + $param['method'] = $hasPromotion ? 'app.Shopping.removeAndCart' : 'app.Shopping.remove'; |
115 | $param['product_sku_list'] = $sku; | 115 | $param['product_sku_list'] = $sku; |
116 | 116 | ||
117 | if (!empty($uid)) { | 117 | if (!empty($uid)) { |
@@ -135,7 +135,7 @@ class CartModel | @@ -135,7 +135,7 @@ class CartModel | ||
135 | * @param string $shoppingKey 未登录用户唯一识别码 | 135 | * @param string $shoppingKey 未登录用户唯一识别码 |
136 | * @return array 处理之后的数据的数据 | 136 | * @return array 处理之后的数据的数据 |
137 | */ | 137 | */ |
138 | - public static function selectGoods($uid, $skuList, $shoppingKey, $hasPromotion = false) | 138 | + public static function selectGoods($uid, $skuList, $shoppingKey) |
139 | { | 139 | { |
140 | $result = array('code' => 400, 'message' => '出错啦~'); | 140 | $result = array('code' => 400, 'message' => '出错啦~'); |
141 | 141 | ||
@@ -143,8 +143,11 @@ class CartModel | @@ -143,8 +143,11 @@ class CartModel | ||
143 | if (empty($skuList)) { | 143 | if (empty($skuList)) { |
144 | break; | 144 | break; |
145 | } | 145 | } |
146 | - | ||
147 | - $select = CartData::selectGoods($uid, $skuList, $shoppingKey,$hasPromotion); | 146 | + $arr = json_decode($skuList, true); |
147 | + $arr[0]['promotion_id'] = $arr[0]['hasPromotion']; | ||
148 | + $hasPromotion = $arr[0]['hasPromotion']; | ||
149 | + $skuList = json_encode($arr); | ||
150 | + $select = CartData::selectGoods($uid, $skuList, $shoppingKey, $hasPromotion); | ||
148 | if ($select && isset($select['code'])) { | 151 | if ($select && isset($select['code'])) { |
149 | $result['code'] = $select['code']; | 152 | $result['code'] = $select['code']; |
150 | $result['message'] = $select['message']; | 153 | $result['message'] = $select['message']; |
@@ -168,8 +171,7 @@ class CartModel | @@ -168,8 +171,7 @@ class CartModel | ||
168 | $result = array('code' => 400, 'message' => '出错啦~'); | 171 | $result = array('code' => 400, 'message' => '出错啦~'); |
169 | 172 | ||
170 | // 处理sku | 173 | // 处理sku |
171 | - $sku_list = json_encode(array($sku => intval($count) )); | ||
172 | - | 174 | + $sku_list = json_encode(array(array('product_sku'=>$sku,'buy_number'=>intval($count), 'promotion_id'=>$hasPromotion))); |
173 | $remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey, $hasPromotion); | 175 | $remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey, $hasPromotion); |
174 | if ($remove && isset($remove['code'])) { | 176 | if ($remove && isset($remove['code'])) { |
175 | $result['code'] = $remove['code']; | 177 | $result['code'] = $remove['code']; |
@@ -103,8 +103,8 @@ class IndexController extends AbstractAction | @@ -103,8 +103,8 @@ class IndexController extends AbstractAction | ||
103 | $productId = $this->post('skuList', 0); | 103 | $productId = $this->post('skuList', 0); |
104 | $uid = $this->getUid(true); | 104 | $uid = $this->getUid(true); |
105 | $shoppingKey = Helpers::getShoppingKeyByCookie(); | 105 | $shoppingKey = Helpers::getShoppingKeyByCookie(); |
106 | - $hasPromotion = $this->post('hasPromotion', false); | ||
107 | - $result = CartModel::selectGoods($uid, $productId, $shoppingKey, $hasPromotion); | 106 | + |
107 | + $result = CartModel::selectGoods($uid, $productId, $shoppingKey); | ||
108 | } | 108 | } |
109 | 109 | ||
110 | $this->echoJson($result); | 110 | $this->echoJson($result); |
@@ -123,7 +123,8 @@ class IndexController extends AbstractAction | @@ -123,7 +123,8 @@ class IndexController extends AbstractAction | ||
123 | $uid = $this->getUid(true); | 123 | $uid = $this->getUid(true); |
124 | $shoppingKey = Helpers::getShoppingKeyByCookie(); | 124 | $shoppingKey = Helpers::getShoppingKeyByCookie(); |
125 | $hasPromotion = $this->post('hasPromotion', false); | 125 | $hasPromotion = $this->post('hasPromotion', false); |
126 | - $result = CartModel::removeFromCart($uid, $sku, $count, $shoppingKey); | 126 | + |
127 | + $result = CartModel::removeFromCart($uid, $sku, $count, $shoppingKey, $hasPromotion); | ||
127 | } | 128 | } |
128 | 129 | ||
129 | $this->echoJson($result); | 130 | $this->echoJson($result); |
-
Please register or login to post a comment