|
@@ -1385,10 +1385,10 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
if (empty($website)) {
|
|
|
return Result::error("暂无该网站", 0);
|
|
|
}
|
|
|
- $category = WebsiteCategory::where('website_id', $data['website_id'])->where('pid', $data['pid'])->pluck('category_id')->all();
|
|
|
+ $category = WebsiteCategory::where('website_id',$data['website_id'])->pluck('category_id')->all();
|
|
|
// return Result::success($category);
|
|
|
if (empty($category)) {
|
|
|
- return Result::error("暂无二级导航", 0);
|
|
|
+ return Result::error("暂无此导航",0);
|
|
|
}
|
|
|
$query = Category::whereIn('id', $category);
|
|
|
if (isset($data['cityid']) && !empty($data['cityid'])) {
|
|
@@ -1396,11 +1396,12 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
if (empty($cityid)) {
|
|
|
return Result::error("暂无此城市", 0);
|
|
|
} else {
|
|
|
- $result = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->get();
|
|
|
+ $city_category = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->pluck('id');
|
|
|
// $where[] = ['JSON_CONTAINS(city_arr_id, ?)', $data['cityid']];
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("暂无此城市下的二级导航", 0);
|
|
|
+ if (empty($city_category)) {
|
|
|
+ return Result::error("暂无此城市下的导航", 0);
|
|
|
}
|
|
|
+ $result['catid'] = $city_category;
|
|
|
$city = 1;
|
|
|
// var_dump("城市====================",$result);
|
|
|
}
|
|
@@ -1410,24 +1411,27 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
if (empty($departmentid)) {
|
|
|
return Result::error("暂无此部门", 0);
|
|
|
} else {
|
|
|
- $result = $query->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->get();
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("暂无此部门下的二级导航", 0);
|
|
|
+ $depart_category = $query->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->pluck('id');
|
|
|
+ if (empty($depart_category)) {
|
|
|
+ return Result::error("暂无此部门下的导航", 0);
|
|
|
}
|
|
|
+ $result['catid'] = $depart_category;
|
|
|
// var_dump("职能部门*******************",$result);
|
|
|
$department = 1;
|
|
|
}
|
|
|
}
|
|
|
- if (!empty($city) && !empty($department)) {
|
|
|
- // var_dump("城市和职能部门----------------------",$result);
|
|
|
- $result = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->get();
|
|
|
- } else {
|
|
|
- $result = $query->get();
|
|
|
+ if(!empty($city) && !empty($department)){
|
|
|
+ // var_dump("城市和职能部门----------------------",$result);
|
|
|
+ $sel_category = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->pluck('id');
|
|
|
+ if (empty($sel_category)) {
|
|
|
+ return Result::error("暂无此城市和职能部门下的导航", 0);
|
|
|
+ }
|
|
|
+ $result['catid'] = $sel_category;
|
|
|
}
|
|
|
if (empty($result)) {
|
|
|
- return Result::error("暂无二级导航", 0);
|
|
|
- }
|
|
|
-
|
|
|
+ return Result::error("暂无导航",0);
|
|
|
+ }
|
|
|
+
|
|
|
// department_id
|
|
|
} else {
|
|
|
return Result::error("参数错误", 0);
|
|
@@ -1457,8 +1461,8 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
- /*
|
|
|
- * 获取某个导航
|
|
|
+ /*
|
|
|
+ * 获取某个栏目
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
* */
|