shizhongqi před 10 měsíci
rodič
revize
0cc4b2ff46
1 změnil soubory, kde provedl 8 přidání a 6 odebrání
  1. 8 6
      biz-mall/message/services/ChatService.php

+ 8 - 6
biz-mall/message/services/ChatService.php

@@ -223,16 +223,18 @@ class ChatService extends BaseService
         $where = [];
         $where['userId'] = $userId;
         $where['delStatus'] = 0;
-        $hdList = HdClass::getAllByCondition($where,'inTurn DESC, addTime DESC', 'customId, shopId');
+        $hdList = HdClass::getAllByCondition($where,'inTurn DESC, addTime DESC', 'id, customId, shopId');
         // 生成以 shopId 为键的新数组
         $hdListByShopId = ArrayHelper::index($hdList, 'shopId');
         $shopList = ShopClass::getByIds($ids, null, null, 'id, avatar, shopName, merchantName');
-        foreach ($shopList as $shopId => $info) {
-            $shopList[$shopId]['unReadNum'] = isset($userData[$info['id']]['unReadNum']) ? $userData[$info['id']]['unReadNum'] : 0;
-            $shopList[$shopId]['chatTime'] = isset($userData[$info['id']]['time']) ? $userData[$info['id']]['time'] : 0;
-			$shopList[$shopId]['customId'] = isset($hdListByShopId[$info['id']]['customId']) ? $hdListByShopId[$info['id']]['customId'] : 0;
+        foreach ($shopList as $key => $shop) {
+            $shopId = $shop['id'];
+            $shopList[$key]['unReadNum'] = isset($userData[$shopId]['unReadNum']) ? $userData[$shop['id']]['unReadNum'] : 0;
+            $shopList[$key]['chatTime'] = isset($userData[$shopId]['time']) ? $userData[$shop['id']]['time'] : 0;
+			$shopList[$key]['customId'] = isset($hdListByShopId[$shopId]['customId']) ? $hdListByShopId[$shop['id']]['customId'] : 0;
+			$shopList[$key]['hdId'] = $hdListByShopId[$shopId]['id'];
 
-            $shopList[$shopId]['avatar'] = imgUtil::groupImg($info['avatar']) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
+            $shopList[$key]['avatar'] = imgUtil::groupImg($shop['avatar']) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
         }
         $shopList = arrayUtil::arraySort($shopList, 'chatTime', SORT_DESC);
         return array_values($shopList);