|
|
<?php
|
|
|
|
|
|
namespace Plugin\DataProcess;
|
|
|
|
|
|
use Plugin\Helpers;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -18,9 +17,10 @@ class ListProcess |
|
|
*/
|
|
|
public static function getListData($data, $returnFilter = true)
|
|
|
{
|
|
|
$result = array('new' => array(), 'filter' => array());
|
|
|
$result = array();
|
|
|
|
|
|
if (isset($data['product_list'])) {
|
|
|
if(isset($data['product_list']))
|
|
|
{
|
|
|
$result['new'] = self::getProductData($data['product_list']);
|
|
|
}
|
|
|
if ($returnFilter && isset($data['filter'])) {
|
...
|
...
|
@@ -28,6 +28,7 @@ class ListProcess |
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -46,34 +47,40 @@ class ListProcess |
|
|
}
|
|
|
|
|
|
return $products;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处理筛选数据
|
|
|
*
|
|
|
* @param $data
|
|
|
* @param string | integer $gender 默认选择的性别,默认1,2,3表示所有
|
|
|
* @return array 处理之后的筛选数据
|
|
|
*/
|
|
|
public static function getFilterData($data)
|
|
|
public static function getFilterData($data, $gender = '1,2,3')
|
|
|
{
|
|
|
// 过滤条件数据
|
|
|
$filters = array('classify' => array());
|
|
|
$filters = array('classify'=>array());
|
|
|
|
|
|
// 返回数据中有没有gender时要添加gender
|
|
|
// $data['gender'] = array('2,3'=>'GIRLS','1,3'=>'BOYS');
|
|
|
|
|
|
$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) {
|
|
|
$build = self::$key($val, $gender);
|
|
|
if($num === 1)
|
|
|
{
|
|
|
$build['active'] = true;
|
|
|
}
|
|
|
|
|
|
$num ++;
|
|
|
$num++;
|
|
|
$filters['classify'][] = $build;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -81,6 +88,7 @@ class ListProcess |
|
|
self::sortArrByField($filters['classify'], 'sort_col');
|
|
|
|
|
|
return $filters;
|
|
|
|
|
|
}
|
|
|
|
|
|
private static function brand($data)
|
...
|
...
|
@@ -159,7 +167,7 @@ class ListProcess |
|
|
foreach ($data as $key => $one) {
|
|
|
$discount = array();
|
|
|
$discount['dataId'] = $key;
|
|
|
$discount['name'] = $one['name'] . '折商品';
|
|
|
$discount['name'] = $one['name'] .'折商品';
|
|
|
|
|
|
$result['subs'][] = $discount;
|
|
|
}
|
...
|
...
|
@@ -167,7 +175,7 @@ class ListProcess |
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
private static function gender($data)
|
|
|
private static function gender($data, $gender)
|
|
|
{
|
|
|
$result = array(
|
|
|
'title' => '性别',
|
...
|
...
|
@@ -176,8 +184,7 @@ class ListProcess |
|
|
'dataType' => 'gender',
|
|
|
'subs' => array(
|
|
|
array(
|
|
|
'chosed' => true,
|
|
|
'dataId' => 0,
|
|
|
'dataId' => '1,2,3',
|
|
|
'name' => '所有性别'
|
|
|
),
|
|
|
array(
|
...
|
...
|
@@ -191,6 +198,11 @@ class ListProcess |
|
|
)
|
|
|
);
|
|
|
|
|
|
// 处理选中状态
|
|
|
foreach ($result['subs'] as &$val) {
|
|
|
$val['dataId'] === $gender && $val['chosed'] = true;
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -215,7 +227,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();
|
...
|
...
|
@@ -226,7 +238,7 @@ class ListProcess |
|
|
|
|
|
$category['subs'][] = $subitem;
|
|
|
}
|
|
|
} */
|
|
|
}*/
|
|
|
|
|
|
$result['subs'][] = $category;
|
|
|
}
|
...
|
...
|
@@ -295,8 +307,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];
|
...
|
...
|
@@ -304,5 +315,4 @@ class ListProcess |
|
|
$sort = $desc == false ? SORT_ASC : SORT_DESC;
|
|
|
array_multisort($fieldArr, $sort, $array);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|