shish 5 лет назад
Родитель
Сommit
8c6ca4ffb8

+ 0 - 3
app-ghs/controllers/ProductController.php

@@ -29,9 +29,6 @@ class ProductController extends BaseController
         $py = Yii::$app->request->get('py', '');
         $type = Yii::$app->request->get('type', '');
 
-        //访问店铺时用户增加最近访问的店铺 ssh 2021.3.1
-        AdminClass::addRecentShop($this->lookShopId, $this->admin);
-
         //获取所有当前供应商的分类 (全部、常用)
         //根据分类组装分类下的花材信息
         $classIds = ItemClassClass::getGhsItemClassAll($this->sjId);

+ 1 - 2
app-hd/controllers/GhsProductController.php

@@ -19,13 +19,12 @@ use Yii;
 class GhsProductController extends BaseController
 {
 
-    //从零售端采购入库,查看供货商的某个门店的product
+    //零售进店采购
     public function actionIndex()
     {
         $get = Yii::$app->request->get();
         $shopId = $get['shopId']??0;
         $sjId = $get['sjId']??0;
-        AdminClass::addRecentShop($shopId,$this->admin);
 
         //获取所有当前供应商的分类 (全部、常用)
         //根据分类组装分类下的花材信息

+ 1 - 10
app-mall/controllers/AuthController.php

@@ -156,15 +156,8 @@ class AuthController extends PublicController
         $unionId = isset($arr['unionid']) && !empty($arr['unionid']) ? $arr['unionid'] : '';
         $userInfo = ['miniOpenId' => $miniOpenId, 'unionId' => $unionId];
         $userSource = UserClass::$userSourceId['mini']['name'];
-        $shopId = $this->shopId;
         $sjId = 0;
-        if (!empty($shopId)) {
-            $shop = ShopClass::getById($shopId);
-            $sjId = $shop['merchantId'] ?? 0;
-        }
         $user = UserClass::replaceUser($userInfo, $userSource, $sjId);
-        $custom = $user['customInfo'] ?? [];
-        $customId = $custom['id'] ?? 0;
         $cacheKey = 'MALL_MINI_SESSION_KEY_' . $miniOpenId;
         Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
         $userId = $user['id'];
@@ -173,9 +166,7 @@ class AuthController extends PublicController
         util::success([
             'token' => $token,
             'user' => $user,
-            'update' => 0,
-            'customId' => $customId,
-            'custom' => $custom
+            'update' => 0
         ]);
     }
 

+ 22 - 34
app-mall/controllers/BaseController.php

@@ -17,7 +17,7 @@ class BaseController extends PublicController
 
     public $validate = true;
     public $guestAccess = [];
-    public $userId = 0, $user, $shopId,$shop;
+    public $userId = 0, $user, $shopId, $shop;
     public $sjId, $sj, $sjExtend, $customId = 0, $custom = [];
     public $isWx;
 
@@ -28,16 +28,21 @@ class BaseController extends PublicController
 
         $userId = jwt::getLoginId();
 
-        $sjId = 0;
-        if (in_array($action->id, $this->guestAccess) == false){
-            $header = httpUtil::getHeader();
-            $shopId = isset($header['account']) ? $header['account'] : 0;
-            if (empty($shopId)) {
-                util::fail('没有找到门店');
-            }
+        if (empty($userId)) {
+            util::fail('您还没有登陆');
+        }
+        $this->userId = $userId;
+        $userInfo = UserService::getUserInfo($userId);
+        $this->user = $userInfo;
+        $this->isWx = util::isWx();
+
+        $header = httpUtil::getHeader();
+        $shopId = isset($header['account']) ? $header['account'] : 0;
+        $this->shopId = $shopId;
+        if (!empty($shopId)) {
             $shop = ShopClass::getById($shopId);
             if (empty($shop)) {
-                util::fail('没有找到门店哦');
+                util::fail('没有找到门店');
             }
             $sjId = $shop['merchantId'] ?? 0;
             if (empty($sjId)) {
@@ -45,41 +50,24 @@ class BaseController extends PublicController
             }
             $sj = MerchantService::getMerchantById($sjId);
             if (empty($sj)) {
-                util::fail('没有找到商家');
+                util::fail('没有找到商家信息');
             }
             $this->sjId = $sjId;
             $this->sj = $sj;
-            $this->shopId = $shopId;
             $this->shop = $shop;
             $this->sjExtend = MerchantExtendService::getByMerchantId($sjId);
-        }
-
-        $this->isWx = util::isWx();
-
-        if (empty($userId)) {
-            $this->validate = false;
-        } else {
-            $this->validate = true;
-            $this->userId = $userId;
-            $userInfo = UserService::getUserInfo($userId);
-            if (empty($userInfo)) {
-                util::fail('没有用户信息');
-            }
-            $this->user = $userInfo;
-            if (in_array($action->id, $this->guestAccess) == false) {
-                $custom = CustomClass::replaceCustom($sjId, $userInfo);
+            $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('没有找到客户信息,无权限访问');
+                }
             }
         }
-        //游客可以访问的方法
-        if (in_array($action->id, $this->guestAccess)) {
-            $this->validate = true;
-        }
-        if ($this->validate == false) {
-            util::notLogin();
-        }
+
         return parent::beforeAction($action);
     }
 

