全量分类读取新增指定参数

feat/task1-c-wallet
gongfuxiang 2022-06-07 00:49:19 +08:00
parent 4026e7d7f6
commit 416dbe7ec6
2 changed files with 9 additions and 9 deletions

View File

@ -94,7 +94,7 @@ class Index extends Common
MyViewAssign('pages_list', $pages_list);
// 商品分类
$goods_category = GoodsService::GoodsCategoryAll();
$goods_category = GoodsService::GoodsCategory(['is_all'=>1]);
MyViewAssign('goods_category_list', $goods_category);
// 商品搜索分类(分类)

View File

@ -95,19 +95,17 @@ class GoodsService
// 获取分类
if(empty($params['where']))
{
$where = [
$params['where'] = [
['pid', '=', 0],
['is_enable', '=', 1],
];
} else {
$where = $params['where'];
}
$data = self::GoodsCategoryList(['where'=>$where]);
$data = self::GoodsCategoryList($params);
if(!empty($data))
{
// 基础条件、去除pid
$where_base = $where;
$temp_column = array_column($where, 0);
$where_base = $params['where'];
$temp_column = array_column($where_base, 0);
if(in_array('pid', $temp_column))
{
unset($where_base[array_search('pid', $temp_column)]);
@ -115,11 +113,13 @@ class GoodsService
}
foreach($data as &$v)
{
$v['items'] = self::GoodsCategoryList(['where'=>array_merge($where_base, [['pid', '=', $v['id']]])]);
$params['where'] = array_merge($where_base, [['pid', '=', $v['id']]]);
$v['items'] = self::GoodsCategoryList($params);
if(!empty($v['items']))
{
// 一次性查出所有二级下的三级、再做归类、避免sql连接超多
$itemss = self::GoodsCategoryList(['where'=>array_merge($where_base, [['pid', 'in', array_column($v['items'], 'id')]])]);
$params['where'] = array_merge($where_base, [['pid', 'in', array_column($v['items'], 'id')]]);
$itemss = self::GoodsCategoryList($params);
if(!empty($itemss))
{
foreach($v['items'] as &$vs)