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.
91 lines
2.5 KiB
91 lines
2.5 KiB
<?php
|
|
|
|
|
|
namespace App\Service\v3\Implementations;
|
|
use App\Model\v3\Market;
|
|
use App\Model\v3\OrderMain;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use App\Service\v3\Interfaces\HorsemanServiceInterface;
|
|
use Hyperf\Utils\ApplicationContext;
|
|
use App\Constants\v3\SsdbKeys;
|
|
use App\TaskWorker\SSDBTask;
|
|
use App\Constants\v3\ErrorCode;
|
|
use App\Exception\ErrorCodeException;
|
|
class HorsemanService implements HorsemanServiceInterface
|
|
{
|
|
public function do()
|
|
{
|
|
// TODO: Implement do() method.
|
|
}
|
|
|
|
public function check()
|
|
{
|
|
// TODO: Implement check() method.
|
|
}
|
|
|
|
public function undo()
|
|
{
|
|
// TODO: Implement undo() method.
|
|
}
|
|
public function getOrderList()
|
|
{
|
|
return OrderMain::query()->where('state',3)->limit(5)->get();
|
|
}
|
|
|
|
/**
|
|
* 记录骑手坐标
|
|
*/
|
|
public function setHorsemanCoordinate($employeesId,$coordinate){
|
|
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
|
|
if(false === $ssdb->exec('set', SsdbKeys::HORSEMAN_COORDINATE.$employeesId,$coordinate)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 获取骑手坐标
|
|
*/
|
|
public function getHorsemanCoordinate($employeesId){
|
|
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
|
|
$params = $ssdb->exec('get', SsdbKeys::HORSEMAN_COORDINATE.$employeesId);
|
|
|
|
if ((false === $params) || empty($params)) {
|
|
throw new ErrorCodeException(ErrorCode::HORSEMAN_COORDINATE_FAIL, '获取骑手坐标失败');
|
|
}
|
|
return $params;
|
|
}
|
|
|
|
/**
|
|
* 获取订单起止坐标
|
|
*/
|
|
public function getOrderCoordinate($globalOrderId){
|
|
//获取订单信息
|
|
$order = OrderMain::where('global_order_id',$globalOrderId)
|
|
->select(
|
|
'lat as origi_lat',
|
|
'lng as origi_lng',
|
|
'state',
|
|
'market_id'
|
|
)
|
|
->first();
|
|
if($order->state != 3)
|
|
{
|
|
return false;
|
|
}
|
|
//获取市场信息
|
|
$market = Market::where('id',$order->market_id)
|
|
->select(
|
|
'lat as destination_lat',
|
|
'lng as destination_lng'
|
|
)
|
|
->first();
|
|
$res = [
|
|
'origi_lat' => $order->origi_lat,
|
|
'origi_lng' => $order->origi_lng,
|
|
'destination_lat' => $market->destination_lat,
|
|
'destination_lng' => $market->destination_lng
|
|
];
|
|
return $res;
|
|
}
|
|
}
|