NewSaleProcess.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace Plugin\DataProcess;
use Plugin\DataProcess\ListProcess;
use Plugin\Helpers;
/**
* 新品到着、折扣专区数据处理类
*/
class NewSaleProcess
{
/**
* 处理新品到着、折扣专区数据
*
* @param array $products 接口传回的数据
* @return array 处理之后的数据
*/
public static function newSaleData($products)
{
$result = array();
// 处理Tabs
if (isset($products['tabs'])) {
$result['tabs'] = array();
foreach ($products['tabs'] as $key => $one) {
$tabItem = array();
$tabItem['title'] = $one;
$tabItem['dataId'] = $key;
if ($key === 1) {
$tabItem['focus'] = true;
}
$result['tabs'][] = $tabItem;
}
}
// 处理Filter
if(isset($products['filter'])) {
$result['filter'] = ListProcess::getFilterData($products['filter']);
}
// 处理商品
if (isset($products['product_list'])) {
foreach ($products['product_list'] as $single) {
$result['goods'][] = Helpers::formatProduct($single, true, false, false, 290, 388);
}
}
return $result;
}
}