|
|
@@ -32,49 +32,45 @@ class BaseController extends PublicController
|
|
|
Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'mall');
|
|
|
$this->isWx = util::isWx();
|
|
|
$userId = jwt::getLoginId();
|
|
|
- if (!empty($userId)) {
|
|
|
- $this->userId = $userId;
|
|
|
- $user = UserClass::getById($userId, true);
|
|
|
- if (empty($user)) {
|
|
|
- if (!in_array($action->id, $this->guestAccess)){
|
|
|
- util::fail('请先登录');
|
|
|
- }
|
|
|
+ if (empty($userId)) {
|
|
|
+ if (!in_array($action->id, $this->guestAccess)) {
|
|
|
+ util::fail('请先登录');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->userId = $userId;
|
|
|
+ $user = UserClass::getById($userId, true);
|
|
|
+ if (empty($user)) {
|
|
|
+ if (!in_array($action->id, $this->guestAccess)) {
|
|
|
+ util::fail('请先登录');
|
|
|
}
|
|
|
- $this->user = $user;
|
|
|
- $shopId = Yii::$app->request->get('account', 0);
|
|
|
- if (!empty($shopId)) {
|
|
|
- $this->shopId = $shopId;
|
|
|
- $shop = ShopClass::getById($shopId, true);
|
|
|
- if (!empty($shop)) {
|
|
|
- $this->shop = $shop;
|
|
|
- $mainId = $shop->mainId ?? 0;
|
|
|
- $main = MainClass::getById($mainId, true);
|
|
|
- $this->main = $main;
|
|
|
- $this->mainId = $mainId;
|
|
|
- $hdId = Yii::$app->request->get('hdId', 0);
|
|
|
- $hd = HdClass::getById($hdId, true);
|
|
|
- if (!empty($hd)) {
|
|
|
- if ($hd->userId != $this->userId) {
|
|
|
- util::fail('不是你的花店,无法访问哦');
|
|
|
- }
|
|
|
- if ($shopId != $hd->shopId) {
|
|
|
- util::fail('花店信息有问题哦');
|
|
|
- }
|
|
|
- $this->hd = $hd;
|
|
|
- $customId = $hd->customId ?? 0;
|
|
|
- $custom = CustomClass::getById($customId, true);
|
|
|
- $this->custom = $custom;
|
|
|
- } else {
|
|
|
- $respond = CustomClass::buildRelation($shop, $user);
|
|
|
- $hd = $respond['hd'];
|
|
|
- $custom = $respond['custom'];
|
|
|
- $this->hd = $hd;
|
|
|
- $this->custom = $custom;
|
|
|
+ }
|
|
|
+ $this->user = $user;
|
|
|
+ $shopId = Yii::$app->request->get('account', 0);
|
|
|
+ if (!empty($shopId)) {
|
|
|
+ $this->shopId = $shopId;
|
|
|
+ $shop = ShopClass::getById($shopId, true);
|
|
|
+ if (!empty($shop)) {
|
|
|
+ $this->shop = $shop;
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $main = MainClass::getById($mainId, true);
|
|
|
+ $this->main = $main;
|
|
|
+ $this->mainId = $mainId;
|
|
|
+ $hdId = Yii::$app->request->get('hdId', 0);
|
|
|
+ $hd = HdClass::getById($hdId, true);
|
|
|
+ if (!empty($hd)) {
|
|
|
+ if ($hd->userId != $this->userId) {
|
|
|
+ util::fail('不是你的花店,无法访问哦');
|
|
|
+ }
|
|
|
+ if ($shopId != $hd->shopId) {
|
|
|
+ util::fail('花店信息有问题哦');
|
|
|
}
|
|
|
+ $this->hd = $hd;
|
|
|
+ $customId = $hd->customId ?? 0;
|
|
|
+ $custom = CustomClass::getById($customId, true);
|
|
|
+ $this->custom = $custom;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return parent::beforeAction($action);
|
|
|
}
|
|
|
|