middleware('auth'); } public function index(Request $request) { $this->service = app('SettlementBillsAreaFeeService'); $this->archiveService = app('OwnerBillReportArchiveService'); list($permittingOwnerIds, $counting_month, $owner_id) = $this->service->getRequestParams($request->year, $request->month, $request->owner_id); $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, OwnerBillReportArchive::$enums['type']['仓储费']); list($areaReports, $billReport, $price) = $this->service->get($owner_id, $counting_month); $owners = Owner::query()->find($permittingOwnerIds); $owner = Owner::query()->find($owner_id); $request = $request->all(); $request['year'] = Carbon::parse($counting_month)->year; $request['month'] = Carbon::parse($counting_month)->month; $request = collect($request); return view('finance.settlementBills.areaFee.index', compact('owner', 'owners', 'areaReports', 'billReport', 'price', 'request', 'isArchived')); } /** * 确认账单 * @param Request $request * @return RedirectResponse */ public function confirmBill(Request $request) { $this->service = app('SettlementBillsAreaFeeService'); $this->archiveService = app('OwnerBillReportArchiveService'); list($permittingOwnerIds, $counting_month, $owner_id) = $this->service->getRequestParams($request->year, $request->month, $request->owner_id); list($areaReports, $billReport, $price) = $this->service->get($owner_id, $counting_month); OwnerBillReportArchive::query()->create([ 'owner_bill_report_id' => $billReport->id ?? null, 'owner_id' => $owner_id, 'counting_month' => $counting_month, 'type' => $this->service::TYPE, 'archiver_id' => auth()->id(), 'archived_at' => now(), 'information' => [ 'areaReports' => $areaReports, 'billReport' => $billReport, 'price' => $price, ], ]); return back()->with('success', '确认成功'); } public function export(Request $request) { $this->service = app('SettlementBillsAreaFeeService'); list($permittingOwnerIds, $counting_month, $owner_id) = $this->service->getRequestParams($request->year, $request->month, $request->owner_id); list($areaReports, $billReport, $price) = $this->service->get($owner_id, $counting_month); $json = []; foreach ($areaReports as $areaReport) { $json[] = [ $areaReport['owner_storage_price_model']['using_type']??$areaReport['ownerStoragePriceModel']['using_type'], '平面区', $areaReport['area_on_flat'], $areaReport['accounting_area'], $price, $billReport['storage_fee'], ]; $json[] = [ $areaReport['owner_storage_price_model']['using_type']??$areaReport['ownerStoragePriceModel']['using_type'], '整托存储', $areaReport['area_on_tray'], $areaReport['accounting_area'], $price, $billReport['storage_fee'], ]; $json[] = [ $areaReport['owner_storage_price_model']['using_type']??$areaReport['ownerStoragePriceModel']['using_type'], '半托存储', $areaReport['area_on_half_tray'], $areaReport['accounting_area'], $price, $billReport['storage_fee'], ]; } $row = ['仓库类型', '使用区域', '数量', '合计面积', '单价', '金额',]; return Export::make($row, $json, "仓储费"); } }