roleAllow(UserRole::NORMAL_ADMIN); } protected function getParam(): IParam { return $this->param; } protected function run(Request $request): Response { $param = $this->param; $a = $param->toArray(); try { $this->transaction->beginTransaction(); $targets = $this->repository->get( [ ...$param->toArray(), ReceiptIssuingOrderRepository::CONDITION_CONTRACT_ID => $this->loginUser()->getCurrentContractId(), ReceiptIssuingOrderRepository::CONDITION_IS_CONFIRMED => true, ReceiptIssuingOrderRepository::CONDITION_HAS_MAILORDER => true, ] ); $models = ReceiptIssuingOrder::findMany(Arr::pluck($targets, ReceiptIssuingOrder::COL_NAME_ID)); $documents = $this->manager->initForDownloadLetters()->downlaodLetters($models); $this->updatePostDate($models); $this->transaction->commit(); } catch (Exception $e) { $this->transaction->rollBack(); throw $e; } return $documents; } private function updatePostDate(Collection $models) { foreach ($models as $order) { $manager = UpdateManager::instance(); $messages = $manager->initById($order->id) ->mailPosted(DateUtil::now()) ->update(); if (count($messages) !== 0) { throw new AppCommonException(Arr::first($messages)); } } } }