正在显示
4 个修改的文件
包含
17 行增加
和
5 行删除
| @@ -29,7 +29,10 @@ class CategoryController extends BaseController | @@ -29,7 +29,10 @@ class CategoryController extends BaseController | ||
| 29 | foreach ($data as &$v){ | 29 | foreach ($data as &$v){ |
| 30 | $v['product_num'] = $logic->getProductNum($v['id']); | 30 | $v['product_num'] = $logic->getProductNum($v['id']); |
| 31 | } | 31 | } |
| 32 | - return $this->success(Arr::listToTree($data)); | 32 | + if(!$map){ |
| 33 | + $data = Arr::listToTree($data); | ||
| 34 | + } | ||
| 35 | + return $this->success($data); | ||
| 33 | } | 36 | } |
| 34 | 37 | ||
| 35 | public function info(Request $request, CategoryLogic $logic){ | 38 | public function info(Request $request, CategoryLogic $logic){ |
| @@ -25,7 +25,11 @@ class KeywordController extends BaseController | @@ -25,7 +25,11 @@ class KeywordController extends BaseController | ||
| 25 | $map[] = ['title', 'like', "%{$this->param['search']}%"]; | 25 | $map[] = ['title', 'like', "%{$this->param['search']}%"]; |
| 26 | } | 26 | } |
| 27 | $sort = ['id' => 'desc']; | 27 | $sort = ['id' => 'desc']; |
| 28 | - $data = $logic->getList($map, $sort, ['id', 'title', 'route', 'status', 'created_at']); | 28 | + $data = $logic->getList($map, $sort, ['id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'status', 'created_at']); |
| 29 | + foreach ($data['list'] as &$v){ | ||
| 30 | + $v['product_num'] = $logic->getProductNum($v['title']); | ||
| 31 | + $v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']); | ||
| 32 | + } | ||
| 29 | return $this->success($data); | 33 | return $this->success($data); |
| 30 | } | 34 | } |
| 31 | 35 | ||
| @@ -36,7 +40,7 @@ class KeywordController extends BaseController | @@ -36,7 +40,7 @@ class KeywordController extends BaseController | ||
| 36 | 'id.required' => 'ID不能为空' | 40 | 'id.required' => 'ID不能为空' |
| 37 | ]); | 41 | ]); |
| 38 | $data = $logic->getInfo($this->param['id']); | 42 | $data = $logic->getInfo($this->param['id']); |
| 39 | - return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'route', 'created_at'])); | 43 | + return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'created_at'])); |
| 40 | } | 44 | } |
| 41 | 45 | ||
| 42 | public function save(KeywordRequest $request, KeywordLogic $logic) | 46 | public function save(KeywordRequest $request, KeywordLogic $logic) |
| @@ -64,7 +64,8 @@ class CategoryLogic extends BaseLogic | @@ -64,7 +64,8 @@ class CategoryLogic extends BaseLogic | ||
| 64 | * @date 2023/4/28 | 64 | * @date 2023/4/28 |
| 65 | */ | 65 | */ |
| 66 | public function getProductNum($cate_id){ | 66 | public function getProductNum($cate_id){ |
| 67 | - $ids = $this->model->getChildIdsArr($cate_id); | ||
| 68 | - return CategoryRelated::whereIn('cate_id', $ids)->count(); | 67 | + $cate_ids = $this->model->getChildIdsArr($cate_id); |
| 68 | + $product_ids = CategoryRelated::whereIn('cate_id', $cate_ids)->pluck('id'); | ||
| 69 | + return Product::whereIn('id', $product_ids)->count(); | ||
| 69 | } | 70 | } |
| 70 | } | 71 | } |
| @@ -59,4 +59,8 @@ class KeywordLogic extends BaseLogic | @@ -59,4 +59,8 @@ class KeywordLogic extends BaseLogic | ||
| 59 | 59 | ||
| 60 | return $this->success(); | 60 | return $this->success(); |
| 61 | } | 61 | } |
| 62 | + | ||
| 63 | + public function getProductNum($title){ | ||
| 64 | + return Product::whereRaw("find_in_set('{$title}',`keywords`)")->count(); | ||
| 65 | + } | ||
| 62 | } | 66 | } |
-
请 注册 或 登录 后发表评论