From 10945ef56eef6ff2e4a6cf85e9d74d6d78cb6024 Mon Sep 17 00:00:00 2001 From: xing Date: Mon, 3 Jun 2024 21:38:34 +0800 Subject: [PATCH] use match --- app/Jobs/notice.php | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/app/Jobs/notice.php b/app/Jobs/notice.php index 2edc344..ef2af18 100644 --- a/app/Jobs/notice.php +++ b/app/Jobs/notice.php @@ -61,21 +61,12 @@ public function handle(): void { Log::info('===========================开始执行type' . $this->type . ' 的队列============================'); try { - switch ($this->type) { - case 1: - $this->addGoods(); - break; - case 2: - $this->updateGoods(); - break; - case 3: - $this->changeProductState(); - break; - case 4: - case 5: - $this->changePrice(); - break; - } + match ($this->type) { + 1 => $this->addGoods(), + 2 => $this->updateGoods(), + 3 => $this->changeProductState(), + 4, 5 => $this->changePrice(), + }; Log::info('===========================执行完成================================'); } catch (Throwable $throwable) { $this->fail($throwable);