archiveService = app('OwnerBillReportArchiveService'); $counting_month = $kvPairs['counting_month']; $owner_id = $kvPairs['owner_id']; if ($this->archiveService->isArchived($kvPairs['counting_month'], $kvPairs['owner_id'], $kvPairs['type']) == 1) { $archived = $this->archiveService->get($kvPairs); $areaReports = collect($archived->information['areaReports']); $billReport = collect($archived->information['billReport']); } else { $areaReports = OwnerAreaReport::query() ->with(['ownerStoragePriceModel' => function ($query) { $query->selectRaw("id,using_type,price,unit_id,unit_id,time_unit_id,name,minimum_area") ->with(['unit:id,name', 'timeUnit:id,name']); }]) ->where('owner_id', $owner_id) ->where('counting_month', $counting_month) ->get(); $billReport = OwnerBillReport::query() ->select(['storage_fee', 'id']) ->where('owner_id', $owner_id) ->where('counting_month', $counting_month) ->firstOr(function () { return new OwnerBillReport(); }); } return array($areaReports, $billReport); } public function getSql($owner_id, $counting_month): \Illuminate\Database\Eloquent\Builder { // TODO: Implement getSql() method. } public function getTotalFee($owner_id, $counting_month) { return OwnerBillReport::query() ->where('owner_id', $owner_id) ->where('counting_month', $counting_month) ->first(); } public function switchType($type) { // TODO: Implement switchType() method. } public function buildExport($details): array { // TODO: Implement buildExport() method. } public function add(array $model) { // TODO: Implement add() method. } public function recordReport($counting_month = null,array $ownerIds = []) { // TODO: Implement recordReport() method. } public function confirmBill($counting_month, $owner_id) { list($areaReports, $billReport) = $this->get([ 'owner_id' => $owner_id, 'counting_month' => $counting_month, 'type' => $this::TYPE, ]); OwnerBillReportArchive::query()->create([ 'owner_bill_report_id' => $billReport->id ?? null, 'owner_id' => $owner_id, 'counting_month' => $counting_month, 'type' => $this::TYPE, 'archiver_id' => auth()->id(), 'archived_at' => now(), 'information' => [ 'areaReports' => $areaReports, 'billReport' => $billReport, ], ]); $this->confirmBillFeeTotal($counting_month, $owner_id); } }