|
|
@ -374,11 +374,41 @@ class CategoryController extends BaseController |
|
|
return jsonReturn(-1, $e->getError()); |
|
|
return jsonReturn(-1, $e->getError()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 非超管:从缓存读取 customContent 对应的栏目ID
|
|
|
|
|
|
$customContentCateIds = []; |
|
|
|
|
|
if ($this->admin['uid'] != 1) { |
|
|
|
|
|
$customContentCateIds = Cache::get('custom_cate_' . $this->admin['seller_id'] . '_' . $this->admin['uid'], []); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$Website = new Website(); |
|
|
$Website = new Website(); |
|
|
$website = $Website->getAllCustomArrayData([['id','in',$param['site_id']],['seller_id','=',$this->admin['seller_id']]] |
|
|
$website = $Website->getAllCustomArrayData([['id','in',$param['site_id']],['seller_id','=',$this->admin['seller_id']]] |
|
|
,'id asc','id,seller_id,title,domain')['data']; |
|
|
,'id asc','id,seller_id,title,domain')['data']; |
|
|
$website = getColumnForKeyArray($website,'id'); |
|
|
$website = getColumnForKeyArray($website,'id'); |
|
|
|
|
|
|
|
|
|
|
|
// 有 customContent 菜单权限时,按栏目ID过滤;否则不限制
|
|
|
|
|
|
if (!empty($customContentCateIds)) { |
|
|
|
|
|
$category = $Category->getAllCustomArrayData([['id','in',$customContentCateIds],['seller_id','=',$this->admin['seller_id']],['lang','=',$param['lang']]],'id asc')['data']; |
|
|
|
|
|
$cateArr = is_array($category) ? $category : $category->toArray(); |
|
|
|
|
|
$websiteIds = array_unique(array_column($cateArr, 'website_id')); |
|
|
|
|
|
$allCategory = $Category->getAllCustomArrayData([['website_id','in',implode(',',$websiteIds)],['seller_id','=',$this->admin['seller_id']],['lang','=',$param['lang']]],'id asc')['data']; |
|
|
|
|
|
$allCategory = getArrayGroupBy($allCategory, 'website_id'); |
|
|
|
|
|
$response = []; |
|
|
|
|
|
foreach ($allCategory as $key => $cate) { |
|
|
|
|
|
if (!isset($website[$key])) continue; |
|
|
|
|
|
$tmpCategory = $this->makeTree($cate); |
|
|
|
|
|
$tmpCategory = $this->imp($tmpCategory); |
|
|
|
|
|
$tmpCategory = array_values(array_filter($tmpCategory, function($item) use ($customContentCateIds) { |
|
|
|
|
|
return in_array((int)$item['id'], $customContentCateIds); |
|
|
|
|
|
})); |
|
|
|
|
|
if (!empty($tmpCategory)) { |
|
|
|
|
|
$tmpCate = $website[$key]; |
|
|
|
|
|
$tmpCate['category'] = $tmpCategory; |
|
|
|
|
|
$response[] = $tmpCate; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return jsonReturn(0, lang('成功'), $response); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$category = $Category -> getAllCustomArrayData([['website_id','in',$param['site_id']],['seller_id','=',$this->admin['seller_id']],['lang','=',$param['lang']]],'id asc')['data']; |
|
|
$category = $Category -> getAllCustomArrayData([['website_id','in',$param['site_id']],['seller_id','=',$this->admin['seller_id']],['lang','=',$param['lang']]],'id asc')['data']; |
|
|
$category = getArrayGroupBy($category,'website_id'); |
|
|
$category = getArrayGroupBy($category,'website_id'); |
|
|
$response = []; |
|
|
$response = []; |
|
|
|