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.4 KiB
84 lines
2.4 KiB
<?php
|
|
|
|
namespace App\Controller\v3;
|
|
|
|
use App\Constants\v3\ErrorCode;
|
|
use App\Controller\BaseController;
|
|
use App\Exception\ErrorCodeException;
|
|
use App\Model\v3\Market;
|
|
use App\Service\v3\Interfaces\LocationServiceInterface;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
|
|
use Hyperf\Validation\ValidationException;
|
|
|
|
/**
|
|
* 定位相关
|
|
* Class LocationController
|
|
* @package App\Controller\v3
|
|
*/
|
|
class LocationController extends BaseController
|
|
{
|
|
/**
|
|
* @Inject
|
|
* @var LocationServiceInterface
|
|
*/
|
|
protected $locationService;
|
|
|
|
/**
|
|
* @Inject()
|
|
* @var ValidatorFactoryInterface
|
|
*/
|
|
protected $validationFactory;
|
|
|
|
/**
|
|
* 获取当前用户定位最近的市场
|
|
* 1.用户上报经纬度数据
|
|
* 2.如果经纬度不存在或无法获取到最近市场信息,则返回空数据
|
|
* 3.根据经纬度查询获取市场数据,id、名称、省份、城市、行政区、地址、经纬度
|
|
*/
|
|
public function getNearestMarket()
|
|
{
|
|
$lng = $this->request->input('lng',0);
|
|
$lat = $this->request->input('lat',0);
|
|
return $this->success(['market' => $this->locationService->getNearestMarket($lng,$lat)]);
|
|
}
|
|
|
|
public function getMarketListByLocation()
|
|
{
|
|
$lng = $this->request->input('lng',0);
|
|
$lat = $this->request->input('lat',0);
|
|
return $this->success($this->locationService->getMarketListByLocation($lng,$lat));
|
|
}
|
|
|
|
public function getMarketsInfo()
|
|
{
|
|
$ret = [];
|
|
$ret['service_time']='8:30-20:00';
|
|
$ret['markets_info']=$this->locationService->getMarketsInfo();
|
|
|
|
return $this->success($ret);
|
|
}
|
|
|
|
public function addrSuggestion()
|
|
{
|
|
|
|
$validator = $this->validationFactory->make(
|
|
$this->request->all(),
|
|
['keyword' => 'required|nonempty'],
|
|
['keyword.*' => '关键字不能为空或undefined等']
|
|
);
|
|
|
|
if ($validator->fails()){
|
|
throw new ValidationException($validator);
|
|
}
|
|
|
|
$keyword = $this->request->input('keyword');
|
|
$marketId = $this->request->input('market_id');
|
|
$page = $this->request->input('page');
|
|
$pageSize = $this->request->input('pagesize');
|
|
|
|
$res = $this->locationService->placeSuggestion($keyword, $marketId, $page, $pageSize);
|
|
|
|
return $this->success($res);
|
|
}
|
|
}
|