Authored by hf

code review by hf: do modify cart list add cartType parameter

@@ -191,7 +191,7 @@ class SaeTOAuthV2 { @@ -191,7 +191,7 @@ class SaeTOAuthV2 {
191 $params['username'] = $keys['username']; 191 $params['username'] = $keys['username'];
192 $params['password'] = $keys['password']; 192 $params['password'] = $keys['password'];
193 } else { 193 } else {
194 - throw new OAuthException("wrong auth type"); 194 + throw new \OAuthException("wrong auth type");
195 } 195 }
196 196
197 $response = $this->oAuthRequest($this->accessTokenURL(), 'POST', $params); 197 $response = $this->oAuthRequest($this->accessTokenURL(), 'POST', $params);
@@ -200,7 +200,7 @@ class SaeTOAuthV2 { @@ -200,7 +200,7 @@ class SaeTOAuthV2 {
200 $this->access_token = $token['access_token']; 200 $this->access_token = $token['access_token'];
201 //$this->refresh_token = $token['refresh_token']; 201 //$this->refresh_token = $token['refresh_token'];
202 } else { 202 } else {
203 - throw new OAuthException("get access token failed." . $token['error']); 203 + throw new \OAuthException("get access token failed." . $token['error']);
204 } 204 }
205 return $token; 205 return $token;
206 } 206 }
@@ -52,7 +52,7 @@ class CartModel @@ -52,7 +52,7 @@ class CartModel
52 */ 52 */
53 public static function getCartData($uid, $shoppingKey, $cartType = 'all', $onlyGift = false, $onlyAdvanceBuy = false) 53 public static function getCartData($uid, $shoppingKey, $cartType = 'all', $onlyGift = false, $onlyAdvanceBuy = false)
54 { 54 {
55 - $result = array('cartNav' => true, 'commonGoodsCount' => '0', 'presellGoodsCount' => '0'); 55 + $result = array('cartNav' => false, 'commonGoodsCount' => '0', 'presellGoodsCount' => '0');
56 56
57 // 用户是否登录 57 // 用户是否登录
58 if (empty($uid)) { 58 if (empty($uid)) {
@@ -65,15 +65,13 @@ class CartModel @@ -65,15 +65,13 @@ class CartModel
65 65
66 // 处理普通购物车和预售购物车的数据 66 // 处理普通购物车和预售购物车的数据
67 do { 67 do {
68 - if (!isset($cartData['data']) || empty($cartData['data'])) {  
69 -// $result['isEmptyCart'] = true; 68 + if (empty($cartData['data'])) {
  69 + $result['isEmptyCart'] = true;
70 break; 70 break;
71 } 71 }
72 72
73 $cart = $cartData['data']; 73 $cart = $cartData['data'];
74 74
75 - $result['cartNav'] = true;  
76 -  
77 if ($cartType !== 'all') { // 加价购或者赠品数据 75 if ($cartType !== 'all') { // 加价购或者赠品数据
78 $result = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy); 76 $result = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy);
79 break; 77 break;
@@ -86,15 +84,32 @@ class CartModel @@ -86,15 +84,32 @@ class CartModel
86 $result['isEmptyCart'] = true; 84 $result['isEmptyCart'] = true;
87 break; 85 break;
88 } 86 }
89 - if ($ordinaryCount === '0' || $advanceCount === '0') { 87 +
  88 + // 普通购物车空,则显示预售购物车
  89 + if ($ordinaryCount === '0') {
90 $result['cartNav'] = false; 90 $result['cartNav'] = false;
  91 + $result['cartType'] = 'advance';
  92 + }
  93 + // 预售购物车空,则显示普通购物车
  94 + elseif ($advanceCount === '0') {
  95 + $result['cartNav'] = false;
  96 + $result['cartType'] = 'ordinary';
  97 + }
  98 + // 以上两个购物车中都有数据, 默认显示普通购物车
  99 + else {
  100 + $result['cartNav'] = true;
  101 + $result['cartType'] = 'ordinary';
91 } 102 }
  103 +
  104 +
  105 +
92 /* 普通购物车 */ 106 /* 普通购物车 */
93 $result['commonGoodsCount'] = $ordinaryCount; 107 $result['commonGoodsCount'] = $ordinaryCount;
94 $result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy); 108 $result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy);
95 /* 预售购物车 */ 109 /* 预售购物车 */
96 $result['presellGoodsCount'] = $advanceCount; 110 $result['presellGoodsCount'] = $advanceCount;
97 $result['preSellCart'] = self::procCartData($cart['advance_cart_data'], $onlyGift, $onlyAdvanceBuy); 111 $result['preSellCart'] = self::procCartData($cart['advance_cart_data'], $onlyGift, $onlyAdvanceBuy);
  112 +
98 } while(false); 113 } while(false);
99 114
100 return $result; 115 return $result;