whereIn('area_id', $area_ids) ->filter($filter) ->where('status', '!=', OrderRent::STATUS_CLOSE_ORDER) ->with('users') ->orderByDesc('id') ->paginate(); return $this->ok(OrderRentResource::collection($order)); } /** * 日租订单详情 * */ public function orderRentDetail(Request $request) { $order_id = $request->get('order_id') ?? ''; if (empty($order_id)) return $this->error('参数错误'); $order = OrderRent::query()->find($order_id); if (empty($order)) return $this->error('找不到该订单,参数错误'); $orderLocations = []; $wx_orderLocations = []; // 订单轨迹 $locationsLog = LocationsLog::where('order_id', (int)$order_id)->where('is_rent', LocationsLog::RENT_YES)->whereBetween('latitude', [3, 53])->whereBetween('longitude', [73, 136])->orderBy('created_at', 'asc')->get(); if (!empty($locationsLog)) { foreach ($locationsLog as $vv) { $orderLocations[] = [$vv->longitude, $vv->latitude]; $wx_orderLocations[] = ['longitude' => $vv->longitude, 'latitude' => $vv->latitude]; } } // Log::info($orderLocations); $data = [ 'order_status' => OrderRent::$statusMaps[$order->status], 'start_use_bike_time' => date('Y-m-d H:i:s', strtotime($order->start_use_bike_time)), 'end_use_bike_time' => $order->end_use_bike_time ? date('Y-m-d H:i:s', strtotime($order->end_use_bike_time)) : '', 'pay_money' => $order->pay_money, 'time_money' => $order->time_money, 'dispatch_money' => $order->dispatch_money, 'bike_no' => $order->bike_no, 'bike_id' => $order->bike_id, 'user_id' => $order->user_id, 'nickname' => $order->users->nickname ?? '', 'mobile' => $order->users->mobile ?? '', 'orderLocations' => $orderLocations, 'start_location' => empty($orderLocations) ? [] : current($orderLocations), 'end_location' => empty($orderLocations) ? [] : end($orderLocations), 'wx_orderLocations' => $wx_orderLocations, 'wx_start_location' => empty($wx_orderLocations) ? [] : current($wx_orderLocations), 'wx_end_location' => empty($wx_orderLocations) ? [] : end($wx_orderLocations), //'center_location' => GetCenterFromDegrees([['lat'=>$orderLocations[0][1],'lng'=>$orderLocations[0][0]],['lat'=>end($orderLocations)[1],'lng'=>end($orderLocations)[0]]]) ]; return $this->ok($data); } }