| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\controllers\cloud\behaviors;
- use app\models\StoreCloud;
- use Yii;
- use yii\base\ActionFilter;
- use yii\helpers\Json;
- use yii\web\Response;
- class MerchantBehaviors extends ActionFilter
- {
- // 接口白名单
- public static $allow_list = [
-
- ];
- public function beforeAction($action)
- {
- $params_r = $_REQUEST['r'];
- if (in_array($params_r, self::$allow_list)) {
- return true;
- }
- // 判断当前商城是否创建云仓数据
- $store_id = get_store_id();
- $storeCloud = StoreCloud::find()->where(['store_id' => $store_id,'is_delete'=>0])->one();
- if (!$storeCloud) {
- \Yii::$app->response->format = Response::FORMAT_JSON;
- Yii::$app->response->data = [
- 'code' => 1,
- 'msg' => '未创建云仓商户,请联系管理员添加'
- ];
- return false;
- }
-
- // 重置token
- $token = get_merchant_token();
- if (!$token) {
- \Yii::$app->response->format = Response::FORMAT_JSON;
- Yii::$app->response->data = [
- 'code' => 1,
- 'msg' => '账户异常,请联系管理员处理'
- ];
- return false;
- }
- return parent::beforeAction($action);
- }
- }
|