From 72619f6208d1d7cf90f1c072e502e9470d2a4a86 Mon Sep 17 00:00:00 2001 From: ctexthuang Date: Thu, 15 May 2025 15:31:33 +0800 Subject: [PATCH] feat : sts --- app/Constants/Common/CategoryCode.php | 2 +- app/Service/Admin/Good/SpuService.php | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/Constants/Common/CategoryCode.php b/app/Constants/Common/CategoryCode.php index dfc6015..5d4ab7f 100644 --- a/app/Constants/Common/CategoryCode.php +++ b/app/Constants/Common/CategoryCode.php @@ -12,4 +12,4 @@ class CategoryCode CONST int EXTRA_STAPLE = 3; CONST int SOUP = 5; -} \ No newline at end of file +} diff --git a/app/Service/Admin/Good/SpuService.php b/app/Service/Admin/Good/SpuService.php index ddf3895..6c43fa9 100644 --- a/app/Service/Admin/Good/SpuService.php +++ b/app/Service/Admin/Good/SpuService.php @@ -10,6 +10,7 @@ declare(strict_types=1); namespace App\Service\Admin\Good; +use App\Cache\Redis\Api\GoodCache; use App\Constants\Admin\UserCode; use App\Constants\Common\GoodCode; use App\Constants\Common\SiteCode; @@ -190,6 +191,12 @@ class SpuService extends BaseService #[Inject] protected Chef $chefModel; + /** + * @var GoodCache + */ + #[Inject] + protected GoodCache $goodCache; + /** * 信息检测 * @return void @@ -222,7 +229,10 @@ class SpuService extends BaseService $this->checkInfo(); - $info->kitchen_id = $this->request->input('kitchen_id'); + $kitchenId = (int)$this->request->input('kitchen_id'); + $oldKitchenId = (int)$info->kitchen_id; + + $info->kitchen_id = $kitchenId; // $info->chef_id = $this->request->input('chef_id'); $info->title = $this->request->input('title'); $info->caterer_id = $this->request->input('caterer_id'); @@ -234,6 +244,10 @@ class SpuService extends BaseService if (!$info->save()) throw new ErrException('修改菜品失败'); + //删除缓存 + if ($oldKitchenId != $kitchenId) $this->goodCache->delCache($kitchenId,$info->cycle_id); + $this->goodCache->delCache($oldKitchenId,$info->cycle_id); + return $this->return->success(); } @@ -258,6 +272,9 @@ class SpuService extends BaseService $info->is_del = GoodCode::SPU_IS_DELETE; $info->save(); + //删除缓存 + $this->goodCache->delCache($info->kitchen_id,$info->cycle_id); + return $this->return->success(); }