Browse Source

商品搜索、商家详情页

master
weigang 5 years ago
parent
commit
2025fdf190
  1. 2
      app/Service/v3/Implementations/CategoryService.php
  2. 14
      app/Service/v3/Implementations/SearchService.php

2
app/Service/v3/Implementations/CategoryService.php

@ -42,7 +42,7 @@ class CategoryService implements CategoryServiceInterface
->groupBy(['category_id']) ->groupBy(['category_id'])
->get()->toArray(); ->get()->toArray();
return GoodsType::query()
return Category::query()
->whereIn('id', array_column($goodsTypeIds, 'category_id')) ->whereIn('id', array_column($goodsTypeIds, 'category_id'))
->orderBy('sort', 'DESC') ->orderBy('sort', 'DESC')
->orderBy('id', 'DESC') ->orderBy('id', 'DESC')

14
app/Service/v3/Implementations/SearchService.php

@ -44,19 +44,7 @@ class SearchService implements \App\Service\v3\Interfaces\SearchServiceInterface
} }
$builder->select(['id', 'store_id', 'cover_img', 'name', 'spec', 'tags', 'original_price', 'price', 'inventory', 'sales as total_sales']); $builder->select(['id', 'store_id', 'cover_img', 'name', 'spec', 'tags', 'original_price', 'price', 'inventory', 'sales as total_sales']);
$goods = $builder->forPage($params['page'], $params['pagesize'])->get()->toArray();
$data = [];
foreach ($goods as $key => &$item) {
$store = (object)$item['store'];
unset($item['store']);
$data[] = [
'goods' => $item,
'store' => $store
];
}
return $data;
return $goods = $builder->forPage($params['page'], $params['pagesize'])->get()->toArray();
} }
public function doForStores($params) public function doForStores($params)

Loading…
Cancel
Save