Authored by 梁志锋

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

@@ -40,11 +40,11 @@ class CartData @@ -40,11 +40,11 @@ class CartData
40 $param['selected'] = 'Y'; 40 $param['selected'] = 'Y';
41 $param['promotion_id'] = $promotionId; 41 $param['promotion_id'] = $promotionId;
42 42
43 - if ($uid !== null) { 43 + if (!empty($uid)) {
44 $param['uid'] = $uid; 44 $param['uid'] = $uid;
45 } 45 }
46 if ($shoppingKey !== null) { 46 if ($shoppingKey !== null) {
47 - $param['shoppingKey'] = $shoppingKey; 47 + $param['shopping_key'] = $shoppingKey;
48 } 48 }
49 $param['client_secret'] = Sign::getSign($param); 49 $param['client_secret'] = Sign::getSign($param);
50 50
@@ -570,6 +570,7 @@ class Helpers @@ -570,6 +570,7 @@ class Helpers
570 570
571 $oneGoods = array(); 571 $oneGoods = array();
572 foreach ($cartGoods as $key => $value) { 572 foreach ($cartGoods as $key => $value) {
  573 + $oneGoods = array();
573 $oneGoods['id'] = $value['product_sku']; 574 $oneGoods['id'] = $value['product_sku'];
574 $oneGoods['skn'] = $value['product_skn']; 575 $oneGoods['skn'] = $value['product_skn'];
575 $oneGoods['name'] = $value['product_name']; 576 $oneGoods['name'] = $value['product_name'];
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 {{#if advanceBuyPage}} 3 {{#if advanceBuyPage}}
4 {{# advanceBuy}} 4 {{# advanceBuy}}
5 <div class="advance-block" data-promotion-id="{{promotionId}}"> 5 <div class="advance-block" data-promotion-id="{{promotionId}}">
6 - <p class="title">{{title}}</p> 6 + <p class="title">{{promotionTitle}}</p>
7 {{#goods}} 7 {{#goods}}
8 {{> cart/gift-advance-good}} 8 {{> cart/gift-advance-good}}
9 {{/goods}} 9 {{/goods}}
@@ -70,10 +70,17 @@ @@ -70,10 +70,17 @@
70 70
71 {{#if yohoCoin}} 71 {{#if yohoCoin}}
72 <span class="desc">可抵¥{{yohoCoin}}</span> 72 <span class="desc">可抵¥{{yohoCoin}}</span>
  73 + {{#if useYohoCoin}}
73 <span class="coin-check"> 74 <span class="coin-check">
74 <em>- ¥ {{yohoCoin}}</em> 75 <em>- ¥ {{yohoCoin}}</em>
75 <i class="iconfont checkbox icon-cb-checked"></i> 76 <i class="iconfont checkbox icon-cb-checked"></i>
76 </span> 77 </span>
  78 + {{else}}
  79 + <span class="coin-check">
  80 + <em style="display: none;">- ¥ {{yohoCoin}}</em>
  81 + <i class="iconfont checkbox icon-checkbox"></i>
  82 + </span>
  83 + {{/if}}
77 {{^}} 84 {{^}}
78 <span class="not-used coin-check"> 85 <span class="not-used coin-check">
79 无YOHO币可用 86 无YOHO币可用
@@ -415,6 +415,7 @@ class CartModel @@ -415,6 +415,7 @@ class CartModel
415 $oneGoods['gift'] = true; 415 $oneGoods['gift'] = true;
416 } elseif ($single['goods_type'] == 'price_gift') { 416 } elseif ($single['goods_type'] == 'price_gift') {
417 $oneGoods['advanceBuy'] = true; 417 $oneGoods['advanceBuy'] = true;
  418 + $oneGoods['price'] = Helpers::transPrice($single['sale_price']);
418 } 419 }
419 420
420 $result['goods'][] = $oneGoods; 421 $result['goods'][] = $oneGoods;
@@ -440,7 +441,8 @@ class CartModel @@ -440,7 +441,8 @@ class CartModel
440 } 441 }
441 442
442 // 有货币 443 // 有货币
443 - $result['yohoCoin'] = (isset($orderCompute['use_yoho_coin']) && !empty($orderCompute['use_yoho_coin'])) ? $orderCompute['use_yoho_coin'] : $payReturn['yoho_coin']; 444 + $result['yohoCoin'] = $payReturn['yoho_coin'];
  445 + $result['useYohoCoin'] = isset($orderCompute['use_yoho_coin']) ? $orderCompute['use_yoho_coin'] : $payReturn['yoho_coin'];
444 446
445 // 订单数据 447 // 订单数据
446 if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) { 448 if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) {
@@ -662,16 +664,9 @@ class CartModel @@ -662,16 +664,9 @@ class CartModel
662 $colorNum += $one['storage_number']; 664 $colorNum += $one['storage_number'];
663 $sizeStorageStr .= $one['storage_number'] . '/'; 665 $sizeStorageStr .= $one['storage_number'] . '/';
664 666
665 - $sizeList[$val['color_id']][] = $oneSize; 667 + $sizeList[$val['product_skc']][] = $oneSize;
666 668
667 - $colorStorageGroup[$one['size_name']][$val['color_name']] = $one['storage_number'];  
668 - }  
669 -  
670 - // 统计尺码对应的各个颜色的库存量  
671 - foreach ($sizes as $colorId => $sizeArr) {  
672 - foreach ($sizeArr as $key => $value) {  
673 - $sizeList[$colorId][$key]['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) );  
674 - } 669 + $colorStorageGroup[$val['product_skc']][$one['size_name']] = $one['storage_number'];
675 } 670 }
676 671
677 // 颜色 672 // 颜色
@@ -695,9 +690,24 @@ class CartModel @@ -695,9 +690,24 @@ class CartModel
695 $totalStorageNum += $colorNum; 690 $totalStorageNum += $colorNum;
696 } 691 }
697 692
  693 + // 遍历所有尺码,统计出该尺码的每个颜色的库存量,没有时添0,不能空着,因为JS中需要判断
  694 + foreach ($sizeList as $skc => $sizeArr) {
  695 + foreach ($sizeArr as $key => $value) {
  696 + $sizeStorageStr = '';
  697 + foreach ($colorStorageGroup as $colorArr) {
  698 + if (isset($colorArr[ $value['name'] ])) {
  699 + $sizeStorageStr .= $colorArr[ $value['name'] ] . '/';
  700 + } else {
  701 + $sizeStorageStr .= '0/';
  702 + }
  703 + }
  704 + $sizeList[$skc][$key]['colorNumStr'] = rtrim($sizeStorageStr, '/');
  705 + }
  706 + }
  707 +
698 // 格式化尺码对应的各个颜色分组 708 // 格式化尺码对应的各个颜色分组
699 foreach ($colors as $color) { 709 foreach ($colors as $color) {
700 - $sizes[]['size'] = $sizeList[$color['id']]; 710 + $sizes[]['size'] = $sizeList[$color['skcId']];
701 } 711 }
702 712
703 $data['thumbs'] = $thumbImageList; 713 $data['thumbs'] = $thumbImageList;
@@ -36,7 +36,7 @@ class IndexController extends AbstractAction @@ -36,7 +36,7 @@ class IndexController extends AbstractAction
36 public function indexAction() 36 public function indexAction()
37 { 37 {
38 $this->setTitle('购物车'); 38 $this->setTitle('购物车');
39 - $this->setNavHeader('购物车'); 39 + $this->setNavHeader('购物车', true, '');
40 40
41 $shoppingKey = Helpers::getShoppingKeyByCookie(); 41 $shoppingKey = Helpers::getShoppingKeyByCookie();
42 $uid = $this->getUid(true); 42 $uid = $this->getUid(true);
@@ -275,14 +275,20 @@ class IndexController extends AbstractAction @@ -275,14 +275,20 @@ class IndexController extends AbstractAction
275 $this->setNavHeader('确认订单', Helpers::url('/cart/index/index'), false); // 不显示右上角home按钮 275 $this->setNavHeader('确认订单', Helpers::url('/cart/index/index'), false); // 不显示右上角home按钮
276 276
277 // 购物车商品为空跳转到购物车页面 277 // 购物车商品为空跳转到购物车页面
  278 + $cartType = $this->get('cartType', 'ordinary');
  279 + $cartKey = 'commonCart';
  280 + if ($cartType === 'advance') {
  281 + $cartKey = 'preSellCart';
  282 + }
  283 +
278 $shoppingKey = Helpers::getShoppingKeyByCookie(); 284 $shoppingKey = Helpers::getShoppingKeyByCookie();
279 $uid = $this->getUid(true); 285 $uid = $this->getUid(true);
280 $cartGoods = CartModel::getCartData($uid, $shoppingKey); 286 $cartGoods = CartModel::getCartData($uid, $shoppingKey);
281 - if (empty($cartGoods) || isset($cartGoods['isEmptyCart'])) { 287 + if (isset($cartGoods['isEmptyCart']) || empty($cartGoods[$cartKey])) {
282 $this->go(Helpers::url('/cart/index/index')); 288 $this->go(Helpers::url('/cart/index/index'));
283 } 289 }
284 290
285 - $cartType = $this->get('cartType', 'ordinary'); 291 +
286 $cookieData = $this->getCookie('order-info', null); 292 $cookieData = $this->getCookie('order-info', null);
287 $uid = $this->getUid(true); 293 $uid = $this->getUid(true);
288 $data = array( 294 $data = array(
@@ -451,7 +457,7 @@ class IndexController extends AbstractAction @@ -451,7 +457,7 @@ class IndexController extends AbstractAction
451 457
452 // 设置加入购物车凭证到客户端浏览器 458 // 设置加入购物车凭证到客户端浏览器
453 if (!$shoppingKey && isset($result['data']['shopping_key'])) { 459 if (!$shoppingKey && isset($result['data']['shopping_key'])) {
454 - $this->setCookie('_spk', $result['data']['shopping_key']); 460 + $this->setCookie('_Spk', $result['data']['shopping_key']);
455 } 461 }
456 } 462 }
457 463