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.

115 lines
3.7 KiB

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