设置权限

lszyh
zengyyh 4 months ago
parent 322245bc92
commit 9d2a1422aa
  1. 3
      app/api/controller/Controller.php
  2. 28
      app/store/controller/Controller.php

@ -100,6 +100,9 @@ class Controller extends BaseController
if ($store['is_recycle'] || $store['is_delete']) {
throwError('很抱歉,当前商城已删除');
}
if($store['effective_time']<time()){
throwError('很抱歉,当前商城已过期');
}
$this->storeInfo = $store;
}

@ -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']<time()){
throwError('很抱歉,当前商城已过期');
}
$this->storeInfo = $store;
}
}

Loading…
Cancel
Save