|
|
<?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;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -62,12 +58,12 @@ class ListProcess |
|
|
public static function getFilterData($data, $gender = 0)
|
|
|
{
|
|
|
// 过滤条件数据
|
|
|
$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")) {
|
...
|
...
|
@@ -79,7 +75,7 @@ class ListProcess |
|
|
$build['active'] = true;
|
|
|
}
|
|
|
|
|
|
$num++;
|
|
|
$num ++;
|
|
|
$filters['classify'][] = $build;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -87,7 +83,6 @@ class ListProcess |
|
|
self::sortArrByField($filters['classify'], 'sort_col');
|
|
|
|
|
|
return $filters;
|
|
|
|
|
|
}
|
|
|
|
|
|
private static function brand($data)
|
...
|
...
|
@@ -166,7 +161,7 @@ class ListProcess |
|
|
foreach ($data as $key => $one) {
|
|
|
$discount = array();
|
|
|
$discount['dataId'] = $key;
|
|
|
$discount['name'] = $one['name'] .'折商品';
|
|
|
$discount['name'] = $one['name'] . '折商品';
|
|
|
|
|
|
$result['subs'][] = $discount;
|
|
|
}
|
...
|
...
|
@@ -226,18 +221,18 @@ class ListProcess |
|
|
$category['dataId'] = isset($one['relation_parameter']) ? $one['relation_parameter']['sort'] : 0;
|
|
|
$category['name'] = $one['category_name'];
|
|
|
|
|
|
/*// 子品类(目前h5不支持二级)
|
|
|
if(isset($one['sub']))
|
|
|
{
|
|
|
$category['subs'] = array();
|
|
|
foreach ($one['sub'] as $single) {
|
|
|
$subitem = array();
|
|
|
$subitem['dataId'] = $single['category_id'];
|
|
|
$subitem['name'] = $single['category_name'];
|
|
|
/* // 子品类(目前h5不支持二级)
|
|
|
if(isset($one['sub']))
|
|
|
{
|
|
|
$category['subs'] = array();
|
|
|
foreach ($one['sub'] as $single) {
|
|
|
$subitem = array();
|
|
|
$subitem['dataId'] = $single['category_id'];
|
|
|
$subitem['name'] = $single['category_name'];
|
|
|
|
|
|
$category['subs'][] = $subitem;
|
|
|
}
|
|
|
}*/
|
|
|
$category['subs'][] = $subitem;
|
|
|
}
|
|
|
} */
|
|
|
|
|
|
$result['subs'][] = $category;
|
|
|
}
|
...
|
...
|
@@ -290,7 +285,7 @@ class ListProcess |
|
|
|
|
|
foreach ($data as $one) {
|
|
|
$size = array();
|
|
|
$size['dataId'] = $one['size_id'];
|
|
|
$size['dataId'] = $one['size_id'];
|
|
|
$size['name'] = $one['size_name'];
|
|
|
|
|
|
$result['subs'][] = $size;
|
...
|
...
|
@@ -306,7 +301,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];
|
...
|
...
|
@@ -314,4 +310,5 @@ class ListProcess |
|
|
$sort = $desc == false ? SORT_ASC : SORT_DESC;
|
|
|
array_multisort($fieldArr, $sort, $array);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|