Authored by Rock Zhang

Merge test

<?php
namespace Plugin\DataProcess;
use Plugin\Helpers;
/**
... ... @@ -18,16 +17,19 @@ 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;
}
/**
... ... @@ -46,6 +48,7 @@ class ListProcess
}
return $products;
}
/**
... ... @@ -58,12 +61,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")) {
... ... @@ -75,7 +78,7 @@ class ListProcess
$build['active'] = true;
}
$num ++;
$num++;
$filters['classify'][] = $build;
}
... ... @@ -83,6 +86,7 @@ class ListProcess
self::sortArrByField($filters['classify'], 'sort_col');
return $filters;
}
private static function brand($data)
... ... @@ -161,7 +165,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 +225,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 +236,7 @@ class ListProcess
$category['subs'][] = $subitem;
}
} */
}*/
$result['subs'][] = $category;
}
... ... @@ -301,8 +305,7 @@ 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];
... ... @@ -310,5 +313,4 @@ class ListProcess
$sort = $desc == false ? SORT_ASC : SORT_DESC;
array_multisort($fieldArr, $sort, $array);
}
}
... ...