|
|
<?php
|
|
|
|
|
|
namespace Plugin\DataProcess;
|
|
|
|
|
|
use Plugin\Helpers;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -17,19 +18,16 @@ class ListProcess |
|
|
*/
|
|
|
public static function getListData($data)
|
|
|
{
|
|
|
$result = array('new'=>array(), 'filter'=>array());
|
|
|
$result = array('new' => array(), 'filter' => array());
|
|
|
|
|
|
if(isset($data['product_list']))
|
|
|
{
|
|
|
if (isset($data['product_list'])) {
|
|
|
$result['new'] = self::getProductData($data['product_list']);
|
|
|
}
|
|
|
if(isset($data['filter']))
|
|
|
{
|
|
|
if (isset($data['filter'])) {
|
|
|
$result['filter'] = self::getFilterData($data['filter']);
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -43,13 +41,11 @@ class ListProcess |
|
|
// 处理商品
|
|
|
$products = array();
|
|
|
|
|
|
foreach ($data as $value)
|
|
|
{
|
|
|
foreach ($data as $value) {
|
|
|
$products[] = Helpers::formatProduct($value, true, true, true, true);
|
|
|
}
|
|
|
|
|
|
return $products;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -61,24 +57,23 @@ class ListProcess |
|
|
public static function getFilterData($data)
|
|
|
{
|
|
|
// 过滤条件数据
|
|
|
$filters = array('classify'=>array());
|
|
|
$filters = array('classify' => array());
|
|
|
|
|
|
$num = 1;
|
|
|
$build = array();
|
|
|
foreach ($data as $key => $val) {
|
|
|
if(empty($val))
|
|
|
{
|
|
|
if (empty($val)) {
|
|
|
continue;
|
|
|
}
|
|
|
if (!is_callable("self::$key")) {
|
|
|
continue;
|
|
|
}
|
|
|
$build = self::$key($val);
|
|
|
if($num === 1)
|
|
|
{
|
|
|
if ($num === 1) {
|
|
|
$build['active'] = true;
|
|
|
}
|
|
|
|
|
|
$num++;
|
|
|
$num ++;
|
|
|
$filters['classify'][] = $build;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -86,7 +81,6 @@ class ListProcess |
|
|
self::sortArrByField($filters['classify'], 'sort_col');
|
|
|
|
|
|
return $filters;
|
|
|
|
|
|
}
|
|
|
|
|
|
private static function brand($data)
|
...
|
...
|
@@ -165,7 +159,7 @@ class ListProcess |
|
|
foreach ($data as $key => $one) {
|
|
|
$discount = array();
|
|
|
$discount['dataId'] = $key;
|
|
|
$discount['name'] = $one['name'] .'折商品';
|
|
|
$discount['name'] = $one['name'] . '折商品';
|
|
|
|
|
|
$result['subs'][] = $discount;
|
|
|
}
|
...
|
...
|
@@ -221,7 +215,7 @@ class ListProcess |
|
|
$category['dataId'] = isset($one['relation_parameter']) ? $one['relation_parameter']['sort'] : 0;
|
|
|
$category['name'] = $one['category_name'];
|
|
|
|
|
|
/*// 子品类(目前h5不支持二级)
|
|
|
/* // 子品类(目前h5不支持二级)
|
|
|
if(isset($one['sub']))
|
|
|
{
|
|
|
$category['subs'] = array();
|
...
|
...
|
@@ -232,7 +226,7 @@ class ListProcess |
|
|
|
|
|
$category['subs'][] = $subitem;
|
|
|
}
|
|
|
}*/
|
|
|
} */
|
|
|
|
|
|
$result['subs'][] = $category;
|
|
|
}
|
...
|
...
|
@@ -301,7 +295,8 @@ class ListProcess |
|
|
* @param string $field 字段名称
|
|
|
* @param boolean $desc 时候降序排列,默认为false
|
|
|
*/
|
|
|
private static function sortArrByField(&$array, $field, $desc = false){
|
|
|
private static function sortArrByField(&$array, $field, $desc = false)
|
|
|
{
|
|
|
$fieldArr = array();
|
|
|
foreach ($array as $k => $v) {
|
|
|
$fieldArr[$k] = $v[$field];
|
...
|
...
|
@@ -309,4 +304,5 @@ class ListProcess |
|
|
$sort = $desc == false ? SORT_ASC : SORT_DESC;
|
|
|
array_multisort($fieldArr, $sort, $array);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|