+ 24 - 0
app-mall/controllers/CustomController.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace mall\controllers;
+
+use bizHd\custom\classes\CustomClass;
+use Yii;
+use common\components\util;
+
+class CustomController extends BaseController
+{
+
+    public $guestAccess = ['init-custom'];
+
+    //生成客户信息 shish 2021.5.1
+    public function actionInitCustom()
+    {
+        $custom = CustomClass::replaceCustom($this->sjId, $this->user, $this->shopId);
+        if (empty($custom)) {
+            util::fail('没有找到客户信息');
+        }
+        util::success(['custom' => $custom]);
+    }
+
+}

+ 0 - 2
app-mall/controllers/UserController.php

@@ -18,8 +18,6 @@ use yii\helpers\Json;
 class UserController extends BaseController
 {
 
-    public $guestAccess = ['recent-shop'];
-
     //最近店铺 ssh 2021.2.27
     public function actionRecentShop()
     {

+ 0 - 17
biz-hd/admin/classes/AdminClass.php

@@ -25,23 +25,6 @@ class AdminClass extends BaseClass
         'wx84d95afcb7b594eb' => ['oTFbYvsjwgVwXggwtlM2ESAKwuN8', 'oTFbYvqP6qwdCCkdFB9GYnlzDIUg'],
     ];
 
-    //增加最近访问的门店 ssh 2021.3.1
-    public static function addRecentShop($lookShopId, $admin)
-    {
-        if (empty($lookShopId)) {
-            return false;
-        }
-        $hasRecentShop = $admin['recentShop'];
-        $adminId = $admin['id'];
-        $newShopIds = [];
-        if (!empty($hasRecentShop)) {
-            $newShopIds = josn_decode($hasRecentShop, true);
-        }
-        $newShopIds = array_merge($newShopIds, [$lookShopId]);
-        $newShopIds = array_unique(array_filter($newShopIds));
-        self::updateById($adminId, ['recentShop' => json_encode($newShopIds)]);
-    }
-
     //开店时初始化员工和角色
     public static function initAdmin($applyData, $sjId, $shopId)
     {

+ 13 - 5
biz-hd/custom/classes/CustomClass.php

@@ -20,8 +20,9 @@ class CustomClass extends BaseClass
         return 'hd_custom_key_' . $sjId . '_' . $userId;
     }
 
+
     //创建或获取客户信息 ssh 2021.3.19
-    public static function replaceCustom($sjId, $user)
+    public static function replaceCustom($sjId, $user, $shopId)
     {
         $userId = $user['id'];
         $name = $user['userName'] ?? '';
@@ -30,8 +31,12 @@ class CustomClass extends BaseClass
         $currentId = Yii::$app->redis->executeCommand('GET', [$key]);
         if (!empty($currentId)) {
             $info = self::getById($currentId);
-            return $info;
+            if (!empty($info)) {
+                $info['avatar'] = imgUtil::groupImg($info['avatar']);
+                return $info;
+            }
         }
+
         $info = self::getByCondition(['sjId' => $sjId, 'userId' => $userId]);
         if (empty($info)) {
             $py = stringUtil::py($name);
@@ -44,13 +49,14 @@ class CustomClass extends BaseClass
                 'mobile' => $mobile,
                 'visitTime' => $visitTime,
             ];
-            $info = self::addCustom($data);
+            $info = self::addCustom($data, $user, $shopId);
         }
         if (empty($info)) {
-            util::fail('没有生成客户信息');
+            return $info;
         }
         $id = $info['id'];
         Yii::$app->redis->executeCommand('SET', [$key, $id]);
+        $info['avatar'] = imgUtil::groupImg($info['avatar']);
         return $info;
     }
 
@@ -104,8 +110,10 @@ class CustomClass extends BaseClass
     }
 
     //添加客户 ssh 2021.2.28
-    public static function addCustom($data)
+    public static function addCustom($data, $user, $shopId)
     {
+        //增加最近访问的店铺
+        UserClass::addRecentShop($shopId, $user);
         return self::add($data);
     }
 

+ 7 - 13
biz-mall/user/classes/UserClass.php

@@ -58,21 +58,12 @@ class UserClass extends BaseClass
     public static function getRecentShop($user)
     {
         $recent = $user['recentShop'];
-        $arr = [];
+        $list = [];
         if (!empty($recent)) {
             $ids = json_decode($recent, true);
             $list = ShopClass::getShopByIds($ids);
-            if (!empty($list)) {
-                foreach ($list as $key => $val) {
-                    $arr[] = [
-                        'shopId' => $val['id'],
-                        'shopName' => $val['shopName'],
-                        'shopImg' => $val['avatar'],
-                    ];
-                }
-            }
         }
-        return $arr;
+        return $list;
     }
 
     //添加最近访问的门店 ssh 2021.4.10
@@ -571,8 +562,11 @@ class UserClass extends BaseClass
             }
         }
 
-        //创建客户信息
-        $custom = CustomClass::replaceCustom($sjId, $user);
+        $custom = [];
+        if (!empty($sjId)) {
+            //创建客户信息
+            $custom = CustomClass::replaceCustom($sjId, $user);
+        }
         $user['customInfo'] = $custom;
 
         return $user;

+ 1 - 1
common/components/dict.php

@@ -10,7 +10,7 @@ class dict
     public static $data = [
 
         //需要显示国兰的信息 0不需要 1需要(要审核小程序请显示国兰信息)
-        'showGlInfo' => 1,
+        'showGlInfo' => 0,
         //显示零售和供货商的演示入口
         'showDemo' => 1,
         //零售演示的管理员id