Browse Source

最近访问

shish 3 years ago
parent
commit
735820bdae

+ 2 - 1
app-mall/controllers/ShopController.php

@@ -9,6 +9,7 @@ use bizMall\goods\services\GoodsCategoryService;
 use bizMall\invite\services\InviteService;
 use bizMall\merchant\services\MerchantService;
 use bizMall\merchant\services\ShopService;
+use bizMall\user\classes\UserClass;
 use bizMall\user\services\UserService;
 use common\components\imgUtil;
 use Yii;
@@ -35,7 +36,7 @@ class ShopController extends BaseController
     //最新店铺 ssh 20220506
     public function actionGetNewShop()
     {
-        $respond = ShopClass::getNewShopList();
+        $respond = UserClass::getRecentShop($this->user);
         $showGlInfo = getenv('SHOW_GL_INFO');
         $info = $showGlInfo === false ? 1 : $showGlInfo;
         $respond['showGlInfo'] = $info;

+ 1 - 1
app-mall/controllers/UserController.php

@@ -30,7 +30,7 @@ class UserController extends BaseController
     //最近店铺 ssh 2021.2.27
     public function actionRecentShop()
     {
-        $list = UserClass::getRecentShop($this->user);
+        $list = [];
         //显示国兰的信息 0不是 1是
         $showGlInfo = getenv('SHOW_GL_INFO');
         $info = $showGlInfo === false ? 1 : $showGlInfo;

+ 18 - 8
biz-mall/user/classes/UserClass.php

@@ -11,6 +11,7 @@ use bizMall\message\classes\ChatClass;
 use bizMall\user\services\UserIntegralService;
 use common\components\business;
 use common\components\dict;
+use common\components\imgUtil;
 use common\components\stringUtil;
 use common\components\util;
 use common\components\wxUtil;
@@ -55,20 +56,29 @@ class UserClass extends BaseClass
         'system' => ['id' => 5, 'name' => 'system'],
     ];
 
-    //最近访问的门店 ssh 2021.4.10
+    //最近访问的门店 ssh 20220916
     public static function getRecentShop($user)
     {
-        $recent = $user['recentShop'];
+        if (empty($user)) {
+            return [];
+        }
+        $recent = $user->recentShop;
         $list = [];
         if (!empty($recent)) {
             $ids = json_decode($recent, true);
             $list = ShopClass::getShopByIds($ids);
-            foreach ($list as $key => $val) {
-                $shopName = $val['shopName'] ?? '';
-                $sjName = $val['merchantName'] ?? '';
-                $default = $val['default'] ?? 0;
-                $showName = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
-                $list[$key]['showName'] = $showName;
+            if (!empty($list)) {
+                foreach ($list as $key => $val) {
+                    $shopName = $val['shopName'] ?? '';
+                    $sjName = $val['merchantName'] ?? '';
+                    $default = $val['default'] ?? 0;
+                    $showName = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
+                    $list[$key]['showName'] = $showName;
+                    $shortAvatar = $val['avatar'] ?? '';
+                    $smallAvatar = imgUtil::groupImg($shortAvatar) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
+                    $list['shortAvatar'] = $shortAvatar;
+                    $list['smallAvatar'] = $smallAvatar;
+                }
             }
         }
         return $list;