You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB

  1. <?php
  2. namespace App\Controller\v3;
  3. use App\Controller\BaseController;
  4. use App\Request\v3\SearchGoodsRequest;
  5. use App\Service\v3\Interfaces\SearchServiceInterface;
  6. use Hyperf\Di\Annotation\Inject;
  7. use Psr\Http\Message\ResponseInterface;
  8. class SearchController extends BaseController
  9. {
  10. /**
  11. * @Inject
  12. * @var SearchServiceInterface
  13. */
  14. protected $searchService;
  15. /**
  16. * 获取搜索热词
  17. * 1、参数type区分是商品还是商户
  18. * 2、不同type处理不同的service获取热词
  19. */
  20. public function hotKeywords()
  21. {
  22. $type = $this->request->input('type', 'goods');
  23. $keywords = $this->searchService->getHotKeywords($type);
  24. return $this->success(['keywords' => $keywords]);
  25. }
  26. /**
  27. * 商品搜索
  28. * 1、筛选条件:商品分类、商品关键词
  29. * 2、排序:综合排序、销量最多、价格高/
  30. * 3、返回数据格式,大购物车统计+商品数据含有id、封面图、名称、原价、现价、库存、月销、tag、规格、购物车相关、商户id、商户avatar、商户名
  31. * @param SearchGoodsRequest $request
  32. * @return ResponseInterface
  33. */
  34. public function goods(SearchGoodsRequest $request)
  35. {
  36. $params = $request->validated();
  37. $data = $this->searchService->doForGoods($params);
  38. return $this->success(['goods' => $data]);
  39. }
  40. public function stores()
  41. {
  42. }
  43. }