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.

49 lines
1.4 KiB

5 years ago
  1. <?php
  2. namespace App\Controller\v3;
  3. use App\Controller\BaseController;
  4. use App\Model\v3\Market;
  5. use App\Service\v3\Interfaces\LocationServiceInterface;
  6. use Hyperf\Di\Annotation\Inject;
  7. /**
  8. * 定位相关
  9. * Class LocationController
  10. * @package App\Controller\v3
  11. */
  12. class LocationController extends BaseController
  13. {
  14. /**
  15. * @Inject
  16. * @var LocationServiceInterface
  17. */
  18. protected $locationService;
  19. /**
  20. * 获取当前用户定位最近的市场
  21. * 1.用户上报经纬度数据
  22. * 2.如果经纬度不存在或无法获取到最近市场信息,则返回空数据
  23. * 3.根据经纬度查询获取市场数据,id、名称、省份、城市、行政区、地址、经纬度
  24. */
  25. public function getNearestMarket()
  26. {
  27. $lng = $this->request->input('lng',0);
  28. $lat = $this->request->input('lat',0);
  29. return $this->success(['market' => $this->locationService->getNearestMarket($lng,$lat)]);
  30. }
  31. public function getMarketListByLocation()
  32. {
  33. $lng = $this->request->input('lng',0);
  34. $lat = $this->request->input('lat',0);
  35. return $this->success($this->locationService->getMarketListByLocation($lng,$lat));
  36. }
  37. public function getMarketsInfo()
  38. {
  39. $ret = [];
  40. $ret['service_time']='8:30-20:00';
  41. $ret['markets_info']=$this->locationService->getMarketsInfo();
  42. return $this->success($ret);
  43. }
  44. }