|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace shop\controllers;
|
|
|
|
|
|
+use biz\admin\classes\AdminClass;
|
|
|
use biz\admin\services\ShopAdminService;
|
|
|
use biz\merchant\services\AdminService;
|
|
|
use biz\merchant\services\MerchantExtendService;
|
|
|
@@ -14,62 +15,62 @@ use common\components\util;
|
|
|
|
|
|
class BaseController extends PublicController
|
|
|
{
|
|
|
- public $admin, $adminId, $adminAvatar, $account;
|
|
|
- public $merchantId = 0, $merchantName, $merchant, $merchantExtend, $merchantLogo, $signPackage, $shopId = 0;
|
|
|
- public $appId;
|
|
|
- public $isWx = false;
|
|
|
- public $isLogin = false;
|
|
|
- public $withoutLogin = [];//不需要登陆的方法名
|
|
|
- public $validate = true;
|
|
|
+ public $admin, $adminId, $adminAvatar, $account;
|
|
|
+ public $merchantId = 0, $merchantName, $merchant, $merchantExtend, $merchantLogo, $signPackage, $shopId = 0;
|
|
|
+ public $appId;
|
|
|
+ public $isWx = false;
|
|
|
+ public $isLogin = false;
|
|
|
+ public $withoutLogin = [];//不需要登陆的方法名
|
|
|
+ public $validate = true;
|
|
|
|
|
|
- //shish 2020.3.8
|
|
|
- public function beforeAction($action)
|
|
|
- {
|
|
|
- //token验证
|
|
|
- //$adminId = jwt::getLoginId();
|
|
|
+ //shish 2020.3.8
|
|
|
+ public function beforeAction($action)
|
|
|
+ {
|
|
|
+ //token验证
|
|
|
+ //$adminId = jwt::getLoginId();
|
|
|
$adminId = 18569;
|
|
|
- $merchantId = 0;
|
|
|
- $merchant = [];
|
|
|
- $merchantExtend = [];
|
|
|
- $admin = [];
|
|
|
- if (empty($adminId)) {
|
|
|
- $this->validate = false;
|
|
|
- } else {
|
|
|
- $admin = AdminService::getById($adminId);
|
|
|
- if (empty($admin)) {
|
|
|
- util::fail('帐号无效');
|
|
|
- }
|
|
|
- $adminId = $admin['id'];
|
|
|
- $shopId = Yii::$app->redis->executeCommand('GET', ['LOGIN_ADMIN_SHOP' . $adminId]);
|
|
|
- //取不到门店id可能被清缓存,需要重新登陆,$shopId = 0 则表示非管理员,没有关联的门店,只可以访问官网
|
|
|
- if (is_numeric($shopId) == false) {
|
|
|
- util::notLogin('登陆已失效,请重新登陆');
|
|
|
- }
|
|
|
- if (!empty($shopId)) {
|
|
|
- $shop = ShopService::getById($shopId);
|
|
|
- if (empty($shop)) {
|
|
|
- util::fail('您所管理的门店已经跑到月球上去了');
|
|
|
- }
|
|
|
- $merchantId = $shop['merchantId'];
|
|
|
- $merchant = MerchantService::getMerchantById($merchantId);
|
|
|
- $merchantExtend = MerchantExtendService::getByMerchantId($merchantId);
|
|
|
- }
|
|
|
- $this->shopId = $shopId;
|
|
|
- }
|
|
|
- //游客可以访问的方法
|
|
|
- if (in_array($action->id, $this->withoutLogin)) {
|
|
|
- $this->validate = true;
|
|
|
- }
|
|
|
- if ($this->validate == false) {
|
|
|
- util::notLogin('您还没有登陆哦');
|
|
|
- }
|
|
|
- $this->admin = $admin;
|
|
|
- $this->adminId = $adminId;
|
|
|
- $this->merchantId = $merchantId;
|
|
|
- $this->merchant = $merchant;
|
|
|
- $this->merchantExtend = $merchantExtend;
|
|
|
- return parent::beforeAction($action);
|
|
|
- }
|
|
|
+ $merchantId = 0;
|
|
|
+ $merchant = [];
|
|
|
+ $merchantExtend = [];
|
|
|
+ $admin = [];
|
|
|
+ if (empty($adminId)) {
|
|
|
+ $this->validate = false;
|
|
|
+ } else {
|
|
|
+ $admin = AdminClass::getAdminById($adminId, true);
|
|
|
+ if (empty($admin)) {
|
|
|
+ util::fail('帐号无效');
|
|
|
+ }
|
|
|
+ $adminId = $admin['id'];
|
|
|
+ $shopId = Yii::$app->redis->executeCommand('GET', ['LOGIN_ADMIN_SHOP' . $adminId]);
|
|
|
+ //取不到门店id可能被清缓存,需要重新登陆,$shopId = 0 则表示非管理员,没有关联的门店,只可以访问官网
|
|
|
+ if (is_numeric($shopId) == false) {
|
|
|
+ util::notLogin('登陆已失效,请重新登陆');
|
|
|
+ }
|
|
|
+ if (!empty($shopId)) {
|
|
|
+ $shop = ShopService::getById($shopId);
|
|
|
+ if (empty($shop)) {
|
|
|
+ util::fail('您所管理的门店已经跑到月球上去了');
|
|
|
+ }
|
|
|
+ $merchantId = $shop['merchantId'];
|
|
|
+ $merchant = MerchantService::getMerchantById($merchantId);
|
|
|
+ $merchantExtend = MerchantExtendService::getByMerchantId($merchantId);
|
|
|
+ }
|
|
|
+ $this->shopId = $shopId;
|
|
|
+ }
|
|
|
+ //游客可以访问的方法
|
|
|
+ if (in_array($action->id, $this->withoutLogin)) {
|
|
|
+ $this->validate = true;
|
|
|
+ }
|
|
|
+ if ($this->validate == false) {
|
|
|
+ util::notLogin('您还没有登陆哦');
|
|
|
+ }
|
|
|
+ $this->admin = $admin;
|
|
|
+ $this->adminId = $adminId;
|
|
|
+ $this->merchantId = $merchantId;
|
|
|
+ $this->merchant = $merchant;
|
|
|
+ $this->merchantExtend = $merchantExtend;
|
|
|
+ return parent::beforeAction($action);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|