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.

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