wesmiler 2 лет назад
Родитель
Сommit
aa5b3d956b

+ 2 - 2
app/Http/Controllers/Api/v1/MessageController.php

@@ -90,8 +90,8 @@ class MessageController extends webApp
     public function setRead()
     {
         $chatKey = request()->post('chat_key','');
-        $msgType = request()->post('msg_type',1);
-        if(!$result = MessageService::make()->setRead($this->userId, $msgType, $chatKey)){
+        $type = request()->post('type',0);
+        if(!$result = MessageService::make()->setRead($this->userId, $type, $chatKey)){
             return message(1020, false);
         }else{
             return message(1019, true);

+ 4 - 1
app/Services/Api/MessageService.php

@@ -426,7 +426,7 @@ class MessageService extends BaseService
      */
     public function getUnreadCount($userId, $chatKey=0, $type=0)
     {
-        $cacheKey = "caches:messages:unReadCount:{$userId}_{$chatKey}_{$type}";
+        $cacheKey = "caches:messages:un_{$userId}_{$chatKey}_{$type}";
         $data = RedisService::get($cacheKey);
         if(RedisService::exists($cacheKey)){
             return $data;
@@ -502,6 +502,7 @@ class MessageService extends BaseService
         // 清除缓存
         RedisService::keyDel("caches:messages:bar*");
         RedisService::keyDel("caches:messages:new_*");
+        RedisService::keyDel("caches:messages:un_*");
         RedisService::keyDel("caches:messages:topList_{$userId}");
         return true;
     }
@@ -520,6 +521,7 @@ class MessageService extends BaseService
         // 清除缓存
         RedisService::keyDel("caches:messages:bar*");
         RedisService::keyDel("caches:messages:new_*");
+        RedisService::keyDel("caches:messages:un_*");
         RedisService::keyDel("caches:messages:topList_{$userId}");
         return true;
     }
@@ -537,6 +539,7 @@ class MessageService extends BaseService
         // 清除缓存
         RedisService::keyDel("caches:messages:bar*");
         RedisService::keyDel("caches:messages:new_*");
+        RedisService::keyDel("caches:messages:un_*");
         RedisService::keyDel("caches:messages:topList_{$userId}");
         return true;
     }