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.

101 lines
3.2 KiB

5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Controller\v3;
  3. use App\Controller\BaseController;
  4. use App\Request\v3\StoreIndexRequest;
  5. use App\Service\v3\Interfaces\CategoryServiceInterface;
  6. use App\Service\v3\Interfaces\CollectStoreServiceInterface;
  7. use App\Service\v3\Interfaces\GoodsServiceInterface;
  8. use App\Service\v3\Interfaces\StoreServiceInterface;
  9. use Hyperf\Di\Annotation\Inject;
  10. use Psr\Http\Message\ResponseInterface;
  11. use \App\Service\v3\Interfaces\BusinessHoursServiceInterface;
  12. class StoreController extends BaseController
  13. {
  14. /**
  15. * @Inject
  16. * @var StoreServiceInterface
  17. */
  18. protected $storeService;
  19. /**
  20. * @Inject
  21. * @var CategoryServiceInterface
  22. */
  23. protected $categoryService;
  24. /**
  25. * @Inject
  26. * @var CollectStoreServiceInterface
  27. */
  28. protected $collectService;
  29. /**
  30. * @Inject
  31. * @var BusinessHoursServiceInterface
  32. */
  33. protected $businessHoursService;
  34. /**
  35. * @Inject
  36. * @var GoodsServiceInterface
  37. */
  38. protected $goodsService;
  39. /**
  40. * 商户详情页
  41. * 1、商户id用来查询的,还要有user_id
  42. * 2、返回数据,id、logo、name、收藏状态、简介、地址、营业状态、营业时间、联系电话
  43. * 3、返回数据,商品推荐的分类,需要经过商户商品反查
  44. * 4、分类下的商品,则复用商品搜索接口
  45. * @param StoreIndexRequest $request
  46. * @return ResponseInterface
  47. */
  48. public function index(StoreIndexRequest $request)
  49. {
  50. $params = $this->request->all();
  51. $data = $this->storeService->detail($params['store_id']);
  52. $data['is_collected'] = (bool)$this->collectService->check($params['user_id'],$params['store_id']);
  53. $data['goods_types'] = $this->categoryService->allForStore($params['store_id']);
  54. $data['in_business'] = $this->storeService->check($params['store_id']);
  55. if($data['in_business'] === true)
  56. {
  57. $data['in_business_text'] = '营业中';
  58. }else{
  59. $data['in_business_text'] = '休息中';
  60. }
  61. return $this->success(['store' => $data]);
  62. }
  63. public function getBusinessHours()
  64. {
  65. $storeId = $this->request->input('store_id');
  66. $res = $this->businessHoursService->check($storeId);
  67. return $this->success($res);
  68. }
  69. public function updateBusinessHours()
  70. {
  71. $storeId = $this->request->input('store_id');
  72. $isRest = $this->request->input('is_rest','');
  73. $time1 = $this->request->input('time1','');
  74. $time2 = $this->request->input('time2','');
  75. $time3 = $this->request->input('time3','');
  76. $time4 = $this->request->input('time4','');
  77. $res = $this->businessHoursService->do($storeId,$isRest,$time1,$time2,$time3,$time4);
  78. return $this->success($res);
  79. }
  80. public function getGoodsByType()
  81. {
  82. $storeId = $this->request->input('store_id');
  83. $typeId = $this->request->input('type_id','');
  84. $page = $this->request->input('page',1);
  85. $pagesize = $this->request->input('pagesize',10);
  86. $goods = $this->goodsService->getByType($storeId,$typeId,$page,$pagesize);
  87. return $this->success($goods);
  88. }
  89. }