startOfMonth()->startOfDay()->toDateTimeString(); $end = Carbon::parse($counting_month)->endOfMonth()->endOfDay()->toDateTimeString(); return array($start, $end); } /** * 确认账单 * @param $counting_month * @param $owner_id */ public function confirmBill($counting_month, $owner_id) { $billReport = OwnerBillReport::query() ->select('id') ->where('owner_id', $owner_id) ->where('counting_month', $counting_month) ->firstOr(function () { return new OwnerBillReport(); }); 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' => [], ]); $this->confirmBillFeeTotal($counting_month, $owner_id); } /** * 确认总账单费用 * @param $counting_month * @param $owner_id */ public function confirmBillFeeTotal($counting_month, $owner_id): void { if ($this::TYPE !== '总费用') { /**@var $archiveService OwnerBillReportArchiveService */ $archiveService = app('OwnerBillReportArchiveService'); if (count($archiveService->getUnAchieved($counting_month, $owner_id)) == 0) {//全部子项已经确认完成 //确认总费用 /**@var $totalFeeService OwnerFeeTotalService */ $totalFeeService = app('OwnerFeeTotalService'); $totalFeeService->confirmBill($counting_month, $owner_id); } } } }