Authored by 梁志锋

Merge branch 'feature/cart' of http://git.dev.yoho.cn/web/yohobuy into develop

@@ -601,7 +601,7 @@ class Helpers @@ -601,7 +601,7 @@ class Helpers
601 } 601 }
602 602
603 /** 603 /**
604 - * 格式化加价购商品 604 + * 格式化加价购和赠品商品
605 * 605 *
606 * @param array $advanceGoods 加价购商品列表 606 * @param array $advanceGoods 加价购商品列表
607 * @param int $count 计商品件数 607 * @param int $count 计商品件数
@@ -615,6 +615,7 @@ class Helpers @@ -615,6 +615,7 @@ class Helpers
615 $oneGoods = array(); 615 $oneGoods = array();
616 foreach ($advanceGoods as $value) { 616 foreach ($advanceGoods as $value) {
617 $gift = array(); 617 $gift = array();
  618 + $gift['promotionId'] = $value['promotion_id'];
618 $gift['promotionTitle'] = $value['promotion_title']; 619 $gift['promotionTitle'] = $value['promotion_title'];
619 620
620 foreach ($value['goods_list'] as $single) { 621 foreach ($value['goods_list'] as $single) {
@@ -189,50 +189,7 @@ class CartModel @@ -189,50 +189,7 @@ class CartModel
189 $product = CartData::cartProductData($uid, $skn); 189 $product = CartData::cartProductData($uid, $skn);
190 if (isset($product['code']) && $product['code'] === 200) { 190 if (isset($product['code']) && $product['code'] === 200) {
191 $result['code'] = 200; 191 $result['code'] = 200;
192 - $data = array();  
193 - $productData = $product['data'];  
194 -  
195 - // 品牌信息  
196 - if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {  
197 - $data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);  
198 - }  
199 -  
200 - $data['name'] = $productData['product_name'];  
201 - $data['price'] = $productData['market_price'];  
202 - $data['salePrice'] = $productData['sales_price'];  
203 - $data['storage'] = $productData['storage_sum'];  
204 - $data['num'] = $num;  
205 -  
206 - // 商品选择  
207 - if (isset($productData['goods_list'])) {  
208 - $goodsList = $productData['goods_list'];  
209 -  
210 - $colors = array();  
211 - $oneColor = array();  
212 - $sizes = array();  
213 - $oneSize = array();  
214 - foreach ($goodsList as $val) {  
215 - // 颜色  
216 - $oneColor = array();  
217 - $oneColor['id'] = $val['color_id'];  
218 - $oneColor['name'] = $val['color_name'];  
219 -  
220 - // 尺码  
221 - foreach ($val['size_list'] as $one) {  
222 - $oneSize = array();  
223 - $oneSize['id'] = $one['size_id'];  
224 - $oneSize['name'] = $one['size_name'];  
225 - }  
226 - $sizes[] = $oneSize;  
227 -  
228 - $oneColor['sizes'] = $sizes;  
229 - $colors[] = $oneColor;  
230 - }  
231 -  
232 - $data['colors'] = $colors;  
233 - }  
234 -  
235 - $result['data'] = $data; 192 + $result['data'] = self::procGoodsDetail($product['data'], $num);
236 } 193 }
237 194
238 return $result; 195 return $result;
@@ -252,49 +209,7 @@ class CartModel @@ -252,49 +209,7 @@ class CartModel
252 $product = CartData::giftProductData($skn, $promotionId); 209 $product = CartData::giftProductData($skn, $promotionId);
253 if (isset($product['code']) && $product['code'] === 200) { 210 if (isset($product['code']) && $product['code'] === 200) {
254 $result['code'] = 200; 211 $result['code'] = 200;
255 - $data = array();  
256 - $productData = $product['data'];  
257 -  
258 - // 品牌信息  
259 - if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {  
260 - $data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);  
261 - }  
262 -  
263 - $data['name'] = $productData['product_name'];  
264 - $data['price'] = $productData['market_price'];  
265 - $data['salePrice'] = $productData['sales_price'];  
266 - $data['storage'] = $productData['storage_sum'];  
267 -  
268 - // 商品选择  
269 - if (isset($productData['goods_list'])) {  
270 - $goodsList = $productData['goods_list'];  
271 -  
272 - $colors = array();  
273 - $oneColor = array();  
274 - $sizes = array();  
275 - $oneSize = array();  
276 - foreach ($goodsList as $val) {  
277 - // 颜色  
278 - $oneColor = array();  
279 - $oneColor['id'] = $val['color_id'];  
280 - $oneColor['name'] = $val['color_name'];  
281 -  
282 - // 尺码  
283 - foreach ($val['size_list'] as $one) {  
284 - $oneSize = array();  
285 - $oneSize['id'] = $one['size_id'];  
286 - $oneSize['name'] = $one['size_name'];  
287 - }  
288 - $sizes[] = $oneSize;  
289 -  
290 - $oneColor['sizes'] = $sizes;  
291 - $colors[] = $oneColor;  
292 - }  
293 -  
294 - $data['colors'] = $colors;  
295 - }  
296 -  
297 - $result['data'] = $data; 212 + $result['data'] = self::procGoodsDetail($product['data']);
298 } 213 }
299 214
300 return $result; 215 return $result;
@@ -657,6 +572,62 @@ class CartModel @@ -657,6 +572,62 @@ class CartModel
657 572
658 573
659 /** 574 /**
  575 + * 处理购物车商品、加价购商品、赠品详情数据
  576 + *
  577 + * @param array $productData 要处理的商品数据
  578 + * @param int $num 购买数目
  579 + * @return array $data 处理之后的数据
  580 + */
  581 + private static function procGoodsDetail($productData, $num = null)
  582 + {
  583 + $data = array();
  584 +
  585 + // 品牌信息
  586 + if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
  587 + $data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
  588 + }
  589 +
  590 + $data['name'] = $productData['product_name'];
  591 + $data['price'] = $productData['market_price'];
  592 + $data['salePrice'] = $productData['sales_price'];
  593 + $data['storage'] = $productData['storage_sum'];
  594 + if ($num !== null) {
  595 + $data['num'] = $num;
  596 + }
  597 +
  598 + // 商品选择
  599 + if (isset($productData['goods_list'])) {
  600 + $goodsList = $productData['goods_list'];
  601 +
  602 + $colors = array();
  603 + $oneColor = array();
  604 + $sizes = array();
  605 + $oneSize = array();
  606 + foreach ($goodsList as $val) {
  607 + // 颜色
  608 + $oneColor = array();
  609 + $oneColor['id'] = $val['color_id'];
  610 + $oneColor['name'] = $val['color_name'];
  611 +
  612 + // 尺码
  613 + foreach ($val['size_list'] as $one) {
  614 + $oneSize = array();
  615 + $oneSize['id'] = $one['size_id'];
  616 + $oneSize['name'] = $one['size_name'];
  617 + }
  618 + $sizes[] = $oneSize;
  619 +
  620 + $oneColor['sizes'] = $sizes;
  621 + $colors[] = $oneColor;
  622 + }
  623 +
  624 + $data['colors'] = $colors;
  625 + }
  626 +
  627 + return $data;
  628 + }
  629 +
  630 + /**
660 * 处理不同类型的购物车数据 631 * 处理不同类型的购物车数据
661 * 632 *
662 * @param array $data 不同类型购物车数据 633 * @param array $data 不同类型购物车数据
@@ -191,6 +191,16 @@ class IndexController extends AbstractAction @@ -191,6 +191,16 @@ class IndexController extends AbstractAction
191 } 191 }
192 192
193 /* 193 /*
  194 + * 获取购物车加价购商品数据模板
  195 + */
  196 + public function giftinfoTplAction()
  197 + {
  198 + if ($this->isAjax()) {
  199 + echo file_get_contents($this->_view->getScriptPath() . '/../partials/cart/chose-panel.phtml');
  200 + }
  201 + }
  202 +
  203 + /*
194 * 获取购物车加价购商品数据 204 * 获取购物车加价购商品数据
195 */ 205 */
196 public function giftinfoAction() 206 public function giftinfoAction()