shish 5 年 前
コミット
13a6769b75

+ 1 - 1
app-ghs/controllers/BaseController.php

@@ -28,7 +28,7 @@ class BaseController extends PublicController
     {
         //定义平台类型 1花店 2供货商
         Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'ghs');
-        //token验证 
+        //token验证
         $adminId = jwt::getLoginId();
         if (getenv('YII_ENV', 'local') != 'production') {
             //$adminId = 18;

+ 45 - 40
app-mall/controllers/BaseController.php

@@ -29,51 +29,56 @@ class BaseController extends PublicController
     {
         //定义平台类型 1花店 2供货商 3商城
         Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'mall');
-        $userId = jwt::getLoginId();
-        if (empty($userId)) {
-            util::fail('您还没有登陆');
-        }
-        $this->userId = $userId;
-        $user = UserClass::getById($userId, true);
-        if (empty($user)) {
-            util::fail('没有找到客户信息');
-        }
-        $this->user = $user;
-        $this->isWx = util::isWx();
-
-        //$header = httpUtil::getHeader();
-        //$shopId = isset($header['account']) ? $header['account'] : 0;
-        $shopId = Yii::$app->request->get('account', 0);
-        $this->shopId = $shopId;
-        if (!empty($shopId)) {
-            $shop = ShopClass::getById($shopId, true);
-            if (empty($shop)) {
-                util::fail('没有找到门店');
+        if (httpUtil::isMiniProgram()) {
+            $userId = jwt::getLoginId();
+            if (empty($userId)) {
+                util::fail('您还没有登陆');
             }
-            $sjId = $shop->sjId ?? 0;
-            if (empty($sjId)) {
-                util::fail('没有找到商家哦');
+            $this->userId = $userId;
+            $user = UserClass::getById($userId, true);
+            if (empty($user)) {
+                util::fail('没有找到客户信息');
             }
-            $sj = SjClass::getById($sjId, true);
-            if (empty($sj)) {
-                util::fail('没有找到商家信息');
-            }
-            $this->sjId = $sjId;
-            $this->sj = $sj;
-            $this->shop = $shop;
-            $this->sjExtend = MerchantExtendService::getBySjId($sjId);
-            $userInfo = isset($user->attributes) ? $user->attributes : [];
-            $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('没有找到客户信息哦');
+            $this->user = $user;
+            $this->isWx = util::isWx();
+
+            //$header = httpUtil::getHeader();
+            //$shopId = isset($header['account']) ? $header['account'] : 0;
+            $shopId = Yii::$app->request->get('account', 0);
+            $this->shopId = $shopId;
+            if (!empty($shopId)) {
+                $shop = ShopClass::getById($shopId, true);
+                if (empty($shop)) {
+                    util::fail('没有找到门店');
+                }
+                $sjId = $shop->sjId ?? 0;
+                if (empty($sjId)) {
+                    util::fail('没有找到商家哦');
+                }
+                $sj = SjClass::getById($sjId, true);
+                if (empty($sj)) {
+                    util::fail('没有找到商家信息');
+                }
+                $this->sjId = $sjId;
+                $this->sj = $sj;
+                $this->shop = $shop;
+                $this->sjExtend = MerchantExtendService::getBySjId($sjId);
+                $userInfo = isset($user->attributes) ? $user->attributes : [];
+                $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('没有找到客户信息哦');
+                    }
                 }
             }
+        } else {
+            //非登陆情况的请求,支付宝扫码付款需要用到
         }
+
         return parent::beforeAction($action);
     }
 

+ 6 - 1
app-mall/controllers/CustomController.php

@@ -3,6 +3,7 @@
 namespace mall\controllers;
 
 use bizHd\custom\classes\CustomClass;
+use common\components\httpUtil;
 use common\components\util;
 
 class CustomController extends BaseController
@@ -14,7 +15,11 @@ class CustomController extends BaseController
     public function actionInitCustom()
     {
         $custom = [];
-        if(!empty($this->shopId)){
+        //非登陆情况的请求,支付宝扫码付款需要用到
+        if (httpUtil::isMiniProgram() == false) {
+            util::success($custom);
+        }
+        if (!empty($this->shopId)) {
             $custom = CustomClass::replaceCustom($this->sjId, $this->user, $this->shopId);
             if (empty($custom)) {
                 util::fail('没有找到客户信息');

+ 1 - 4
app-mall/controllers/OrderController.php

@@ -137,13 +137,10 @@ class OrderController extends BaseController
     public function actionOrderRelate()
     {
         $regionTree = RegionService::tree();
-        $shop = $this->shop->attributes;
+        $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
         $freight = ['first' => 5, 'add' => 2];
         $mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
         $out = ['freight' => $freight, 'shop' => $shop, 'region' => $regionTree, 'txMapKey' => $mapKey, 'merchant' => $shop];
-        Yii::info(json_encode($shop));
-        Yii::info($shop['shopName']);
-        Yii::info('111111');
         util::success($out);
     }