12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Mead
- * Date: 2019/8/6
- * Time: 9:16 PM
- */
- namespace App\Repositories;
- use App\Models\LocationLogMongodb;
- class LocationLogRepository extends BaseRepository
- {
- public function __construct(LocationLogMongodb $model)
- {
- $this->model = $model;
- }
- /**
- * 获取车的最后定位
- * @param $id
- * @return mixed
- * User: Mead
- */
- public function byBikeNoGetLastLocation($bike_no)
- {
- $location = $this->model->where('bike_no', $bike_no)->select(['latitude', 'longitude', 'mileage', 'speed', 'is_yundong'])->orderByDesc('box_time')->first();
- return [
- 'lat' => $location['latitude'],
- 'lng' => $location['longitude'],
- 'mileage' => $location['mileage'],
- 'is_yundong' => $location['is_yundong'],
- 'speed' => $location['speed']
- ];
- }
- /**
- * 根据订单显示获取最后位置
- * @param $id
- * @return array
- * User: Mead
- */
- public function byOrderIdGetLastLocation($id)
- {
- $location = $this->model->where('order_id', $id)->select(['latitude', 'longitude', 'mileage', 'speed', 'is_yundong'])->orderByDesc('box_time')->first();
- return [
- 'lat' => $location['latitude'],
- 'lng' => $location['longitude'],
- 'mileage' => $location['mileage'],
- 'is_yundong' => $location['is_yundong'],
- 'speed' => $location['speed']
- ];
- }
- }
|