input(); list($permittingOwnerIds, $owner_id, $start, $end) = $this->getRequestParams($request); $details = $this->service->getDetails($owner_id, $start, $end, $paginateParams); $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get(); $owner = Owner::query()->selectRaw("name")->find($owner_id); return view('finance.settlementBills.logisticFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner')); } public function export(Request $request) { list($permittingOwnerIds, $owner_id, $start, $end) = $this->getRequestParams($request); $query = $this->service->getSql($owner_id, $start, $end); if (!$request->exists('checkAllSign')) { $query->whereIn('id', explode(',', $request['data'])); } $details = $this->service->buildDetails($query->get()); $json = []; foreach ($details as $detail) { $json[] = array_values($detail); } $row = ['主键', '快递公司', '省份', '快递单号', '重量', '首重价格', '续重价格', '快递费',]; return Export::make($row, $json, "快递费用详情"); } /** * @param Request $request * @return array */ private function getRequestParams(Request $request): array { $this->service = app('OwnerLogisticFeeDetailService'); $this->userService = app('UserService'); $permittingOwnerIds = $this->userService->getPermittingOwnerIds(auth()->user()); if (is_null($request->owner_id)) { $owner_id = $permittingOwnerIds[0]; } else { $owner_id = $request->owner_id; } if (is_null($request->start)) { $start = now()->subMonth()->startOfMonth()->toDateString(); } else { $start = $request->start; } if (is_null($request->end)) { $end = now()->subMonth()->endOfMonth()->toDateString(); } else { $end = $request->end; } return array($permittingOwnerIds, $owner_id, $start, $end); } }