service = app('OwnerStoreOutFeeReportService'); $this->archiveService = app('OwnerBillReportArchiveService'); } public function index(Request $request) { list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id); list($reports, $work_name_fee_total, $fee_total) = $this->service->get([ 'owner_id' => $owner_id, 'counting_month' => $counting_month, 'type' => $this->service::TYPE, ]); $owner = Owner::query()->selectRaw("name,id")->find($owner_id); $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get(); $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE); $request = $this->buildRequest($request, $counting_month); return view('finance.settlementBills.storeOutFee.report.index', compact('reports', 'owners', 'owner', 'isArchived', 'request', 'reports', 'work_name_fee_total', 'fee_total')); } public function confirmBill(Request $request): RedirectResponse { list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id); $billReport = OwnerBillReport::query() ->select('storage_fee', 'id') ->where('owner_id', $owner_id) ->where('counting_month', $counting_month) ->firstOr(function () { return new OwnerBillReport(); }); list($reports, $work_name_fee_total, $fee_total) = $this->service->get([ 'owner_id' => $owner_id, 'counting_month' => $counting_month, 'type' => $this->service::TYPE, ]); 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' => [ 'reports' => $reports, 'work_name_fee_total' => $work_name_fee_total, 'fee_total' => $fee_total, ], ]); return back()->with('success', '确认成功'); } public function export(Request $request) { list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id); list($reports, $work_name_fee_total, $fee_total) = $this->service->get([ 'owner_id' => $owner_id, 'counting_month' => $counting_month, 'type' => $this->service::TYPE, ]); $json = []; foreach ($reports as $report) { $fee = ''; foreach ($work_name_fee_total as $item) { if ($item['work_name'] == $report['work_name']) { $fee = $item['fee']; continue; } } $json[] = [ $report['work_name'], $report['step'], $report['unit_price'] . '元/' . $report['unit']['name'] ?? '', $report['amount'], $fee, ]; } $row = ['作业名称', '阶梯', '单价', '数量', '合计',]; return Export::make($row, $json, "出库费合计"); } }