Showing
2 changed files
with
46 additions
and
8 deletions
@@ -50,4 +50,47 @@ class NewSaleProcess | @@ -50,4 +50,47 @@ class NewSaleProcess | ||
50 | return $result; | 50 | return $result; |
51 | } | 51 | } |
52 | 52 | ||
53 | + /** | ||
54 | + * 处理热销排行榜数据 | ||
55 | + * | ||
56 | + * @param array $products 接口传回的数据 | ||
57 | + * @param boolean $notab 是否传回tab数据 | ||
58 | + * @param int $limit 查询返回的最大限制数 | ||
59 | + * @param int $page 分页第几页 | ||
60 | + * @return array 处理之后的数据 | ||
61 | + */ | ||
62 | + public static function topData($products, $notab, $limit, $page) | ||
63 | + { | ||
64 | + $result = array(); | ||
65 | + | ||
66 | + // 处理Tabs | ||
67 | + if (!$notab && isset($products['tabs'])) { | ||
68 | + $result['tabs'] = array(); | ||
69 | + foreach ($products['tabs'] as $key => $one) { | ||
70 | + $tabItem = array(); | ||
71 | + $tabItem['title'] = $one; | ||
72 | + $tabItem['dataId'] = $key; | ||
73 | + if ($key === 1) { | ||
74 | + $tabItem['focus'] = true; | ||
75 | + } | ||
76 | + $result['tabs'][] = $tabItem; | ||
77 | + } | ||
78 | + } | ||
79 | + | ||
80 | + // 处理商品 | ||
81 | + if (isset($products['product_list'])) { | ||
82 | + | ||
83 | + $count = count($products['product_list']); | ||
84 | + $one = array(); | ||
85 | + foreach ($products['product_list'] as $key => $single) { | ||
86 | + $one = Helpers::formatProduct($single, true, false, false, 75, 114); | ||
87 | + $one['rank'] = $limit * ($page -1) + $key + 1; | ||
88 | + | ||
89 | + $result['goods'][] = $one; | ||
90 | + } | ||
91 | + } | ||
92 | + | ||
93 | + return $result; | ||
94 | + } | ||
95 | + | ||
53 | } | 96 | } |
@@ -234,8 +234,8 @@ class NewsaleModel | @@ -234,8 +234,8 @@ class NewsaleModel | ||
234 | * @param string|null $sort 品类ID查询参数 | 234 | * @param string|null $sort 品类ID查询参数 |
235 | * @param integer|null $tab_id Tab的ID | 235 | * @param integer|null $tab_id Tab的ID |
236 | * @param boolean $notab 时候返回顶部tab的数据,默认返回 | 236 | * @param boolean $notab 时候返回顶部tab的数据,默认返回 |
237 | - * @param integer $limit 查询返回的最大限制数, 默认为50 | ||
238 | - * @param integer $page 分页第几页, 默认第1页 | 237 | + * @param integer $limit 查询返回的最大限制数 |
238 | + * @param integer $page 分页第几页 | ||
239 | * @return array 处理之后的数据 | 239 | * @return array 处理之后的数据 |
240 | */ | 240 | */ |
241 | public static function selectTopData($gender, $sort, $tab_id, $notab, $limit, $page) | 241 | public static function selectTopData($gender, $sort, $tab_id, $notab, $limit, $page) |
@@ -245,12 +245,7 @@ class NewsaleModel | @@ -245,12 +245,7 @@ class NewsaleModel | ||
245 | $data = NewsaleData::getTopProducts($gender, $sort, $tab_id, $limit, $page); | 245 | $data = NewsaleData::getTopProducts($gender, $sort, $tab_id, $limit, $page); |
246 | 246 | ||
247 | 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'])) { |
248 | - $result = NewSaleProcess::newSaleData($data['data']); | ||
249 | - unset($result['filter']); | ||
250 | - | ||
251 | - if ($notab) { | ||
252 | - unset($result['tabs']); | ||
253 | - } | 248 | + $result = NewSaleProcess::topData($data['data'], $notab, $limit, $page); |
254 | } | 249 | } |
255 | 250 | ||
256 | return $result; | 251 | return $result; |
-
Please register or login to post a comment