archiveService = app('OwnerBillReportArchiveService'); $this->service = app('OwnerProcurementSettlementBillService'); } public function index(Request $request) { $paginateParams = $request->input(); list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id); list($details, $total_fee) = $this->service->get([ 'counting_month' => $counting_month, 'owner_id' => $owner_id, 'type' => $this->service::TYPE, ]); $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get(); $owner = Owner::query()->selectRaw("name,id")->find($owner_id); $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE); $request = $this->buildRequest($request, $counting_month); return view('finance.settlementBills.packingMaterialFee.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived', 'total_fee')); } /** * @param Request $request * @return RedirectResponse */ 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($details, $total_fee) = $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' => [ 'details' => $details, 'total_fee' => $total_fee, ], ]); return back()->with('success', '确认成功'); } public function export(Request $request) { list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id); $query = $this->service->getSql($owner_id, $counting_month); if (!$request->exists('checkAllSign')) { $query->whereIn('id', explode(',', $request['data'])); } $details = $query->get(); $json = $this->service->buildExport($details); $row = ['采购日期', '材料名称', '材料类型', '规格', '购买数量', '单价', '总计']; return Export::make($row, $json, "包材费"); } }