CouponFloorProcess.php
1.87 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
* Created by PhpStorm.
* User: Targaryen
* Date: 2016/4/15
* Time: 13:17
*/
namespace Plugin\DataProcess;
class CouponFloorProcess
{
/**
* 获取楼层数据
*
* @param $data
* @return array
*/
public static function getContent($data)
{
$result = array();
if (empty($data)) {
return array();
}
$build = array();
foreach ($data as $v) {
if (empty($v)) {
continue;
}
$fun = $v['template_name'];
if (empty($v['data']) || !is_callable("self::$fun")) {
continue;
}
$build = self::$fun($v['data']);
if (empty($build)) {
continue;
}
$result[] = $build;
}
$build = array();
return $result;
}
/**
* 焦点图处理
*
* @param $data
* @return mixed
*/
private static function carousel_banner($data)
{
if (empty($data)) {
return array();
}
$data['isCarouselBanner'] = true;
return $data;
}
/**
*
* 领券楼层数据处理
*
* @param $data
* @return array
* @internal param $type
*/
private static function getCoupon($data)
{
if (empty($data)) {
return array();
}
foreach ($data['list'] as &$item) {
switch ($item['status']) {
case 1:
$item['isGet'] = true;
break;
case 2:
$item['isZero'] = true;
break;
case 3:
$item['isGeted'] = true;
break;
default:
break;
}
}
$data['isCoupon'] = true;
return $data;
}
}