service = app('OwnerFeeTotalService'); $this->archiveService = app('OwnerBillReportArchiveService'); } public function index(Request $request) { $paginateParams = $request->input(); list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id); $feeTotal = $this->service->get([ 'counting_month' => $counting_month, 'owner_id' => $owner_id, 'paginateParams' => $paginateParams, ]); $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,$owner_id); $isArchivedItems = collect([ 'expressFee' => $this->archiveService->isArchived($counting_month, $owner_id, '快递费-合计'), 'logisticFee' => $this->archiveService->isArchived($counting_month, $owner_id, '物流费'), 'packingMaterialFee' => $this->archiveService->isArchived($counting_month, $owner_id, '包材费'), 'processFee' => $this->archiveService->isArchived($counting_month, $owner_id, '加工费'), 'storageFee' => $this->archiveService->isArchived($counting_month, $owner_id, '仓储费'), 'storeFee' => $this->archiveService->isArchived($counting_month, $owner_id, '入库费-合计'), 'storeOutFee' => $this->archiveService->isArchived($counting_month, $owner_id, '出库费-合计'), 'sundryFee' => $this->archiveService->isArchived($counting_month, $owner_id, '杂项费'), 'unloadFee' => $this->archiveService->isArchived($counting_month, $owner_id, '卸货费'), 'indemnityFee' => $this->archiveService->isArchived($counting_month, $owner_id, '理赔费'), ]); return view('finance.settlementBills.totalFee.index', compact('feeTotal', 'paginateParams', 'owners', 'owner', 'request', 'isArchived', 'isArchivedItems')); } public function export(Request $request) { } public function confirmBill(Request $request): \Illuminate\Http\RedirectResponse { list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->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->service::TYPE, 'archiver_id' => auth()->id(), 'archived_at' => now(), 'information' => [], ]); $unArchived = $this->archiveService->getUnAchieved($counting_month, $owner_id); foreach ($unArchived as $type) { switch ($type) { case '仓储费': /**@var $storageFeeService SettlementBillsAreaFeeService */ $storageFeeService = app('SettlementBillsAreaFeeService'); $storageFeeService->confirmBill($counting_month, $owner_id); break; case '快递费-合计': /**@var $expressFeeService OwnerLogisticFeeReportService */ $expressFeeService = app('OwnerLogisticFeeReportService'); $expressFeeService->confirmBill($counting_month, $owner_id); break; case '入库费-合计': /**@var $storeFeeService OwnerStoreFeeReportService */ $storeFeeService = app('OwnerStoreFeeReportService'); $storeFeeService->confirmBill($counting_month, $owner_id); break; case '出库费-合计': /**@var $storeOutFeeService OwnerStoreOutFeeReportService */ $storeOutFeeService = app('OwnerStoreOutFeeReportService'); $storeOutFeeService->confirmBill($counting_month, $owner_id); break; case '物流费': /**@var $logisticFeeService OwnerWaybillSettlementBillService */ $logisticFeeService = app('OwnerWaybillSettlementBillService'); $logisticFeeService->confirmBill($counting_month, $owner_id); break; case '包材费': /**@var $packingMaterialFeeService OwnerProcurementSettlementBillService */ $packingMaterialFeeService = app('OwnerProcurementSettlementBillService'); $packingMaterialFeeService->confirmBill($counting_month, $owner_id); break; case '加工费': /**@var $processFeeService OwnerProcessSettlementBillService */ $processFeeService = app('OwnerProcessSettlementBillService'); $processFeeService->confirmBill($counting_month, $owner_id); break; case '杂项费': /**@var $sundryFeeService OwnerSundryFeeDetailService */ $sundryFeeService = app('OwnerSundryFeeDetailService'); $sundryFeeService->confirmBill($counting_month, $owner_id); break; case '卸货费': /**@var $unloadFeeService OwnerDischargeTaskSettlementBillService */ $unloadFeeService = app('OwnerDischargeTaskSettlementBillService'); $unloadFeeService->confirmBill($counting_month, $owner_id); break; case '理赔费': /**@var $indemnityFeeService SettlementIndemnityFeeService */ $indemnityFeeService = app('SettlementIndemnityFeeService'); $indemnityFeeService->confirmBill($counting_month, $owner_id); break; } } return back()->with('success', '确认成功'); } }