1
|
<?php
|
1
|
<?php
|
2
|
|
2
|
|
3
|
namespace Plugin\DataProcess;
|
3
|
namespace Plugin\DataProcess;
|
|
|
4
|
+
|
4
|
use Plugin\Helpers;
|
5
|
use Plugin\Helpers;
|
5
|
|
6
|
|
6
|
/**
|
7
|
/**
|
|
@@ -19,8 +20,7 @@ class ListProcess |
|
@@ -19,8 +20,7 @@ class ListProcess |
19
|
{
|
20
|
{
|
20
|
$result = array();
|
21
|
$result = array();
|
21
|
|
22
|
|
22
|
- if(isset($data['product_list']))
|
|
|
23
|
- {
|
23
|
+ if (isset($data['product_list'])) {
|
24
|
$result['new'] = self::getProductData($data['product_list']);
|
24
|
$result['new'] = self::getProductData($data['product_list']);
|
25
|
}
|
25
|
}
|
26
|
if ($returnFilter && isset($data['filter'])) {
|
26
|
if ($returnFilter && isset($data['filter'])) {
|
|
@@ -28,7 +28,6 @@ class ListProcess |
|
@@ -28,7 +28,6 @@ class ListProcess |
28
|
}
|
28
|
}
|
29
|
|
29
|
|
30
|
return $result;
|
30
|
return $result;
|
31
|
-
|
|
|
32
|
}
|
31
|
}
|
33
|
|
32
|
|
34
|
/**
|
33
|
/**
|
|
@@ -47,7 +46,6 @@ class ListProcess |
|
@@ -47,7 +46,6 @@ class ListProcess |
47
|
}
|
46
|
}
|
48
|
|
47
|
|
49
|
return $products;
|
48
|
return $products;
|
50
|
-
|
|
|
51
|
}
|
49
|
}
|
52
|
|
50
|
|
53
|
/**
|
51
|
/**
|
|
@@ -60,23 +58,21 @@ class ListProcess |
|
@@ -60,23 +58,21 @@ class ListProcess |
60
|
public static function getFilterData($data, $gender = '1,2,3')
|
58
|
public static function getFilterData($data, $gender = '1,2,3')
|
61
|
{
|
59
|
{
|
62
|
// 过滤条件数据
|
60
|
// 过滤条件数据
|
63
|
- $filters = array('classify'=>array());
|
61
|
+ $filters = array('classify' => array());
|
64
|
|
62
|
|
65
|
// 返回数据中有没有gender时要添加gender
|
63
|
// 返回数据中有没有gender时要添加gender
|
66
|
// $data['gender'] = array('2,3'=>'GIRLS','1,3'=>'BOYS');
|
64
|
// $data['gender'] = array('2,3'=>'GIRLS','1,3'=>'BOYS');
|
67
|
|
65
|
|
68
|
$num = 1;
|
66
|
$num = 1;
|
69
|
foreach ($data as $key => $val) {
|
67
|
foreach ($data as $key => $val) {
|
70
|
- if(empty($val))
|
|
|
71
|
- {
|
68
|
+ if (empty($val)) {
|
72
|
continue;
|
69
|
continue;
|
73
|
}
|
70
|
}
|
74
|
if (!is_callable("self::$key")) {
|
71
|
if (!is_callable("self::$key")) {
|
75
|
continue;
|
72
|
continue;
|
76
|
}
|
73
|
}
|
77
|
$build = self::$key($val, $gender);
|
74
|
$build = self::$key($val, $gender);
|
78
|
- if($num === 1)
|
|
|
79
|
- {
|
75
|
+ if ($num === 1) {
|
80
|
$build['active'] = true;
|
76
|
$build['active'] = true;
|
81
|
}
|
77
|
}
|
82
|
|
78
|
|
|
@@ -88,7 +84,6 @@ class ListProcess |
|
@@ -88,7 +84,6 @@ class ListProcess |
88
|
self::sortArrByField($filters['classify'], 'sort_col');
|
84
|
self::sortArrByField($filters['classify'], 'sort_col');
|
89
|
|
85
|
|
90
|
return $filters;
|
86
|
return $filters;
|
91
|
-
|
|
|
92
|
}
|
87
|
}
|
93
|
|
88
|
|
94
|
private static function brand($data)
|
89
|
private static function brand($data)
|
|
@@ -167,7 +162,7 @@ class ListProcess |
|
@@ -167,7 +162,7 @@ class ListProcess |
167
|
foreach ($data as $key => $one) {
|
162
|
foreach ($data as $key => $one) {
|
168
|
$discount = array();
|
163
|
$discount = array();
|
169
|
$discount['dataId'] = $key;
|
164
|
$discount['dataId'] = $key;
|
170
|
- $discount['name'] = $one['name'] .'折商品';
|
165
|
+ $discount['name'] = $one['name'] . '折商品';
|
171
|
|
166
|
|
172
|
$result['subs'][] = $discount;
|
167
|
$result['subs'][] = $discount;
|
173
|
}
|
168
|
}
|
|
@@ -200,7 +195,9 @@ class ListProcess |
|
@@ -200,7 +195,9 @@ class ListProcess |
200
|
|
195
|
|
201
|
// 处理选中状态
|
196
|
// 处理选中状态
|
202
|
foreach ($result['subs'] as &$val) {
|
197
|
foreach ($result['subs'] as &$val) {
|
203
|
- $val['dataId'] === $gender && $val['chosed'] = true;
|
198
|
+ if ($val['dataId'] === $gender) {
|
|
|
199
|
+ $val['chosed'] = true;
|
|
|
200
|
+ }
|
204
|
}
|
201
|
}
|
205
|
|
202
|
|
206
|
return $result;
|
203
|
return $result;
|
|
@@ -222,23 +219,24 @@ class ListProcess |
|
@@ -222,23 +219,24 @@ class ListProcess |
222
|
)
|
219
|
)
|
223
|
);
|
220
|
);
|
224
|
|
221
|
|
|
|
222
|
+ $category = array();
|
225
|
foreach ($data as $one) {
|
223
|
foreach ($data as $one) {
|
226
|
- $category = array();
|
224
|
+
|
227
|
$category['dataId'] = isset($one['relation_parameter']) ? $one['relation_parameter']['sort'] : 0;
|
225
|
$category['dataId'] = isset($one['relation_parameter']) ? $one['relation_parameter']['sort'] : 0;
|
228
|
$category['name'] = $one['category_name'];
|
226
|
$category['name'] = $one['category_name'];
|
229
|
|
227
|
|
230
|
- /*// 子品类(目前h5不支持二级)
|
|
|
231
|
- if(isset($one['sub']))
|
|
|
232
|
- {
|
|
|
233
|
- $category['subs'] = array();
|
|
|
234
|
- foreach ($one['sub'] as $single) {
|
|
|
235
|
- $subitem = array();
|
|
|
236
|
- $subitem['dataId'] = $single['category_id'];
|
|
|
237
|
- $subitem['name'] = $single['category_name'];
|
228
|
+ /* // 子品类(目前h5不支持二级)
|
|
|
229
|
+ if(isset($one['sub']))
|
|
|
230
|
+ {
|
|
|
231
|
+ $category['subs'] = array();
|
|
|
232
|
+ foreach ($one['sub'] as $single) {
|
|
|
233
|
+ $subitem = array();
|
|
|
234
|
+ $subitem['dataId'] = $single['category_id'];
|
|
|
235
|
+ $subitem['name'] = $single['category_name'];
|
238
|
|
236
|
|
239
|
- $category['subs'][] = $subitem;
|
|
|
240
|
- }
|
|
|
241
|
- }*/
|
237
|
+ $category['subs'][] = $subitem;
|
|
|
238
|
+ }
|
|
|
239
|
+ } */
|
242
|
|
240
|
|
243
|
$result['subs'][] = $category;
|
241
|
$result['subs'][] = $category;
|
244
|
}
|
242
|
}
|
|
@@ -262,8 +260,9 @@ class ListProcess |
|
@@ -262,8 +260,9 @@ class ListProcess |
262
|
)
|
260
|
)
|
263
|
);
|
261
|
);
|
264
|
|
262
|
|
|
|
263
|
+ $price = array();
|
265
|
foreach ($data as $key => $one) {
|
264
|
foreach ($data as $key => $one) {
|
266
|
- $price = array();
|
265
|
+
|
267
|
$price['dataId'] = $key;
|
266
|
$price['dataId'] = $key;
|
268
|
$price['name'] = $one;
|
267
|
$price['name'] = $one;
|
269
|
|
268
|
|
|
@@ -289,9 +288,10 @@ class ListProcess |
|
@@ -289,9 +288,10 @@ class ListProcess |
289
|
)
|
288
|
)
|
290
|
);
|
289
|
);
|
291
|
|
290
|
|
|
|
291
|
+ $size = array();
|
292
|
foreach ($data as $one) {
|
292
|
foreach ($data as $one) {
|
293
|
- $size = array();
|
|
|
294
|
- $size['dataId'] = $one['size_id'];
|
293
|
+
|
|
|
294
|
+ $size['dataId'] = $one['size_id'];
|
295
|
$size['name'] = $one['size_name'];
|
295
|
$size['name'] = $one['size_name'];
|
296
|
|
296
|
|
297
|
$result['subs'][] = $size;
|
297
|
$result['subs'][] = $size;
|
|
@@ -307,7 +307,8 @@ class ListProcess |
|
@@ -307,7 +307,8 @@ class ListProcess |
307
|
* @param string $field 字段名称
|
307
|
* @param string $field 字段名称
|
308
|
* @param boolean $desc 时候降序排列,默认为false
|
308
|
* @param boolean $desc 时候降序排列,默认为false
|
309
|
*/
|
309
|
*/
|
310
|
- private static function sortArrByField(&$array, $field, $desc = false){
|
310
|
+ private static function sortArrByField(&$array, $field, $desc = false)
|
|
|
311
|
+ {
|
311
|
$fieldArr = array();
|
312
|
$fieldArr = array();
|
312
|
foreach ($array as $k => $v) {
|
313
|
foreach ($array as $k => $v) {
|
313
|
$fieldArr[$k] = $v[$field];
|
314
|
$fieldArr[$k] = $v[$field];
|
|
@@ -315,4 +316,5 @@ class ListProcess |
|
@@ -315,4 +316,5 @@ class ListProcess |
315
|
$sort = $desc == false ? SORT_ASC : SORT_DESC;
|
316
|
$sort = $desc == false ? SORT_ASC : SORT_DESC;
|
316
|
array_multisort($fieldArr, $sort, $array);
|
317
|
array_multisort($fieldArr, $sort, $array);
|
317
|
}
|
318
|
}
|
|
|
319
|
+
|
318
|
} |
320
|
} |