From 9d2a1422aaa725574c9550c38b0b715f17604a8d Mon Sep 17 00:00:00 2001 From: zengyyh Date: Sun, 28 Jul 2024 15:38:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Controller.php | 3 +++ app/store/controller/Controller.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/app/api/controller/Controller.php b/app/api/controller/Controller.php index e3baf3ef..8b97be92 100644 --- a/app/api/controller/Controller.php +++ b/app/api/controller/Controller.php @@ -100,6 +100,9 @@ class Controller extends BaseController if ($store['is_recycle'] || $store['is_delete']) { throwError('很抱歉,当前商城已删除'); } + if($store['effective_time']storeInfo = $store; } diff --git a/app/store/controller/Controller.php b/app/store/controller/Controller.php index 0f1a90e9..c21caeff 100644 --- a/app/store/controller/Controller.php +++ b/app/store/controller/Controller.php @@ -18,6 +18,7 @@ use app\store\service\Auth as AuthService; use app\common\service\store\User as StoreUserService; use cores\exception\BaseException; use app\common\model\Merchant as MerchantModel; +use app\api\model\Store as StoreModel; /** * 商户后台控制器基类 @@ -32,6 +33,8 @@ class Controller extends BaseController // 当前商城ID protected int $storeId; + protected $storeInfo; + // 当前商户ID protected int $merchantId = 0; @@ -84,6 +87,8 @@ class Controller extends BaseController $this->checkMethodRules(); $this->getMerchantId(); + // 验证当前商城状态 + $this->checkStore(); } /** @@ -188,4 +193,27 @@ class Controller extends BaseController } throwError('illegal request method'); } + + /** + * 验证当前商城状态 + * @return void + * @throws BaseException + */ + private function checkStore(): void + { + // 获取当前商城信息 + $store = StoreModel::detail($this->storeId); + if (empty($store)) { + throwError('很抱歉,当前商城信息不存在'); + } + if ($store['is_recycle'] || $store['is_delete']) { + throwError('很抱歉,当前商城已删除'); + } + if($store['effective_time']storeInfo = $store; + } + + }