|
|
@@ -17,7 +17,7 @@ class BaseController extends PublicController
|
|
|
|
|
|
public $validate = true;
|
|
|
public $guestAccess = [];
|
|
|
- public $userId = 0, $user, $shopId,$shop;
|
|
|
+ public $userId = 0, $user, $shopId, $shop;
|
|
|
public $sjId, $sj, $sjExtend, $customId = 0, $custom = [];
|
|
|
public $isWx;
|
|
|
|
|
|
@@ -28,16 +28,21 @@ class BaseController extends PublicController
|
|
|
|
|
|
$userId = jwt::getLoginId();
|
|
|
|
|
|
- $sjId = 0;
|
|
|
- if (in_array($action->id, $this->guestAccess) == false){
|
|
|
- $header = httpUtil::getHeader();
|
|
|
- $shopId = isset($header['account']) ? $header['account'] : 0;
|
|
|
- if (empty($shopId)) {
|
|
|
- util::fail('没有找到门店');
|
|
|
- }
|
|
|
+ if (empty($userId)) {
|
|
|
+ util::fail('您还没有登陆');
|
|
|
+ }
|
|
|
+ $this->userId = $userId;
|
|
|
+ $userInfo = UserService::getUserInfo($userId);
|
|
|
+ $this->user = $userInfo;
|
|
|
+ $this->isWx = util::isWx();
|
|
|
+
|
|
|
+ $header = httpUtil::getHeader();
|
|
|
+ $shopId = isset($header['account']) ? $header['account'] : 0;
|
|
|
+ $this->shopId = $shopId;
|
|
|
+ if (!empty($shopId)) {
|
|
|
$shop = ShopClass::getById($shopId);
|
|
|
if (empty($shop)) {
|
|
|
- util::fail('没有找到门店哦');
|
|
|
+ util::fail('没有找到门店');
|
|
|
}
|
|
|
$sjId = $shop['merchantId'] ?? 0;
|
|
|
if (empty($sjId)) {
|
|
|
@@ -45,41 +50,24 @@ class BaseController extends PublicController
|
|
|
}
|
|
|
$sj = MerchantService::getMerchantById($sjId);
|
|
|
if (empty($sj)) {
|
|
|
- util::fail('没有找到商家');
|
|
|
+ util::fail('没有找到商家信息');
|
|
|
}
|
|
|
$this->sjId = $sjId;
|
|
|
$this->sj = $sj;
|
|
|
- $this->shopId = $shopId;
|
|
|
$this->shop = $shop;
|
|
|
$this->sjExtend = MerchantExtendService::getByMerchantId($sjId);
|
|
|
- }
|
|
|
-
|
|
|
- $this->isWx = util::isWx();
|
|
|
-
|
|
|
- if (empty($userId)) {
|
|
|
- $this->validate = false;
|
|
|
- } else {
|
|
|
- $this->validate = true;
|
|
|
- $this->userId = $userId;
|
|
|
- $userInfo = UserService::getUserInfo($userId);
|
|
|
- if (empty($userInfo)) {
|
|
|
- util::fail('没有用户信息');
|
|
|
- }
|
|
|
- $this->user = $userInfo;
|
|
|
- if (in_array($action->id, $this->guestAccess) == false) {
|
|
|
- $custom = CustomClass::replaceCustom($sjId, $userInfo);
|
|
|
+ $custom = CustomClass::replaceCustom($sjId, $userInfo, $shopId);
|
|
|
+ if (!empty($custom)) {
|
|
|
$this->custom = $custom;
|
|
|
$customId = $custom['id'] ?? 0;
|
|
|
$this->customId = $customId;
|
|
|
+ } else {
|
|
|
+ if (in_array($action->id, $this->guestAccess) == false) {
|
|
|
+ util::fail('没有找到客户信息,无权限访问');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- //游客可以访问的方法
|
|
|
- if (in_array($action->id, $this->guestAccess)) {
|
|
|
- $this->validate = true;
|
|
|
- }
|
|
|
- if ($this->validate == false) {
|
|
|
- util::notLogin();
|
|
|
- }
|
|
|
+
|
|
|
return parent::beforeAction($action);
|
|
|
}
|
|
|
|