|
|
@@ -3,9 +3,55 @@
|
|
|
namespace open\controllers;
|
|
|
|
|
|
use Yii;
|
|
|
-use yii\web\Controller;
|
|
|
+use biz\merchant\services\MerchantExtendService;
|
|
|
+use biz\merchant\services\MerchantService;
|
|
|
+use biz\user\services\UserService;
|
|
|
+use common\components\httpUtil;
|
|
|
+use common\components\jwt;
|
|
|
+use common\components\util;
|
|
|
|
|
|
class BaseController extends PublicController
|
|
|
{
|
|
|
|
|
|
+ public $validate = true;
|
|
|
+ public $withoutLogin = [];//不需要登陆可以访问的方法
|
|
|
+ public $userId, $user;
|
|
|
+ public $merchantId, $merchant, $merchantExtend;
|
|
|
+ public $isWeixin;
|
|
|
+
|
|
|
+ public function beforeAction($action)
|
|
|
+ {
|
|
|
+ //token验证
|
|
|
+ //$userId = jwt::getLoginId();
|
|
|
+ $userId = 12536630;
|
|
|
+ $account = 12358;
|
|
|
+ if (empty($account)) {
|
|
|
+ util::fail('商家无效');
|
|
|
+ }
|
|
|
+ $merchant = MerchantService::getById($account);
|
|
|
+ if (empty($merchant)) {
|
|
|
+ util::fail('商家信息无效');
|
|
|
+ }
|
|
|
+ $this->merchantId = $account;
|
|
|
+ $this->merchant = $merchant;
|
|
|
+ $this->merchantExtend = MerchantExtendService::getByMerchantId($account);
|
|
|
+ $this->isWeixin = util::isWeixin();
|
|
|
+
|
|
|
+ if (empty($userId)) {
|
|
|
+ $this->validate = false;
|
|
|
+ } else {
|
|
|
+ $this->validate = true;
|
|
|
+ $this->userId = $userId;
|
|
|
+ $this->user = UserService::getById($userId);
|
|
|
+ }
|
|
|
+ //游客可以访问的方法
|
|
|
+ if (in_array($action->id, $this->withoutLogin)) {
|
|
|
+ $this->validate = true;
|
|
|
+ }
|
|
|
+ if ($this->validate == false) {
|
|
|
+ util::notLogin();
|
|
|
+ }
|
|
|
+ return parent::beforeAction($action);
|
|
|
+ }
|
|
|
+
|
|
|
}
|