Authored by Rock Zhang

修复热门排行的一些接口问题

@@ -227,19 +227,30 @@ class NewsaleModel @@ -227,19 +227,30 @@ class NewsaleModel
227 return $result; 227 return $result;
228 } 228 }
229 229
230 - /**  
231 - * 筛选出来的热销排行榜商品数据处理  
232 - *  
233 - * @param array $data 筛选出来的原数据  
234 - * @return array 处理之后的数据  
235 - */  
236 - public static function selectTopData($data) 230 + /**
  231 + * 筛选出来的热销排行榜商品数据处理
  232 + *
  233 + * @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
  234 + * @param string|null $sort 品类ID查询参数
  235 + * @param integer|null $tab_id Tab的ID
  236 + * @param boolean $notab 时候返回顶部tab的数据,默认返回
  237 + * @param integer $limit 查询返回的最大限制数, 默认为50
  238 + * @param integer $page 分页第几页, 默认第1页
  239 + * @return array 处理之后的数据
  240 + */
  241 + public static function selectTopData($gender, $sort, $tab_id, $notab, $limit, $page)
237 { 242 {
238 $result = array(); 243 $result = array();
239 244
  245 + $data = NewsaleData::getTopProducts($gender, $sort, $tab_id, $limit, $page);
  246 +
240 if (isset($data['code']) && $data['code'] === 200 && isset($data['data']['product_list'])) { 247 if (isset($data['code']) && $data['code'] === 200 && isset($data['data']['product_list'])) {
241 $result = NewSaleProcess::newSaleData($data['data']); 248 $result = NewSaleProcess::newSaleData($data['data']);
242 unset($result['filter']); 249 unset($result['filter']);
  250 +
  251 + if ($notab) {
  252 + unset($result['tabs']);
  253 + }
243 } 254 }
244 255
245 return $result; 256 return $result;
@@ -101,18 +101,17 @@ class NewsaleController extends AbstractAction @@ -101,18 +101,17 @@ class NewsaleController extends AbstractAction
101 { 101 {
102 $result = array(); 102 $result = array();
103 103
104 - if ($this->isAjax()) { 104 +// if ($this->isAjax()) {
105 $sort = $this->get('sort', null); 105 $sort = $this->get('sort', null);
106 $tab_id = $this->get('tab_id', null); 106 $tab_id = $this->get('tab_id', null);
107 $limit = $this->get('limit', 50); 107 $limit = $this->get('limit', 50);
108 $page = $this->get('page', 1); 108 $page = $this->get('page', 1);
  109 + $notab = (boolean)$this->get('notab', false);
109 110
110 // 获取性别 111 // 获取性别
111 $gender = Helpers::getGenderByCookie(); 112 $gender = Helpers::getGenderByCookie();
112 -  
113 - $data = NewsaleData::getTopProducts($gender, $sort, $tab_id, $limit, $page);  
114 - $result = \Product\NewsaleModel::selectTopData($data);  
115 - } 113 + $result = \Product\NewsaleModel::selectTopData($gender, $sort, $tab_id, $notab, $limit, $page);
  114 +// }
116 115
117 if (empty($result)) { 116 if (empty($result)) {
118 echo ' '; 117 echo ' ';