Authored by Rock Zhang

修复收藏的品牌以及商品会1限循环的bug(接口返回数据格式变化导致)

Code Review By Rock Zhang
@@ -633,8 +633,15 @@ class CartModel @@ -633,8 +633,15 @@ class CartModel
633 $data = array(); 633 $data = array();
634 634
635 $data['name'] = $productData['product_name']; 635 $data['name'] = $productData['product_name'];
636 - $data['price'] = $productData['format_market_price'];  
637 - $data['salePrice'] = $productData['format_sales_price']; 636 + if (isset($productData['special_price'])) { // 加价购或者赠品的销售价字段
  637 + $data['price'] = $productData['format_market_price'];
  638 + $data['salePrice'] = $productData['format_sales_price'];
  639 +
  640 + } else { // 购物车商品的销售价字段
  641 + $data['price'] = $productData['market_price'] > $productData['sales_price'] ? $productData['format_market_price'] : false;
  642 + $data['salePrice'] = '¥' . Helpers::transPrice($productData['sales_price']);
  643 + }
  644 +
638 645
639 if (isset($productData['storage_sum'])) { 646 if (isset($productData['storage_sum'])) {
640 $data['storage'] = $productData['storage_sum']; 647 $data['storage'] = $productData['storage_sum'];
@@ -188,7 +188,7 @@ class UserModel @@ -188,7 +188,7 @@ class UserModel
188 $favProduct = UserData::favoriteProductData($uid, $page, $limit); 188 $favProduct = UserData::favoriteProductData($uid, $page, $limit);
189 189
190 // 处理用户收藏的商品数据 190 // 处理用户收藏的商品数据
191 - if (isset($favProduct['data']) && !empty($favProduct['data']['product_list'])) { 191 + if (isset($favProduct['data']) && $page <= $favProduct['data']['page_total']) {
192 $datas = array(); 192 $datas = array();
193 $product = array(); 193 $product = array();
194 foreach ($favProduct['data']['product_list'] as $val) { 194 foreach ($favProduct['data']['product_list'] as $val) {
@@ -210,7 +210,7 @@ class UserModel @@ -210,7 +210,7 @@ class UserModel
210 $datas[] = $product; 210 $datas[] = $product;
211 } 211 }
212 !empty($datas) && $result['hasFavProduct'] = $datas; 212 !empty($datas) && $result['hasFavProduct'] = $datas;
213 - } else if ($page > 1 && !isset($favProduct['data']['product_list'])) { 213 + } else if (($page > 1 && !$favProduct) || $page > $favProduct['data']['page_total']) {
214 $result['end'] = true; 214 $result['end'] = true;
215 } 215 }
216 216
@@ -234,7 +234,7 @@ class UserModel @@ -234,7 +234,7 @@ class UserModel
234 $favBrand = UserData::favoriteBrandData($uid, $gender, $page, $limit); 234 $favBrand = UserData::favoriteBrandData($uid, $gender, $page, $limit);
235 235
236 // 处理用户收藏的品牌数据 236 // 处理用户收藏的品牌数据
237 - if (isset($favBrand['data']) && !empty($favBrand['data']['brand_list'])) { 237 + if (isset($favBrand['data']) && $page <= $favBrand['data']['page_total']) {
238 $datas = array(); 238 $datas = array();
239 $brand = array(); 239 $brand = array();
240 foreach ($favBrand['data']['brand_list'] as $val) { 240 foreach ($favBrand['data']['brand_list'] as $val) {
@@ -265,7 +265,7 @@ class UserModel @@ -265,7 +265,7 @@ class UserModel
265 $datas[] = $brand; 265 $datas[] = $brand;
266 } 266 }
267 !empty($datas) && $result['hasFavBrand'] = $datas; 267 !empty($datas) && $result['hasFavBrand'] = $datas;
268 - } else if ($page > 1 && !isset($favBrand['code']['brand_list'])) { 268 + } else if (($page > 1 && !$favBrand) || $page > $favBrand['data']['page_total']) {
269 $result['end'] = true; 269 $result['end'] = true;
270 } 270 }
271 271